Photon use BOTH particle CLI and Particle Build on the same device at the same time?

How do you set up the photon to use both the CLI and the web app at the same time?

Also how do I properly set up and compile using the CLI? Works fine for packages with no dependencies, but totally fails on finding sub projects.

It complains that it can’t find a related package.

so if I have this directory structure:
myProject------>firmware------->git_Submodule
… L------>git_submodule
… L------->firmware

however the compiler complains that it can’t find the includes. Everything works on the Particle Dev site.

I’ve manually added the files to the file “particle.include” and it works for .ino files, but fails for cpp files?
Is there a specific file structure I need? Where should includes for libraries go?

No need to do anything on the Photon. You can flash it either way by default.
But for the time being you need to adapt the include statements.
I usually do it like this

#define PARTICLE_BUILD
#ifdef PARTICLE_BUILD
#  include "libname/libname.h"
#else
#  include "libname.h"
#endif

This way you just need to #define/#undefine PARTICLE_BUILD.

The thing is that the directory structure will be flattened on upload (when properly set up in particle.include), and so you need to adjust your includes to the flattened structure, even if you got them stored hirarchically.

Thanks @ScruffR, I am assuming that I need that to have the “libname.h” form for local builds and the “libname/libname.h” for the Web IDE?

And libraries need to be flattened and placed in the same directory? Or is there a directory libraries are supposed to live in? particle compile doesn’t seem to let you pass in a lib folder on the command line.

The documentation on particle compile and particle.include is a bit light. :smile:

Thanks again!

There is no need to manually flatten the file structure anymore. You can have your direcories however you like them, as long you tell the dev tool which files to gather and from where.
Then all the files listed in there will be pulled in and uploaded to the build farm into one flat temp directory from where your project will be built.

AFAIK you can even use wild cards in particle.include (which needs to live along side your project .ino) like this

*.cpp
*.h
subdir1/*.*
subdir1/inc/*.h
subdir1/src/*.cpp

And you build like this

cd yourProjectFolder
particle compile photon . --saveTo firmware.bin

(the single dot . stands for current directory)

Thanks, this helps a lot. I currently can’t get the photon seen by both Particle Dev and the Web IDE at the same time (Even though it’s the same account) so I want the CLI version to compile correctly.

This might be something for @suda to look at, as he's the IDE guy at Particle

When compiling locally, particle.include is not included. The best way to do this is to put all of your .cpp and .h files in your firmware directory.

How do you mean that?
How do you “compile locally”?
If you mean Dev or CLI it’s not compiling locally (unless you got the alpha stage build package installed).
CLI does use particle.include just fine for me :confused:
If you mean a local toolchain, the OP didn’t seem to ask in that direction and there you’d definetly have the full depth of the firmware repo.

This is a zipped project that shows that this works with Dev and CLI

Yes, when compiling in the cloud with CLI, particle.include is included. When I compile with the local toolchain or with po-util, particle.include never seems to be included. @mrmowgli and I have been working on po-util lately.

I see - this might have been a valuable clue in the OP :wink:

Is your project in anyway related/comparable to this one?

No. It’s a bit different. It installs the toolchain and dependencies for you, you don’t have to deal with docker, and it is meant to be run from a terminal window. It is for easily installing and using the Particle Toolchain on Ubuntu-based distros and OSX.

Hi Nathan, particle.include is a cloud feature not firmware one (only works for cloud compilation).

Additionally we’re gonna release update to the CLI which allow you to use nested directories (currently whole project is being flattened).

1 Like

Nice.