Upper Version Add PUT method Delete POST method
Dependencies: Adafruit_GFX MbedJSONValue_v102 WIZnetInterface mbed
Fork of WIZwiki-REST-io_v102 by
Revision 6:2974bbc94e7a, committed 2016-07-29
- Comitter:
- joon874
- Date:
- Fri Jul 29 08:14:28 2016 +0000
- Parent:
- 5:473a66ae9596
- Child:
- 7:64db444b21f4
- Commit message:
- Add ADC peri
Changed in this revision
--- a/MbedJSONValue.lib Mon Jul 04 00:14:31 2016 +0000 +++ b/MbedJSONValue.lib Fri Jul 29 08:14:28 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/joon874/code/MbedJSONValue_copy/#fb820325a830 +https://developer.mbed.org/users/joon874/code/MbedJSONValue_copy/#c917476c802b
--- a/RequestHandler.cpp Mon Jul 04 00:14:31 2016 +0000
+++ b/RequestHandler.cpp Fri Jul 29 08:14:28 2016 +0000
@@ -33,18 +33,20 @@
#endif
if(tmpJson->hasMember(tok)){
tmpJson = &((*tmpJson)[tok]);
+ //if(!tmpJson->accessible) tmpJson->cb_action(tmpJson);
name = tok;
tok = strtok_r(0, "/", &last);
}
else{
-#ifdef DEBUG_HTTPREQ
+#ifndef DEBUG_HTTPREQ
printf("No Member\r\n");
#endif
break;
}
}
if(name){
- if(tok){
+ if(tok)
+ {
if(tmpJson->accessible){
#ifdef DEBUG_HTTPREQ
printf("accessible : tmpJson->size()=%d\r\n",tmpJson->size());
--- a/main.cpp Mon Jul 04 00:14:31 2016 +0000
+++ b/main.cpp Fri Jul 29 08:14:28 2016 +0000
@@ -8,7 +8,7 @@
#define SERVER_PORT 80
-//#define DHCP
+#define DHCP
//#define DEBUG
@@ -22,15 +22,20 @@
start();
};
};
+
+//-- I2C OLED --
I2CPreInit gI2C(PA_10,PA_9);
Adafruit_SSD1306_I2c gOled(gI2C,NC,0x78,64,128);
//-- PWM DC --
PwmOut DC(D6);
-//-- GPIO --
+//-- GPIO LED --
DigitalInOut GP05(D5);
+//-- ADC --
+AnalogIn ain(A0);
+
EthernetInterface eth;
HTTPServer WIZwikiWebSvr;
MbedJSONValue WIZwikiREST;
@@ -41,6 +46,7 @@
char ip_addr[] = "192.168.100.100";
char subnet_mask[] = "255.255.255.0";
char gateway_addr[] = "192.168.100.1";
+float ain_value;
GetRequestHandler myGetReq;
PostRequestHandler myPostReq;
@@ -48,7 +54,6 @@
//-- I2C OLED --
bool oled_set(void* param)
{
- printf("param : %c \r\n", param);
char * oled;
if(!param) return false;
oled = (char*) param;
@@ -61,7 +66,6 @@
//-- PWM DC --
bool pwm_set(void* param)
{
- printf("%d\r\n",(*(int*)param));
if(!param) return false;
DC.write((float)(*(int*)param)/100.0);
return true;
@@ -69,10 +73,16 @@
//-- GPIO --
bool p5_set(void* param)
{
- if(!param) return false;
+ if(!param) return false;
GP05.write(*(int*)param);
return true;
}
+//-- ADC --
+bool ain_read(void* param)
+{
+ ((MbedJSONValue*)param)->_value.asDouble = ain.read();
+ return true;
+}
void debug_info()
{
@@ -104,6 +114,9 @@
//GPIO set & init
GP05.output();
GP05.write(1);
+
+ //ADC init
+ //
printf("START \r\n");
printf("sizeof(MbedJSONValue)=%d\r\n",sizeof(MbedJSONValue));
@@ -175,7 +188,7 @@
void WIZwiki_REST_init(void)
{
//Fill the object
- WIZwikiREST["Name"] = "WIZwiki-RESTful-01";
+ WIZwikiREST["Name"] = "WIZwikiREST-io ver1.01";
WIZwikiREST["Name"].accessible = false;
#ifdef DEBUG
debug_info();
@@ -204,6 +217,11 @@
WIZwikiREST["GPIOs"]["P05"] = GP05.read();
WIZwikiREST["GPIOs"]["P05"].accessible = true;
WIZwikiREST["GPIOs"]["P05"].cb_action = p5_set;
+
+ // ADC
+ WIZwikiREST["ADC"]["A0"] = ain.read();
+ WIZwikiREST["ADC"]["A0"].accessible = false;
+ WIZwikiREST["ADC"]["A0"].cb_action = ain_read;
#ifdef DEBUG
debug_info();
