Skip to content

Conversation

nitej
Copy link
Contributor

@nitej nitej commented Mar 5, 2017

Quick modification to use with Particle v2 library structure.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.958% when pulling f50cbc5 on foodbag:master into 13409c4 on bblanchon:master.

@bblanchon
Copy link
Owner

Hi Jacob,

Thank you very much for this 👍

Just a few questions:

  1. Is the empty .cpp file required?
  2. If so, does it has to be named ArduinoJson.cpp or can it be something else like EmptyFile.cpp?
  3. Is the usage.ino mandatory too?

@nitej
Copy link
Contributor Author

nitej commented Mar 6, 2017 via email

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.958% when pulling 324bc03 on foodbag:master into 13409c4 on bblanchon:master.

@bblanchon
Copy link
Owner

Thanks Jacob 👍

The Particle team is removing the requirement on the .cpp file.
See: particle-iot/particle-library-manager#26

Let's wait for this before merging into master.

@skala2301
Copy link

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?
Thanks for reading and for your work, i'll wait for your answer.

@bblanchon
Copy link
Owner

@skala2301 I don't know, but maybe @foodbag can help?

@nitej
Copy link
Contributor Author

nitej commented Mar 15, 2017

@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.

@skala2301
Copy link

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?

@nitej
Copy link
Contributor Author

nitej commented Mar 15, 2017

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.)

@skala2301
Copy link

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?

@bblanchon
Copy link
Owner

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.
You just need to extract the folder include/ in your project folder.

The result should look like:
image

@nitej
Copy link
Contributor Author

nitej commented Mar 17, 2017

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.

@bblanchon
Copy link
Owner

Hello @skala2301,

I added a single file version of ArduinoJson 5.8.4:
https://github.com/bblanchon/ArduinoJson/releases/download/v5.8.4/ArduinoJson-v5.8.4.h

You just need to copy this file in alongside with your project's files.
What's new is that you just need to copy one file, instead of a folder.

See ArduinoJson 5.8.4

Regards,
Benoit

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 99.98% when pulling 796c8f5 on foodbag:master into 13409c4 on bblanchon:master.


#pragma once

#ifndef PARTICLE
Copy link
Owner

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.

Copy link
Contributor Author

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"
Copy link
Owner

@bblanchon bblanchon Apr 20, 2017

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

bblanchon added a commit that referenced this pull request Apr 20, 2017
@nitej
Copy link
Contributor Author

nitej commented Apr 20, 2017

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).

@bblanchon
Copy link
Owner

Hi @foodbag,

I removed the Print class completely in 9afa05e.

However, a question remains: should we support 0.6.1+ only? or should we check the PARTICLE constant?
I'm calling to your own opinion on this.

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.

@nitej
Copy link
Contributor Author

nitej commented Apr 24, 2017

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.

@bblanchon
Copy link
Owner

Thank you very much for your help Jacob.
I just released ArduinoJson 5.9.0 as the first version compatible with Particle.

@bblanchon bblanchon closed this Apr 24, 2017
Repository owner locked and limited conversation to collaborators Sep 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants