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.

Dependencies:   mbed DHT Matrix

Committer:
ShaneKirkbride
Date:
Wed Aug 17 21:14:04 2016 +0000
Revision:
9:bd7f083d55ad
Parent:
8:6a3b7c5d9ba7
Child:
10:ae1d07ffddea
added a toggleLEDSuccess() function;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ShaneKirkbride 0:70a6082c1bf7 1 /**
ShaneKirkbride 0:70a6082c1bf7 2 * Simple example to demo the STM-Client REST calls
ShaneKirkbride 0:70a6082c1bf7 3 */
ShaneKirkbride 0:70a6082c1bf7 4 #include "mbed.h"
ShaneKirkbride 4:31bed73a0d08 5
ShaneKirkbride 0:70a6082c1bf7 6 #include <STMClient.h>
ShaneKirkbride 0:70a6082c1bf7 7 #include <STMClientRest.h>
ShaneKirkbride 0:70a6082c1bf7 8
ShaneKirkbride 0:70a6082c1bf7 9 /*-------- Check if platform compatible ----------*/
ShaneKirkbride 0:70a6082c1bf7 10 #if DEVICE_SERIAL_ASYNCH
ShaneKirkbride 4:31bed73a0d08 11 Serial debugSerial(SERIAL_TX, SERIAL_RX);
ShaneKirkbride 4:31bed73a0d08 12 Serial espSerial(PA_0, PA_1);
ShaneKirkbride 0:70a6082c1bf7 13 #else
ShaneKirkbride 0:70a6082c1bf7 14 #warning "Platform not compatible with Low Power APIs for Serial"
ShaneKirkbride 0:70a6082c1bf7 15 Serial debugSerial(SERIAL_TX, SERIAL_RX);
ShaneKirkbride 0:70a6082c1bf7 16 Serial espSerial(PA_0, PA_1);
ShaneKirkbride 0:70a6082c1bf7 17 #endif
ShaneKirkbride 0:70a6082c1bf7 18
ShaneKirkbride 4:31bed73a0d08 19 DigitalOut led1(LED1);
ShaneKirkbride 4:31bed73a0d08 20 DigitalOut led2(LED2);
ShaneKirkbride 8:6a3b7c5d9ba7 21 DigitalOut LCD_D7(D7);
ShaneKirkbride 0:70a6082c1bf7 22
ShaneKirkbride 0:70a6082c1bf7 23 // Initialize a connection to esp-link using the normal hardware serial port both for
ShaneKirkbride 0:70a6082c1bf7 24 // SLIP and for debug messages.
ShaneKirkbride 0:70a6082c1bf7 25 STMClient esp(&espSerial, &debugSerial);
ShaneKirkbride 0:70a6082c1bf7 26
ShaneKirkbride 0:70a6082c1bf7 27 // Initialize a REST client on the connection to esp-link
ShaneKirkbride 0:70a6082c1bf7 28 STMClientRest rest(&esp);
ShaneKirkbride 0:70a6082c1bf7 29 bool wifiConnected = false;
ShaneKirkbride 4:31bed73a0d08 30 Ticker flipper;
ShaneKirkbride 4:31bed73a0d08 31 Ticker post_data;
ShaneKirkbride 4:31bed73a0d08 32 bool posted = false;
ShaneKirkbride 8:6a3b7c5d9ba7 33 bool ESPisAsleep = false;
ShaneKirkbride 9:bd7f083d55ad 34
ShaneKirkbride 9:bd7f083d55ad 35 void toggleLEDSuccess(){
ShaneKirkbride 9:bd7f083d55ad 36 led2 = 1;
ShaneKirkbride 9:bd7f083d55ad 37 wait(0.25);
ShaneKirkbride 9:bd7f083d55ad 38 led2 = 0;
ShaneKirkbride 9:bd7f083d55ad 39 wait(0.25);
ShaneKirkbride 9:bd7f083d55ad 40 led2 = 1;
ShaneKirkbride 9:bd7f083d55ad 41 wait(0.25);
ShaneKirkbride 9:bd7f083d55ad 42 }
ShaneKirkbride 9:bd7f083d55ad 43
ShaneKirkbride 0:70a6082c1bf7 44 // Callback made from esp-link to notify of wifi status changes
ShaneKirkbride 0:70a6082c1bf7 45 // Here we print something out and set a global flag
ShaneKirkbride 0:70a6082c1bf7 46 void wifiCb(void *response) {
ShaneKirkbride 0:70a6082c1bf7 47 debugSerial.printf("waiting for wifi status...\n\r"); //debug
ShaneKirkbride 0:70a6082c1bf7 48 STMClientResponse *res = (STMClientResponse*)response;
ShaneKirkbride 0:70a6082c1bf7 49 if (res->argc() == 1) {
ShaneKirkbride 0:70a6082c1bf7 50 uint8_t status;
ShaneKirkbride 0:70a6082c1bf7 51 res->popArg(&status, 1);
ShaneKirkbride 0:70a6082c1bf7 52 debugSerial.printf("waiting for wifi status...\n\r");
ShaneKirkbride 0:70a6082c1bf7 53 if(status == STATION_GOT_IP) {
ShaneKirkbride 0:70a6082c1bf7 54 debugSerial.printf("WIFI CONNECTED");
ShaneKirkbride 0:70a6082c1bf7 55 wifiConnected = true;
ShaneKirkbride 0:70a6082c1bf7 56 } else {
ShaneKirkbride 0:70a6082c1bf7 57 debugSerial.printf("WIFI NOT READY: %i",status);
ShaneKirkbride 0:70a6082c1bf7 58 //Serial.printf(status);
ShaneKirkbride 0:70a6082c1bf7 59 wifiConnected = false;
ShaneKirkbride 0:70a6082c1bf7 60 }
ShaneKirkbride 0:70a6082c1bf7 61 }
ShaneKirkbride 0:70a6082c1bf7 62 }
ShaneKirkbride 0:70a6082c1bf7 63
ShaneKirkbride 8:6a3b7c5d9ba7 64 //resync after sleep mode
ShaneKirkbride 8:6a3b7c5d9ba7 65 void syncESP(){
ShaneKirkbride 8:6a3b7c5d9ba7 66
ShaneKirkbride 8:6a3b7c5d9ba7 67 // Sync-up with esp-link, this is required at the start of any sketch and initializes the
ShaneKirkbride 8:6a3b7c5d9ba7 68 // callbacks to the wifi status change callback. The callback gets called with the initial
ShaneKirkbride 8:6a3b7c5d9ba7 69 // status right after Sync() below completes.
ShaneKirkbride 8:6a3b7c5d9ba7 70 esp.wifiCb.attach(wifiCb); // wifi status change callback, optional (delete if not desired)
ShaneKirkbride 8:6a3b7c5d9ba7 71 bool ok;
ShaneKirkbride 8:6a3b7c5d9ba7 72 do {
ShaneKirkbride 8:6a3b7c5d9ba7 73 //debugSerial.printf("main syncing..\n\r");
ShaneKirkbride 8:6a3b7c5d9ba7 74 wait(0.5);
ShaneKirkbride 8:6a3b7c5d9ba7 75 ok = esp.Sync(); // sync up with esp-link, blocks for up to 2 seconds
ShaneKirkbride 8:6a3b7c5d9ba7 76 if (!ok){
ShaneKirkbride 8:6a3b7c5d9ba7 77 debugSerial.printf("STM-Client sync failed!\n\r");
ShaneKirkbride 8:6a3b7c5d9ba7 78 wait(0.5);
ShaneKirkbride 8:6a3b7c5d9ba7 79 }
ShaneKirkbride 8:6a3b7c5d9ba7 80 } while(!ok);
ShaneKirkbride 8:6a3b7c5d9ba7 81
ShaneKirkbride 8:6a3b7c5d9ba7 82 debugSerial.printf("STM-Client synced!\n\r");
ShaneKirkbride 8:6a3b7c5d9ba7 83
ShaneKirkbride 8:6a3b7c5d9ba7 84 // Get immediate wifi status info for demo purposes. This is not normally used because the
ShaneKirkbride 8:6a3b7c5d9ba7 85 // wifi status callback registered above gets called immediately.
ShaneKirkbride 8:6a3b7c5d9ba7 86 esp.GetWifiStatus();
ShaneKirkbride 8:6a3b7c5d9ba7 87
ShaneKirkbride 8:6a3b7c5d9ba7 88 STMClientPacket *packet;
ShaneKirkbride 8:6a3b7c5d9ba7 89 if ((packet=esp.WaitReturn()) != NULL)
ShaneKirkbride 8:6a3b7c5d9ba7 90 {
ShaneKirkbride 8:6a3b7c5d9ba7 91 //debugSerial.printf("Wifi status: %i\n\r", packet->value);
ShaneKirkbride 8:6a3b7c5d9ba7 92 //debugSerial.printf("waiting for wifi status...\n\r");
ShaneKirkbride 8:6a3b7c5d9ba7 93 if(packet->value >= 1) { ///ideally this would coincide with STATION_GOT_IP...
ShaneKirkbride 8:6a3b7c5d9ba7 94 debugSerial.printf("WIFI CONNECTED\n\r");
ShaneKirkbride 8:6a3b7c5d9ba7 95 wifiConnected = true;
ShaneKirkbride 8:6a3b7c5d9ba7 96 } else {
ShaneKirkbride 8:6a3b7c5d9ba7 97 debugSerial.printf("WIFI NOT READY: %i\n\r",packet->value);
ShaneKirkbride 8:6a3b7c5d9ba7 98 //Serial.printf(status);
ShaneKirkbride 8:6a3b7c5d9ba7 99 wifiConnected = false;
ShaneKirkbride 8:6a3b7c5d9ba7 100 }
ShaneKirkbride 8:6a3b7c5d9ba7 101 }
ShaneKirkbride 8:6a3b7c5d9ba7 102 }
ShaneKirkbride 8:6a3b7c5d9ba7 103 //Start/Restart REST...can pass some fancy arguments to this in the future.
ShaneKirkbride 8:6a3b7c5d9ba7 104 void beginREST(){
ShaneKirkbride 8:6a3b7c5d9ba7 105
ShaneKirkbride 8:6a3b7c5d9ba7 106 // Set up the REST client to talk to www.timeapi.org, this doesn't connect to that server,
ShaneKirkbride 8:6a3b7c5d9ba7 107 // it just sets-up stuff on the esp-link side
ShaneKirkbride 8:6a3b7c5d9ba7 108 //int err = rest.begin("www.timeapi.org"); //for basic example of get
ShaneKirkbride 8:6a3b7c5d9ba7 109 const char* host = "api.thingspeak.com";
ShaneKirkbride 8:6a3b7c5d9ba7 110 //const char* host = "posttestserver.com";
ShaneKirkbride 8:6a3b7c5d9ba7 111 //const char* host = "vivaplanetbusservicedev.servicebus.windows.net";
ShaneKirkbride 8:6a3b7c5d9ba7 112 uint16_t port = 80;
ShaneKirkbride 8:6a3b7c5d9ba7 113 bool security = true;
ShaneKirkbride 8:6a3b7c5d9ba7 114 int err = rest.begin(host,port,security);
ShaneKirkbride 8:6a3b7c5d9ba7 115 if (err != 0) {
ShaneKirkbride 8:6a3b7c5d9ba7 116 debugSerial.printf("REST begin failed: %i\n\r",err);
ShaneKirkbride 8:6a3b7c5d9ba7 117 while(1) ;
ShaneKirkbride 8:6a3b7c5d9ba7 118 }
ShaneKirkbride 8:6a3b7c5d9ba7 119 debugSerial.printf("STM-REST ready\n\r");
ShaneKirkbride 8:6a3b7c5d9ba7 120 }
ShaneKirkbride 8:6a3b7c5d9ba7 121
ShaneKirkbride 8:6a3b7c5d9ba7 122 //generate some random numbers
ShaneKirkbride 8:6a3b7c5d9ba7 123 int random_number(int min_num, int max_num){
ShaneKirkbride 8:6a3b7c5d9ba7 124 int result=0,low_num=0,hi_num=0;
ShaneKirkbride 8:6a3b7c5d9ba7 125 if(min_num<max_num)
ShaneKirkbride 8:6a3b7c5d9ba7 126 {
ShaneKirkbride 8:6a3b7c5d9ba7 127 low_num=min_num;
ShaneKirkbride 8:6a3b7c5d9ba7 128 hi_num=max_num+1; // this is done to include max_num in output.
ShaneKirkbride 8:6a3b7c5d9ba7 129 }else{
ShaneKirkbride 8:6a3b7c5d9ba7 130 low_num=max_num+1;// this is done to include max_num in output.
ShaneKirkbride 8:6a3b7c5d9ba7 131 hi_num=min_num;
ShaneKirkbride 8:6a3b7c5d9ba7 132 }
ShaneKirkbride 8:6a3b7c5d9ba7 133 srand(time(NULL));
ShaneKirkbride 8:6a3b7c5d9ba7 134 result = (rand()%(hi_num-low_num))+low_num;
ShaneKirkbride 8:6a3b7c5d9ba7 135 return result;
ShaneKirkbride 8:6a3b7c5d9ba7 136 }
ShaneKirkbride 8:6a3b7c5d9ba7 137
ShaneKirkbride 8:6a3b7c5d9ba7 138
ShaneKirkbride 4:31bed73a0d08 139 #define BUFLEN 100
ShaneKirkbride 4:31bed73a0d08 140 char response[BUFLEN];
ShaneKirkbride 0:70a6082c1bf7 141
ShaneKirkbride 1:99c58a942425 142 char *loop_get() {
ShaneKirkbride 0:70a6082c1bf7 143 //debugSerial.printf("begin main loop \n\r");
ShaneKirkbride 0:70a6082c1bf7 144 // process any callbacks coming from esp_link
ShaneKirkbride 0:70a6082c1bf7 145 esp.Process();
ShaneKirkbride 0:70a6082c1bf7 146 debugSerial.printf("Wifi Connected: %i \n\r",wifiConnected);
ShaneKirkbride 0:70a6082c1bf7 147 // if we're connected make an HTTP request
ShaneKirkbride 0:70a6082c1bf7 148 while(wifiConnected) {
ShaneKirkbride 0:70a6082c1bf7 149 // Request /utc/now from the previously set-up server
ShaneKirkbride 0:70a6082c1bf7 150 rest.get("/utc/now");
ShaneKirkbride 0:70a6082c1bf7 151
ShaneKirkbride 1:99c58a942425 152 //char response[BUFLEN];
ShaneKirkbride 0:70a6082c1bf7 153 memset(response, 0, BUFLEN);
ShaneKirkbride 0:70a6082c1bf7 154 uint16_t code = rest.waitResponse(response, BUFLEN);
ShaneKirkbride 0:70a6082c1bf7 155 if(code == HTTP_STATUS_OK){
ShaneKirkbride 0:70a6082c1bf7 156 debugSerial.printf("STM: GET successful: %s\n\r", response);
ShaneKirkbride 1:99c58a942425 157 wait(60);
ShaneKirkbride 1:99c58a942425 158 return response;
ShaneKirkbride 0:70a6082c1bf7 159 } else {
ShaneKirkbride 0:70a6082c1bf7 160 debugSerial.printf("STM: GET failed: %i\n\r",code);
ShaneKirkbride 1:99c58a942425 161 wait(60);
ShaneKirkbride 1:99c58a942425 162 return (char *)code;
ShaneKirkbride 1:99c58a942425 163 }
ShaneKirkbride 1:99c58a942425 164 }
ShaneKirkbride 1:99c58a942425 165 return "0";
ShaneKirkbride 1:99c58a942425 166 }
ShaneKirkbride 1:99c58a942425 167
ShaneKirkbride 5:9f3015b18b24 168
ShaneKirkbride 1:99c58a942425 169 int loop_post() {
ShaneKirkbride 4:31bed73a0d08 170 posted = false;
ShaneKirkbride 4:31bed73a0d08 171
ShaneKirkbride 1:99c58a942425 172 // process any callbacks coming from esp_link
ShaneKirkbride 1:99c58a942425 173 esp.Process();
ShaneKirkbride 4:31bed73a0d08 174
ShaneKirkbride 1:99c58a942425 175 debugSerial.printf("Wifi Connected: %i \n\r",wifiConnected);
ShaneKirkbride 1:99c58a942425 176 // if we're connected make an HTTP request
ShaneKirkbride 4:31bed73a0d08 177 if(wifiConnected) {
ShaneKirkbride 5:9f3015b18b24 178 //this is where the calls to the sensor drivers should go.
ShaneKirkbride 5:9f3015b18b24 179 //ideally they will be blocking so they don't return a value and allow the program to move on until each
ShaneKirkbride 5:9f3015b18b24 180 //function is complete
ShaneKirkbride 8:6a3b7c5d9ba7 181 debugSerial.printf("geting measurements...\n\r");
ShaneKirkbride 5:9f3015b18b24 182 int Tint = random_number(65, 99);
ShaneKirkbride 5:9f3015b18b24 183 int Lint = random_number(0, 99);
ShaneKirkbride 5:9f3015b18b24 184 int Hint = random_number(20, 25);
ShaneKirkbride 5:9f3015b18b24 185
ShaneKirkbride 5:9f3015b18b24 186 char T[2];
ShaneKirkbride 5:9f3015b18b24 187 sprintf(T, "%d", Tint);
ShaneKirkbride 5:9f3015b18b24 188 char L[2];
ShaneKirkbride 5:9f3015b18b24 189 sprintf(L, "%d", Lint);
ShaneKirkbride 5:9f3015b18b24 190 char H[2];
ShaneKirkbride 5:9f3015b18b24 191 sprintf(H, "%d", Hint);
ShaneKirkbride 5:9f3015b18b24 192 //debugSerial.printf("H: %s \n\r",H); //check to make sure the value is the same
ShaneKirkbride 4:31bed73a0d08 193
ShaneKirkbride 4:31bed73a0d08 194 /**make sure that the size of this array is consistent with the input string**/
ShaneKirkbride 3:8ed85d940c4c 195 const char* body = "";
ShaneKirkbride 4:31bed73a0d08 196 char output [62];
ShaneKirkbride 3:8ed85d940c4c 197 sprintf(output, "/update?api_key=3FF5CTKAJIU2IH0M&field1=%s&field2=%s&field3=%s", T,L,H);
ShaneKirkbride 3:8ed85d940c4c 198 //debugSerial.printf("output: %s \n\r", output);
ShaneKirkbride 4:31bed73a0d08 199 //debugSerial.printf("size: %i \n\r", strlen(output));
ShaneKirkbride 8:6a3b7c5d9ba7 200 debugSerial.printf("sending data...\n\r");
ShaneKirkbride 3:8ed85d940c4c 201 rest.post(output, body); //basic post test
ShaneKirkbride 3:8ed85d940c4c 202
ShaneKirkbride 1:99c58a942425 203 char response[BUFLEN];
ShaneKirkbride 1:99c58a942425 204 memset(response, 0, BUFLEN);
ShaneKirkbride 1:99c58a942425 205 uint16_t code = rest.waitResponse(response, BUFLEN);
ShaneKirkbride 1:99c58a942425 206 if(code == HTTP_STATUS_OK){
ShaneKirkbride 1:99c58a942425 207 debugSerial.printf("STM: POST successful: %s\n\r", response);
ShaneKirkbride 2:20ea1be14e4b 208 }else {
ShaneKirkbride 1:99c58a942425 209 debugSerial.printf("STM: POST failed: %i\n\r",code);
ShaneKirkbride 4:31bed73a0d08 210 return 1;
ShaneKirkbride 0:70a6082c1bf7 211 }
ShaneKirkbride 4:31bed73a0d08 212 }else{
ShaneKirkbride 4:31bed73a0d08 213 debugSerial.printf("STM: wifi NOT connected: %i\n\r",wifiConnected);
ShaneKirkbride 4:31bed73a0d08 214 return 1;
ShaneKirkbride 4:31bed73a0d08 215 }
ShaneKirkbride 4:31bed73a0d08 216 //debugSerial.printf("Exiting...\n\r");
ShaneKirkbride 4:31bed73a0d08 217 return 0;
ShaneKirkbride 0:70a6082c1bf7 218 }
ShaneKirkbride 0:70a6082c1bf7 219
ShaneKirkbride 4:31bed73a0d08 220 void flip() {
ShaneKirkbride 9:bd7f083d55ad 221 led2 = 1;
ShaneKirkbride 8:6a3b7c5d9ba7 222 if(ESPisAsleep){
ShaneKirkbride 8:6a3b7c5d9ba7 223 debugSerial.printf("syncing...\n\r");
ShaneKirkbride 8:6a3b7c5d9ba7 224 LCD_D7 = 0;
ShaneKirkbride 8:6a3b7c5d9ba7 225 wait(0.5);
ShaneKirkbride 8:6a3b7c5d9ba7 226 LCD_D7 = 1;
ShaneKirkbride 8:6a3b7c5d9ba7 227 wait(20);
ShaneKirkbride 8:6a3b7c5d9ba7 228 syncESP();
ShaneKirkbride 8:6a3b7c5d9ba7 229 ESPisAsleep = false;
ShaneKirkbride 8:6a3b7c5d9ba7 230 debugSerial.printf("restarting REST...\n\r");
ShaneKirkbride 8:6a3b7c5d9ba7 231 beginREST();
ShaneKirkbride 8:6a3b7c5d9ba7 232 }
ShaneKirkbride 8:6a3b7c5d9ba7 233 debugSerial.printf("posting...\n\r");
ShaneKirkbride 4:31bed73a0d08 234 int postVal = loop_post();
ShaneKirkbride 4:31bed73a0d08 235 if(!postVal)
ShaneKirkbride 4:31bed73a0d08 236 {
ShaneKirkbride 9:bd7f083d55ad 237 toggleLEDSuccess(); //flashes the LED to show the post was successful
ShaneKirkbride 4:31bed73a0d08 238 posted = true;
ShaneKirkbride 4:31bed73a0d08 239 }else{
ShaneKirkbride 4:31bed73a0d08 240 debugSerial.printf("error...%i\n\r",postVal);
ShaneKirkbride 8:6a3b7c5d9ba7 241 led2 = 0;
ShaneKirkbride 4:31bed73a0d08 242 posted = false;
ShaneKirkbride 4:31bed73a0d08 243 }
ShaneKirkbride 4:31bed73a0d08 244 }
ShaneKirkbride 1:99c58a942425 245
ShaneKirkbride 0:70a6082c1bf7 246 int main() {
ShaneKirkbride 4:31bed73a0d08 247 //setup
ShaneKirkbride 0:70a6082c1bf7 248 led1=0;
ShaneKirkbride 8:6a3b7c5d9ba7 249 LCD_D7 = 1;
ShaneKirkbride 0:70a6082c1bf7 250 debugSerial.baud(115200); // the baud rate here needs to match the esp-link config
ShaneKirkbride 0:70a6082c1bf7 251 espSerial.baud(115200);
ShaneKirkbride 8:6a3b7c5d9ba7 252 espSerial.printf("*********SunLeaf starting!**************\n\r");
ShaneKirkbride 8:6a3b7c5d9ba7 253 debugSerial.printf("*********SunLeaf starting!**************\n\r");
ShaneKirkbride 0:70a6082c1bf7 254
ShaneKirkbride 8:6a3b7c5d9ba7 255 syncESP(); //sync the ESP
ShaneKirkbride 8:6a3b7c5d9ba7 256 beginREST(); //resync the REST
ShaneKirkbride 8:6a3b7c5d9ba7 257
ShaneKirkbride 4:31bed73a0d08 258 flipper.attach(&flip, 60.0); // the address of the function to be attached (flip) and the interval (2 seconds)
ShaneKirkbride 4:31bed73a0d08 259
ShaneKirkbride 8:6a3b7c5d9ba7 260 while(true){
ShaneKirkbride 4:31bed73a0d08 261 if(posted)
ShaneKirkbride 4:31bed73a0d08 262 {
ShaneKirkbride 8:6a3b7c5d9ba7 263 debugSerial.printf("sleeping...\n\r");
ShaneKirkbride 4:31bed73a0d08 264 posted = false;
ShaneKirkbride 8:6a3b7c5d9ba7 265 esp.Sleep(); //put the esp to sleep
ShaneKirkbride 8:6a3b7c5d9ba7 266 ESPisAsleep = true;
ShaneKirkbride 8:6a3b7c5d9ba7 267 led2 = 0; //turn off all other power and sensors
ShaneKirkbride 8:6a3b7c5d9ba7 268
ShaneKirkbride 4:31bed73a0d08 269 sleep(); //then sleep
ShaneKirkbride 4:31bed73a0d08 270 }else{
ShaneKirkbride 8:6a3b7c5d9ba7 271 LCD_D7 = 1;
ShaneKirkbride 4:31bed73a0d08 272 led2 = !led2;
ShaneKirkbride 4:31bed73a0d08 273 wait(0.5); // give everything a second to wake up
ShaneKirkbride 4:31bed73a0d08 274 }
ShaneKirkbride 4:31bed73a0d08 275 }
ShaneKirkbride 4:31bed73a0d08 276
ShaneKirkbride 4:31bed73a0d08 277 }
ShaneKirkbride 4:31bed73a0d08 278