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:
- 5:9f3015b18b24
- Parent:
- 4:31bed73a0d08
- Child:
- 6:faf57101b59c
--- a/main.cpp Tue Aug 09 22:42:31 2016 +0000 +++ b/main.cpp Wed Aug 10 14:14:22 2016 +0000 @@ -29,6 +29,22 @@ Ticker flipper; Ticker post_data; bool posted = false; +//generate some random numbers +int random_number(int min_num, int max_num); +int random_number(int min_num, int max_num){ + int result=0,low_num=0,hi_num=0; + if(min_num<max_num) + { + low_num=min_num; + hi_num=max_num+1; // this is done to include max_num in output. + }else{ + low_num=max_num+1;// this is done to include max_num in output. + hi_num=min_num; + } + srand(time(NULL)); + result = (rand()%(hi_num-low_num))+low_num; + return result; + } // Callback made from esp-link to notify of wifi status changes // Here we print something out and set a global flag @@ -79,6 +95,7 @@ return "0"; } + int loop_post() { posted = false; @@ -88,11 +105,21 @@ debugSerial.printf("Wifi Connected: %i \n\r",wifiConnected); // if we're connected make an HTTP request if(wifiConnected) { + //this is where the calls to the sensor drivers should go. + //ideally they will be blocking so they don't return a value and allow the program to move on until each + //function is complete + int Tint = random_number(65, 99); + int Lint = random_number(0, 99); + int Hint = random_number(20, 25); + + char T[2]; + sprintf(T, "%d", Tint); + char L[2]; + sprintf(L, "%d", Lint); + char H[2]; + sprintf(H, "%d", Hint); + //debugSerial.printf("H: %s \n\r",H); //check to make sure the value is the same - const char* T = "25"; - const char* L = "95"; - const char* H = "25"; - /**make sure that the size of this array is consistent with the input string**/ const char* body = ""; char output [62];