I hope this is the right forum. I am trying to execute a simple web sockets demo as documented here: http://www.slideshare.net/ADunkels/building-day-1-upload-3
I have downloaded the latest device firmware from the Thingsquare site and registered my devices with http://demo.thsq.io
Some of the simple demos I have found work: Hello World, Blink the LEDs, etc. I am using the Develop UI on the Thingsquare site to do this rather than compiling and pushing a new firmware image to the device with the TI tool.
But the websockets example does not work. Here is the code for the device side (I have fuzzed the ip address but the one I use is real -- I can send web socket messages to it from a node.js client):
#include "thsq.h" #include "websocket.h" static struct websocket s; PROCESS(websocket_example_process, "Websocket Example"); AUTOSTART_PROCESSES(&websocket_example_process); /*---------------------------------------------------------------------------*/ static void callback(struct websocket *s, websocket_result r, uint8_t *data, uint16_t datalen) { if(r == WEBSOCKET_CONNECTED) { websocket_send_str(s, "Connected"); } else if(r == WEBSOCKET_DATA) { char buf[100]; snprintf(buf, sizeof(buf), "%.*s", datalen, data); thsq_client_set_str("data", buf); } thsq_client_push(); } /*---------------------------------------------------------------------------*/ PROCESS_THREAD(websocket_example_process, ev, data) { static struct etimer et; PROCESS_EXITHANDLER(websocket_close(&s)); PROCESS_BEGIN(); websocket_open(&s, "ws://xx.xx.xx.xx:8080/", "thingsquare", callback); while(1) { etimer_set(&et, CLOCK_SECOND * 10); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); websocket_send_str(&s, "hello"); } PROCESS_END(); }
Can anyone see any issues with this code? The Server is a simple node.js server definition that works with other client connections.
If there is a better forum for these questions, I will gladly move there.