I am trying to use Particle.Publish to broadcast a series of records from an instrument - initially using Particle.Publish within the Particle environment but subsequently to Google Cloud PubSub.
Each instrument issues a series of records in seperate Publish events, with each record containing the device name so that records from different instruments can be sorted out at the Subscribe end,
I am having difficulty with decoding of the device name into the message buffer as follows:
String devicename; // Get device name Particle.subscribe("particle/device/name",devnameHandler); Particle.publish("particle/device/name"); // Publish header record ncount=0; sprintf(msgBuffer,"%4d,%s,%4d-%02d-%02d,%02d%02d\0",ncount,devicename.c_str(),Time.year(), Time.month(),Time.day(),Time.hour(),Time.minute()); Particle.publish(devicename,msgBuffer,PRIVATE);
I have looked at previous queries on the bulletin board and have tried various combinations to no avail.
The record counter and date/time fields are fine but the devicename field either contains a blank, nothing at all, or a question mark.
Advice would be much appreciated (as a Fortran programmer from the 80’s there is much about the C++ language that trips me up from time to time).
Thanks in anticipation