J Daniel Martinez C
/
C-Conv
PIC to Mbed errors
ubidots.c@0:b329a09583fb, 2017-09-01 (annotated)
- Committer:
- dan_cuspi
- Date:
- Fri Sep 01 16:11:35 2017 +0000
- Revision:
- 0:b329a09583fb
Ubidots PIC to MBED
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan_cuspi | 0:b329a09583fb | 1 | #include "ubidots.h" |
dan_cuspi | 0:b329a09583fb | 2 | |
dan_cuspi | 0:b329a09583fb | 3 | uint8_t buffer[256]; |
dan_cuspi | 0:b329a09583fb | 4 | |
dan_cuspi | 0:b329a09583fb | 5 | /*const char* ubidotsPOST( const char* token, const char* variable_id, float value){ |
dan_cuspi | 0:b329a09583fb | 6 | uint8_t httpBody[SIZE_HTTP_BODY]; |
dan_cuspi | 0:b329a09583fb | 7 | memset(&buffer, 0,sizeof(buffer)); |
dan_cuspi | 0:b329a09583fb | 8 | sprintf(httpBody,"{\"value\":%2.2f}", value); |
dan_cuspi | 0:b329a09583fb | 9 | |
dan_cuspi | 0:b329a09583fb | 10 | sprintf(buffer, "POST /api/v1.6/variables/%s/values HTTP/1.1\r\n", variable_id); |
dan_cuspi | 0:b329a09583fb | 11 | sprintf(buffer, "%sHost: things.ubidots.com\r\n",buffer); |
dan_cuspi | 0:b329a09583fb | 12 | sprintf(buffer, "%sContent-Type: application/json\r\n", buffer); |
dan_cuspi | 0:b329a09583fb | 13 | sprintf(buffer, "%sX-Auth-Token: %s\r\n", buffer, token); |
dan_cuspi | 0:b329a09583fb | 14 | sprintf(buffer, "%sContent-Length: %i\r\n\r\n%s", buffer, strlen(httpBody), httpBody); |
dan_cuspi | 0:b329a09583fb | 15 | |
dan_cuspi | 0:b329a09583fb | 16 | return (uint8_t*)buffer; |
dan_cuspi | 0:b329a09583fb | 17 | }*/ |
dan_cuspi | 0:b329a09583fb | 18 | uint8_t* ubidotsGET(const char* token, const char* variable_id ) |
dan_cuspi | 0:b329a09583fb | 19 | { |
dan_cuspi | 0:b329a09583fb | 20 | memset(&buffer, 0,sizeof(buffer)); |
dan_cuspi | 0:b329a09583fb | 21 | sprintf(buffer,"http://www.things.com/variables/%*s/?token=%*s",sizeof(variable_id),variable_id,sizeof(token),token); |
dan_cuspi | 0:b329a09583fb | 22 | return (uint8_t*)buffer; |
dan_cuspi | 0:b329a09583fb | 23 | } |
dan_cuspi | 0:b329a09583fb | 24 | |
dan_cuspi | 0:b329a09583fb | 25 |