HTTP server (REST & JSON) on Spark core

Hye
This project implement a Http server on Sparkcore itself. Once compiled into the Web IDE, the server will be available at http://IP-SPARKCORE (port 80 by default)
My Github : HTTP server (REST & JSON) on Spark core

Google+ Community

4 Likes

I managed to flash first time using web IDE. But I am not able to Flash it again. Only on commenting out the ws.loop(); IDE is able to flash the core.

What’s your Spark firmware ?
In IDE [Setting]
My FW is version 0.21

It is 0.2.1. What I have noticed is – If I am making use of Spark Tinker functions, like digitialread etc, I am not able to flash the Core from IDE. I either need to comment out Spark tinker functions or ws.opp(); in order to flash the core from IDE.

What is ws.opp() function ? ws.loop() ?
What error is displayed in debug build (the bottom of the IDE)?

Sorry it was a typo… ws.loop();

There was one error with my code. It is getting flashed now.

1 Like

Captain… Attempting to test your application but getting compile errors… hard for me, possibly easy for you to solve.

\core-firmware\build/…/inc/HttpResponse.h:50: undefined reference to HttpResponse::DEFAULT_CONTENT_TYPE' obj/src/application.o: In functionWebServer::loop()’:

and similar for
undefined reference to HttpRequest::HttpRequest()' undefined reference toHttpRequest:: parse(char)'
undefined reference to `HttpRequest::URL() const’
and so on…

Please advise if you can.

I am using NetBeans as a local compiler rather than the cloud. I am off to compile on the cloud hoping to find the solution there.

Thank you very much

Hye @LZHenry ,
Sorry for my english, I am a french.
I dont know compile the project without the Web IDE. I do not know Netbeans.
Sorry !

Captain… I am from the US and wish I could speak/write other languages!!!

Transferred your code to the cloud and was able to load into the CORE. Now I need to understand how to use the browser to display the WEB page.

  1. I assume that with NetBeans compiler I am not properly picking up a typedef for one of your variables; the cloud is properly recognizing the structures. I need to search and learn.

Thank you for sharing the project.

Hello Sir, I tried to flash the code using web IDE. it flashed properly, but i m not able to open the webpage while i am connected to the same network to which core is connected. In the video, you have used 192.168.1.31… I tried to access using this url but it was not working. How can I know or get the IP address of the server implemented in the core, printed on the screen? How to use “serial.print”? Please help.

Hi @Prashut

you must use a network scanner to identify the Spark core IP address of your subnet.

@prashuk, here is a topic on different ways to get your Core’s IP address:

thanks peekay !! :slight_smile:
I used
Serial.print(" Local IP: ");
Serial.println(Network.localIP());

to get my IP.

Is there any way to connect my spark core with proxy server or to set the proxy to connect my core with wi-fi ??

I get everything to validate and upload, but when I go to the ip address in the browser, the website looks nothing like the examples in the video. Instead, I get a static line of text saying:

{"D0":0,"D1":0,"D2":0,"D3":0,"D4":0,"D5":0,"D6":0,"D7":0}

or at analogue:

{"A0":1943,"A1":2105,"A2":2100,"A3":2097,"A4":2128,"A5":2126,"A6":2073,"A7":2083}

What am I doing wrong?

Hi
Actually I changed the GUI to optimize memory.

You can use Old1-spark-Web-Tinker.ino in Github file for old GUI.

Ah oke, than this isn’t what I’m looking for. I want a constant stream of analog input values on a website. Looking into TCPserver and UDP now.

That’s constant stream, but with http client query.
Don’t try to refresh because core down.