I’m currently using Serial.printlnf(...) to log/debug my application and want to continue doing so when the device is not connected to my computer (when it’s deployed). It’d be great if I could use a command line tool like particle-cli (similar to the command particle serial monitor --follow which is what I am using to receive the Serial.printlnf() messages with the photon connected through USB).
I had a look around in the docs, but couldn’t find anything suitable (except for the cloud event system, but I find that’s too “high-level”).
Serial.print() will always only ever go to the USB Serial interface.
However, you can use the logging feature with alternative log-handlers targeting other means of communication like the papertrail log-handler https://build.particle.io/libs/papertrail/0.0.5/tab/papertrail.h
Thanks @ScruffR I’ll try to implement a log handler instead and will use the papertrail code as example. Since, I’d like to receive log message within the same network, I might start with a Tcpclient/server.
Do you have any suggestion on how to discover the log server within the WIFI network (i.e. without hardcoding the IP address in the firmware)? Sorry, slightly off-topic…
The RemoteLogRK library that ScruffR linked to has several examples that may be helpful.
The one that logs to a TCP server is one way, but then you need to store the IP address somewhere.
I prefer to use the UDP multicast, which allows anyone on the network to receive the logs if they know the multicast address and port, which is handy because you don’t have to hardcode the server IP address. It also makes it possible to have multiple receivers. Obviously you want to make sure you don’t log anything sensitive.
Excellent - that’s exactly what I was looking for (and I learned something new about mDNS). Thanks so much for your help. I’ll try the UDP multicast as it promises to match my use case very well.