-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Compatibility with Particle V2 Library Structure #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi Jacob, Thank you very much for this 👍 Just a few questions:
|
Hi Benoît,
I just checked. The library will compile through the particle-cli interface (in which it copies the library directly from my computer to be compiled) without the ArduinoJson.cpp file (which makes sense since it doesn’t do anything). However, it won’t let you upload the library to be used with the web IDE without the ArduinoJson.cpp file and it must be called ArduinoJson.cpp (it has some sort of check for it even if it is empty). It would be easy to just use a script to generate the needed blank .cpp file before uploading, but that is your call.
The usage .ino is not required to compile “locally” or upload to the particle library server and use from the web ide. That file could be removed.
Let me know if you find anything else that needs to be fixed or checked.
Jake
… On Mar 6, 2017, at 2:19 AM, Benoît Blanchon ***@***.***> wrote:
Hi Jacob,
Thank you very much for this 👍
Just a few questions:
Is the empty .cpp file required?
If so, does it has to be named ArduinoJson.cpp or can it be something else like EmptyFile.cpp?
Is the usage.ino mandatory too?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#461 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AG9NBMVj7aB1kI5hsGpbJTUkf05TRXIjks5ri8-3gaJpZM4MTTle>.
|
Thanks Jacob 👍 The Particle team is removing the requirement on the Let's wait for this before merging into master. |
Hi i have some questions, i'm relativelly new to this topic about json and including libraries for photon from github, i would like to know how may i include this library to my project? i saw the changes that you have to implement in some of the files and that, but i don't know what files i need to include in my project, is it just the include archive or do i have to add all the documents? i'm working my project locally, but when i compile it gives me a lot of errors, well and the .hpp are not recognice, when i try to compile, is there a tutorial or some specific information on how to include the last version of this Json library? what docs do i need and what don't? where do i put each file? do i need other tools than particle-cli and dfu-util to do what i need? is it posible to upload it to work it on the web ide? how may i do it? |
@skala2301 I don't know, but maybe @foodbag can help? |
@skala2301 Right now, its a little complicated (I'll explain). The lib does work with the new particle library system. However, @bblanchon and I are waiting on particle to fix some issues with particle-cli's lib uploader before finalizing this pull request (which will hopefully reduce the number of half-ported version of ArduinoJson on the particle platform). The lib also works locally when compiled with particle-cli (I haven't tested the new version of their particle desktop ide, but I recommend particle-cli since I have had the most success with it). The good news is that you don't need to modify this library at all anymore. You can clone it to the lib folder inside a particle project directory (this tutorial on the new library setup for particle-cli is good https://docs.particle.io/guide/tools-and-features/cli/photon/#working-with-projects-and-libraries) so you have the folder structure project-root/lib/ArduinoJson/. For now, you can clone my pull request repo since it has the few changes needed to compile for particle. You shouldn't need to remove anything from this repo. The bad news is something you have already encountered. Particle-cli is really finicky about what files it includes (since it have to upload everything to particle's servers for compiling I suppose), and as such it ignores .hpp files. The way around this is to modify particle-cli to include .hpp files when uploading, but that function is really buried in their particle-cli program. I will try to find some time to submit a pull request for particle-cli to include .hpp files when compiling. |
Hey thanks for your fast answer, so the fact that i have to compile passing throught the web is what may complain my project success, what happens if i try to do it all locally?, i remember reading something like you may compile your project locally with dfu-util i think, do you recommend me doing it that way? |
So, the particle ecosystem is a little different than other MCUs in that by default all compiling is done on particle's servers while the flashing of the binary to the MCU can be done OTA or usb. Even using particle-cli or the desktop ide, the compiling is done on their servers. dfu-util as far as flashing is only good for putting the compiled binary on the particle chip. Now, you can get the compiler on your computer (which is referred to as the local compiler in their speak), but it involves downloading their docker image (which is related to what they use on their particle servers), getting that image setup, and making a separate build script to make the binaries for flashing to the chips (can't use particle-cli if I remember correctly). I have never personally gotten it working, and support around the internet is slim last time I tried. (Note: this is separate from using a local particle cloud server.) |
Hey hi, i have a question, i don't really know how to integrate this library to my project due to the problem of the .hpp that i had, do you know about a library that i may use for json encode and decode, that works almost as good as this one? do you think it would be better to wait for particle to fix the problems with particle-cli's lib uploader that you mentioned?, and thanks for the explanation, i comprehend a little more of how the libraries are structured, by the way how may i modify particle-cli so that it recognices .hpp files? i actually have been watching the files at /usr/local/lib/node_modules/particle-cli, but i don't know even if i'm looking at the correct directory, i'm just trying to find somethin in the code something like ".cpp" and try to figure out what it does, but i don't have a clue, may you give me some tips for that? |
Hi @skala2301, As an alternative, you could try to include the source of ArduinoJson as part of the source of your project. ArduinoJson is a header-only library so including the source of ArduinoJson within the source of your project should be a no-brainer. |
Another temporary alternative is to use the SparkJson library, which should already be uploaded to particles servers (therefore available in the web-ide,particle-cli,etc). It was based on an older version of ArduinoJson and has much of the same syntax. However, it has not been updated in a while, so it lacks many of the newer methods that ArduinoJson has gained. It may be good enough until particle sorts out its issues with its new library format. |
Hello @skala2301, I added a single file version of ArduinoJson 5.8.4: You just need to copy this file in alongside with your project's files. Regards, |
… was fixed and merged.
|
||
#pragma once | ||
|
||
#ifndef PARTICLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure @foodbag, can you confirm that Particle doesn't define ARDUINO
? because all other platforms do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into it. The latest stable particle firmware version 0.6.1 does define ARDUINO, and does not need the ifndef PARTICLE line in Print.hpp. Anything lower than 0.6.1 (including 0.6.0) won't compile without the ifndef PARTICLE in Print.hpp. I haven't tested uploading any code to a particle board yet, but it looks like the changes to Print.hpp may be unnecessary if compatibility is limited to the latest particle board firmwares.
// https://github.com/bblanchon/ArduinoJson | ||
// If you like this project, please add a star! | ||
|
||
#include "../include/ArduinoJson.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to move everything from include/
to src/
and see if other IDE agree.
EDIT: it's already changed in master
Using the latest master, the library can be compiled and uploaded without any changes using the latest particle-cli version (if modified to include .hpp files or using the single .h file) (and if one targets the 0.6.1 firmware). |
Hi @foodbag, I removed the However, a question remains: should we support 0.6.1+ only? or should we check the If we want to do that, we need to modify this line to: #if defined(ARDUINO) || defined(PARTICLE) If we don't, I think we don't have anything to do. |
I checked compiling the newest version of ArduinoJson against the newest stable firmware 0.6.1 and older firmwares and both compile successfully. I'm not sure that it is totally necessary to include the PARTICLE definition in Configuration.hpp. I never modified that when I tested using the library pre-0.6.1 firmware and never had a problem running ArduinoJson without the ARDUINO platform specific settings. My opinion is to leave it without the PARTICLE setting since most people will probably use the latest particle firmware anyway. |
Thank you very much for your help Jacob. |
Quick modification to use with Particle v2 library structure.