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:
- 11:0b6425f59e17
- Parent:
- 10:ae1d07ffddea
- Child:
- 12:0df73cbe5cbf
--- a/main.cpp Wed Aug 24 16:29:18 2016 +0000 +++ b/main.cpp Thu Oct 06 21:18:53 2016 +0000 @@ -1,11 +1,13 @@ /** * Simple example to demo the STM-Client REST calls */ +#include "ST_L152_32MHZ.h" #include "mbed.h" #include "DHT.h" #include <STMClient.h> #include <STMClientRest.h> +//#include <RCC_config.h> /*-------- Check if platform compatible ----------*/ #if DEVICE_SERIAL_ASYNCH @@ -31,7 +33,7 @@ // Initialize a REST client on the connection to esp-link STMClientRest rest(&esp); bool wifiConnected = false; -Ticker flipper; + Ticker post_data; bool posted = false; bool ESPisAsleep = false; @@ -169,8 +171,8 @@ } return "0"; } - - +//initialize light variables We don't want these to get reset each time... +float lnow = 0.0f, lmax = 50.00, lmin = 20.00; int loop_post() { posted = false; @@ -186,15 +188,15 @@ int error = 0; float l = 0.0f, h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f; - float lnow = 0.0f, lmax = 50.00, lmin = 20.00; + wait(2.0f); error = DHTsensor.readData(); - if (0 == error) { + if (0 == error || 6 == error) { //c = sensor.ReadTemperature(CELCIUS); f = DHTsensor.ReadTemperature(FARENHEIT); //k = sensor.ReadTemperature(KELVIN); h = DHTsensor.ReadHumidity(); - lnow = Lsensor.read()*100; //random_number(0, 99); + lnow = Lsensor.read()*100; if(lnow > lmax) { @@ -204,7 +206,7 @@ lmin = lnow; } - l = (lnow - lmin)/(lmax-lmin); + l = ((lnow - lmin)/(lmax-lmin))*100; //dp = sensor.CalcdewPoint(c, h); //dpf = sensor.CalcdewPointFast(c, h); @@ -256,7 +258,7 @@ return 0; } -void flip() { +void post() { led2 = 1; if(ESPisAsleep){ debugSerial.printf("syncing...\n\r"); @@ -294,7 +296,7 @@ syncESP(); //sync the ESP beginREST(); //resync the REST - flipper.attach(&flip, 60.0); // the address of the function to be attached (flip) and the interval (2 seconds) + post_data.attach(&post, 60.0); // the address of the function to be attached (flip) and the interval (2 seconds) while(true){ if(posted)