![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is a SLIP interface for the STM32F446RE Nucleo Board. It is designed to work specifically with the esp-link software for the ESP8266. The program is an example of a rest command.
Diff: main.cpp
- Revision:
- 3:8ed85d940c4c
- Parent:
- 2:20ea1be14e4b
- Child:
- 4:31bed73a0d08
--- a/main.cpp Thu Aug 04 19:44:11 2016 +0000 +++ b/main.cpp Fri Aug 05 16:04:04 2016 +0000 @@ -86,17 +86,29 @@ // if we're connected make an HTTP request while(wifiConnected) { postCount++; //don't post more than 3 times... - // Post to cloud - - //const char* header = "{Host: vivaplanetbusservicedev.servicebus.windows.net Authorization: SharedAccessSignature sr=https%3a%2f%2fvivaplanetbusservicedev.servicebus.windows.net%2fhummingbirdqueue%2fmessages&sig=QIGJfPSsortI9tZpoJ6ZUzfMdtvEaaIHA2pnmKZxNVg%3d&se=1470210743&skn=DevicePolicy Content-Length: 440 Expect: 100-continue Connection: Keep-Alive}"; + //***Uncomment to post to cloud***// + /* + const char* header = "{Host: vivaplanetbusservicedev.servicebus.windows.net Authorization: SharedAccessSignature sr=https%3a%2f%2fvivaplanetbusservicedev.servicebus.windows.net%2fhummingbirdqueue%2fmessages&sig=QIGJfPSsortI9tZpoJ6ZUzfMdtvEaaIHA2pnmKZxNVg%3d&se=1470210743&skn=DevicePolicy Content-Length: 440 Expect: 100-continue Connection: Keep-Alive}"; + rest.setHeader(header); + + const char* body = "{\"id\":\"17564321\",\"Address\":\"$28591\",\"PhotoUrl\":\"http://vivaplanetstoragedev.blob.core.windows.net:80/devicephotoscontainer/1457a68157e446c2bc4d0af58a0ccc63.jpg?st=2016-08-02T21%3A50%3A31Z&se=2016-08-02T22%3A05%3A31Z&sr=b&sp=w&sig=rf6ovBuFXKC937b3TMY3qVSf%2F3QOYXjqJBYcwj2MUv4%3D\",\"HasPhoto\":true,\"PhotoId\":\"1457a68157e446c2bc4d0af58a0ccc63.jpg\",\"DeviceSensors\":[{\"SensorType\":\"0\",\"Reading\":\"00:03:52.7656140\",\"Value\":\"921\"},null,null,null]}"; + rest.post("hummingbirdqueue/messages", body); //cloud post test + */ + //***Uncomment to post to test server***// + //const char* header = "{Host: posttestserver.com\n\rAuthorization: My_SSL_Authorization\n\rContent-Length: 27\n\rHTTP_EXPECT: 100-continue\n\rConnection: Keep-Alive}"; //rest.setHeader(header); - //const char* body = "{\"id\":\"17564321\",\"Address\":\"$28591\",\"PhotoUrl\":\"http://vivaplanetstoragedev.blob.core.windows.net:80/devicephotoscontainer/1457a68157e446c2bc4d0af58a0ccc63.jpg?st=2016-08-02T21%3A50%3A31Z&se=2016-08-02T22%3A05%3A31Z&sr=b&sp=w&sig=rf6ovBuFXKC937b3TMY3qVSf%2F3QOYXjqJBYcwj2MUv4%3D\",\"HasPhoto\":true,\"PhotoId\":\"1457a68157e446c2bc4d0af58a0ccc63.jpg\",\"DeviceSensors\":[{\"SensorType\":\"0\",\"Reading\":\"00:03:52.7656140\",\"Value\":\"921\"},null,null,null]}"; - //rest.post("hummingbirdqueue/messages", body); //cloud post test + const char* T = "25"; + const char* L = "95"; + const char* H = "25"; - const char* body = "{sunleaf: test1}"; - rest.post("/post.php", body); //basic post test + const char* body = ""; + char output [50]; + sprintf(output, "/update?api_key=3FF5CTKAJIU2IH0M&field1=%s&field2=%s&field3=%s", T,L,H); + //debugSerial.printf("output: %s \n\r", output); + rest.post(output, body); //basic post test + char response[BUFLEN]; memset(response, 0, BUFLEN); uint16_t code = rest.waitResponse(response, BUFLEN); @@ -166,12 +178,12 @@ // Set up the REST client to talk to www.timeapi.org, this doesn't connect to that server, // it just sets-up stuff on the esp-link side //int err = rest.begin("www.timeapi.org"); //for basic example of get - int err = rest.begin("posttestserver.com"); //for basic example of post - + const char* host = "api.thingspeak.com"; + //const char* host = "posttestserver.com"; //const char* host = "vivaplanetbusservicedev.servicebus.windows.net"; - //uint16_t port = 443; - //bool security = true; - //int err = rest.begin(host,port,security); + uint16_t port = 80; + bool security = true; + int err = rest.begin(host,port,security); if (err != 0) { debugSerial.printf("REST begin failed: %i\n\r",err);