and should i identify variables in that way var deviceID = “<< XX>>” or var deviceID = << XX>> ?
and lastly ,shall i leave this variable the same without modification
var eventSource = new EventSource(“https://api.spark.io/v1/devices/” + deviceID + “/events/?access_token=” + accessToken);
For future reference, if anybody else faces the same issues:
It can be found in the settings pane of the web IDE (the cog icon). It's actually the accesstoken to your account, not a single device. With that in mind, treat it as you would your password, since they're almost interchangable in regards to security.
The former is correct, e.g. var deviceID = "yadayada123"
Yes, assuming you have changed the variables above, these should not (don't have to) be changed, since they will use the values from above.
I am struggling with the need for changing the Core ID & Access Token from decimal to hex. With the html having decimal ID & token, the form asks a “connect click,” shares “Waiting for data,” but none is displayed on Chrome. Checking JavaScript console says “Opened” but no stream. Photon is breathing cyan.
When I convert the ID to Hex, but leave the 40 character token as is (how can you change a string of digits and letters into Hex?) the form indicates waiting for data, but JavaScript says "Errored."
I’m sure I’m the one at fault here - but where? I would sure appreciate your help.
Did you update these two lines in the web page source?
var deviceID = "<<hex device id here>>";
var accessToken = "<<hex access token here>>";
The part between the " "'s needs to be replaced with your particular ID and token. These are available in the online web IDE (Build button) under the target icon and the gear icon, respectively.
Hi , I am currently doing a project similar to this and still new here, and unfortunately it did not work. Just wondering with var deviceID, you mentioned ‘hex device ID’ , I am assuming I have to convert my device ID from decimal to hexa numbers. How about converting the access token?
Thanks for the reply ! @ScruffR
I did try inserting the device ID I got from IDE particle itself, but not sure why if I use those number my html would not even let me click the ‘connect now’ button, giving this error on my safari.
SyntaxError: Invalid character '\u8364’
The error is pointed towards the device ID on line 14.
I tried on google chrome too but still not working.
Could you have a comment on the like above it with a non-ASCII character? That is the unicode character for "meat diet; strong smelling" which is odd on a number of levels.
What editor are you using to edit the HTML source? You need a plain text editor.
Also, have you removed the << and >> symbols from the line?
You can post the line of code - the device ID isn’t as much a secret as the access token should be - if you still have concerns, you can PM one of the Elites.
I am using textedit on macbook pro. I am not too sure if I accidentally comment something on my HTML code with a non-ASCII character or not, but when I tried the code again today, IT IS WORKING now !!! @bko
and yes I did removed both symbols from the line, but the code is working now when I tried it today.
Thank you for response anyway @Moors7@ScruffR !
Not really. Particle.publish() has a rate limit of one publish per second with a maximum payload of 622 UTF-8 characters and you cannot transmit raw binary data with it.