PIC to Mbed errors

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dan_cuspi
Date:
Fri Sep 01 16:11:35 2017 +0000
Commit message:
Ubidots PIC to MBED

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
ubidots.c Show annotated file Show diff for this revision Revisions of this file
ubidots.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r b329a09583fb main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Sep 01 16:11:35 2017 +0000
@@ -0,0 +1,9 @@
+#include "mbed.h"
+#include "ubidots.h"
+
+DigitalOut myled(LED1);
+Serial pc (USBTX, USBRX);
+int main() 
+{
+    pc.printf("%s", ubidotsGET(TOKEN, VARIABLE_ID));
+}
diff -r 000000000000 -r b329a09583fb mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Sep 01 16:11:35 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/a330f0fddbec
\ No newline at end of file
diff -r 000000000000 -r b329a09583fb ubidots.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ubidots.c	Fri Sep 01 16:11:35 2017 +0000
@@ -0,0 +1,25 @@
+#include "ubidots.h"
+
+uint8_t buffer[256];
+    
+/*const char* ubidotsPOST( const char* token,  const char* variable_id, float value){
+    uint8_t  httpBody[SIZE_HTTP_BODY];
+    memset(&buffer, 0,sizeof(buffer));
+    sprintf(httpBody,"{\"value\":%2.2f}", value);
+    
+    sprintf(buffer, "POST /api/v1.6/variables/%s/values HTTP/1.1\r\n", variable_id);
+    sprintf(buffer, "%sHost: things.ubidots.com\r\n",buffer);
+    sprintf(buffer, "%sContent-Type: application/json\r\n", buffer);
+    sprintf(buffer, "%sX-Auth-Token: %s\r\n", buffer, token);
+    sprintf(buffer, "%sContent-Length: %i\r\n\r\n%s", buffer, strlen(httpBody), httpBody);
+    
+    return (uint8_t*)buffer;
+}*/
+uint8_t* ubidotsGET(const char* token, const char* variable_id )
+{
+    memset(&buffer, 0,sizeof(buffer));
+    sprintf(buffer,"http://www.things.com/variables/%*s/?token=%*s",sizeof(variable_id),variable_id,sizeof(token),token);
+    return (uint8_t*)buffer;
+}
+
+
diff -r 000000000000 -r b329a09583fb ubidots.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ubidots.h	Fri Sep 01 16:11:35 2017 +0000
@@ -0,0 +1,20 @@
+#ifndef UBIDOTS_H
+#define UBIDOTS_H
+
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+#define UBIDOTS_SERVER   "things.ubidots.com"
+#define SIZE_HTTP_BODY   100
+#define SIZE_BUFFER_POST 200
+
+#define TOKEN           "DihroZdscJDt6ZIBX8TMBr84QZDTM7"
+#define VARIABLE_ID     "59977324c03M973c345e0527"
+
+#define VALUE           "\"value\": 1.0"
+
+//const char* ubidotsPOST( const char* token,  const char* variable_id, float value);
+uint8_t* ubidotsGET(uint8_t* token, uint8_t* variable_id );
+
+#endif