Local server in node.js example


#44

You need to set the IP & port of your server via the Particle.function()

You may want to reread the first post to understand the whole setup process and process flow.


#46

Hi, Thank to you, Its working now and I can get the 2 readings from my sensor, As a next step, I want to plot 2 graph lines in different colors from my 2 different reading, any advice on how can i acheive that?
Thank you again for you kind help.


#47

I’d look in this file
https://github.com/rickkas7/localserver/blob/master/livegraph/public/main.js


#48

I’m not sure I understand what you mean by setting the IP/port since a devicesRequest is published and in the setup it initiates the function for devicesHandler? What exactly is missing?


#49

The device needs to know which client to report to in this block

case STATE_CONNECT:
		if (client.connect(serverAddr, serverPort)) {
			client.println("POST /devices HTTP/1.0");
			client.printlnf("Authorization: %s", nonce);
			client.printlnf("Content-Length: 99999999");
		    client.println();
		    state = STATE_SEND_DATA;
		}

How do you think deviceHandler() will set serverAddr, serverPort and nonce and to what values?
Where should these come from?

If everything goes to plan these infos would be supplied by a server that responds to the publish, but if that doesn’t happen for some reason, you can (may need to) do this via a “manual” call to deviceHandler() providing the needed data.