Photon Book - Project 8

I’ve got project 8 working (Morse Code Text Messages) - for the most part. The only issue I seem to be having is properly processing the return value. After a text message is sent to the particle via the html page, a dialog box is supposed to pop up showing either that “Your message is being sent”, or that “Could not connect to photon”.
No matter what, the second alert box shows up, even when the communication is successful. The code that processes the return value is as shown below. It’s almost as if “data.return_value == 1” is never true.

I downloaded both the web page software, as well as the particle firmware directly from the “PHOTON_BOOK” library and its associated github page.
Thanks.

function callback(data, status){
	if (data.return_value == 1) {
		alert("Your Message is being sent");
	}
	else
	{
		alert("Could not Connect to Photon");
	}
}

It’d be great if you could provide a link to the resources you’ve used. That’d save us the hassle of trying to guess where you got it from.

Try to write the return_value to console and see what you actually get in case of success. Maybe its not a 1 but "1"

1 Like

Sorry, I’m a rookie when it comes to html/javascript coding. I did think of trying to display the return value on a webpage but didn’t know how to do it.

I tried changing it to “1” but that didn’t work. What’s interesting is that I also tried to following evaluations:
if(data.return_value > 0)…
if(data.return_value < 0)…
if(data.return_value == 0)…

Neither of the statements ever evaluated to being true.

The particle firmware code came directly from the PHOTON_BOOK library (P_08_Morse_Function). And the html code came directly from the book’s associated github account (p_08_morse_function.html). I figured it should work without the need for modification. I wonder if it has to do with my browser?

I just tried it using Chrome as opposed to Firefox and it worked fine!

1 Like