Andrew Reed
/
NTP-Demo+Sensor
NTP demo for cypress Pioneer and Proto Dev kits also reads available analogue sensors
main.cpp@4:6f3c2a46cec2, 2020-07-02 (annotated)
- Committer:
- reedas
- Date:
- Thu Jul 02 11:06:15 2020 +0100
- Revision:
- 4:6f3c2a46cec2
- Parent:
- 3:9d9e29b54a1a
- Child:
- 5:6b62d5cb48e9
Selected std printf lib for pretty printing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
reedas | 0:01c8e1277c91 | 1 | #include "mbed.h" |
reedas | 0:01c8e1277c91 | 2 | #include "GUI.h" |
reedas | 0:01c8e1277c91 | 3 | #include "mbed_events.h" |
reedas | 0:01c8e1277c91 | 4 | #include "ntp-client/NTPClient.h" |
reedas | 0:01c8e1277c91 | 5 | |
reedas | 0:01c8e1277c91 | 6 | #define CY8CKIT_TFT // Light or Temperature? |
reedas | 0:01c8e1277c91 | 7 | Thread netTimeThreadHandle; |
reedas | 0:01c8e1277c91 | 8 | WiFiInterface *wifi; |
reedas | 0:01c8e1277c91 | 9 | #define MBED_CONF_APP_WIFI_SSID "brackenhillc" |
reedas | 0:01c8e1277c91 | 10 | #define MBED_CONF_APP_WIFI_PASSWORD "1broches" |
reedas | 0:01c8e1277c91 | 11 | |
reedas | 0:01c8e1277c91 | 12 | /* Reference resistor in series with the thermistor is of 10 KOhm */ |
reedas | 0:01c8e1277c91 | 13 | #define R_REFERENCE (float)(10000) |
reedas | 0:01c8e1277c91 | 14 | |
reedas | 0:01c8e1277c91 | 15 | /* Beta constant of this thermistor is 3380 Kelvin. See the thermistor |
reedas | 0:01c8e1277c91 | 16 | (NCP18XH103F03RB) data sheet for more details. */ |
reedas | 0:01c8e1277c91 | 17 | #define B_CONSTANT (float)(3380) |
reedas | 0:01c8e1277c91 | 18 | |
reedas | 0:01c8e1277c91 | 19 | /* Resistance of the thermistor is 10K at 25 degrees C (from data sheet) |
reedas | 0:01c8e1277c91 | 20 | Therefore R0 = 10000 Ohm, and T0 = 298.15 Kelvin, which gives |
reedas | 0:01c8e1277c91 | 21 | R_INFINITY = R0 e^(-B_CONSTANT / T0) = 0.1192855 */ |
reedas | 0:01c8e1277c91 | 22 | #define R_INFINITY (float)(0.1192855) |
reedas | 0:01c8e1277c91 | 23 | |
reedas | 0:01c8e1277c91 | 24 | /* Zero Kelvin in degree C */ |
reedas | 0:01c8e1277c91 | 25 | #define ABSOLUTE_ZERO (float)(-273.15) |
reedas | 0:01c8e1277c91 | 26 | |
reedas | 0:01c8e1277c91 | 27 | EventQueue *displayQueue; |
reedas | 0:01c8e1277c91 | 28 | Semaphore WiFiSemaphore; |
reedas | 0:01c8e1277c91 | 29 | #define SENSOR_BOARD |
reedas | 0:01c8e1277c91 | 30 | #ifdef CY8CKIT_TFT |
reedas | 0:01c8e1277c91 | 31 | DigitalOut PwrEnable(P6_2); |
reedas | 0:01c8e1277c91 | 32 | #ifdef SENSOR_BOARD |
reedas | 0:01c8e1277c91 | 33 | AnalogIn ALS(P10_7); //Sensor Board |
reedas | 0:01c8e1277c91 | 34 | #else |
reedas | 0:01c8e1277c91 | 35 | AnalogIn ALS(P10_0); //TFT Board |
reedas | 0:01c8e1277c91 | 36 | #endif |
reedas | 0:01c8e1277c91 | 37 | static float lightlevel; |
reedas | 0:01c8e1277c91 | 38 | #else |
reedas | 0:01c8e1277c91 | 39 | DigitalOut PwrEnable(P10_0); |
reedas | 0:01c8e1277c91 | 40 | DigitalOut ThermGnd(P10_3); |
reedas | 0:01c8e1277c91 | 41 | AnalogIn Thermistor(P10_1); |
reedas | 0:01c8e1277c91 | 42 | static float TempAverage; |
reedas | 0:01c8e1277c91 | 43 | #endif |
reedas | 0:01c8e1277c91 | 44 | /****************************************************************************************** |
reedas | 0:01c8e1277c91 | 45 | * |
reedas | 0:01c8e1277c91 | 46 | * Display Functions |
reedas | 0:01c8e1277c91 | 47 | * |
reedas | 0:01c8e1277c91 | 48 | ********************************************************************************************/ |
reedas | 0:01c8e1277c91 | 49 | #define DISP_LEFTMARGIN 10 |
reedas | 0:01c8e1277c91 | 50 | #define DISP_TOPMARGIN 4 |
reedas | 0:01c8e1277c91 | 51 | #define DISP_LINESPACE 2 |
reedas | 0:01c8e1277c91 | 52 | // updateDisplayWiFiStatus |
reedas | 0:01c8e1277c91 | 53 | // Used to display the wifi status |
reedas | 0:01c8e1277c91 | 54 | void updateDisplayWiFiStatus(char *status) |
reedas | 0:01c8e1277c91 | 55 | { |
reedas | 0:01c8e1277c91 | 56 | GUI_SetFont(GUI_FONT_16_1); |
reedas | 0:01c8e1277c91 | 57 | GUI_DispStringAt(status,DISP_LEFTMARGIN, DISP_TOPMARGIN); |
reedas | 3:9d9e29b54a1a | 58 | printf("%s\r\n", status); |
reedas | 0:01c8e1277c91 | 59 | free(status); |
reedas | 0:01c8e1277c91 | 60 | } |
reedas | 0:01c8e1277c91 | 61 | // updateDisplayWiFiConnectAttempts |
reedas | 0:01c8e1277c91 | 62 | // This function displays the number of attempted connections |
reedas | 0:01c8e1277c91 | 63 | void updateDisplayWiFiConnectAttempts(int count) |
reedas | 0:01c8e1277c91 | 64 | { |
reedas | 0:01c8e1277c91 | 65 | char buffer[128]; |
reedas | 0:01c8e1277c91 | 66 | snprintf(buffer,sizeof(buffer),"WiFi Connect Attempts = %d",count); |
reedas | 0:01c8e1277c91 | 67 | GUI_SetFont(GUI_FONT_16_1); |
reedas | 0:01c8e1277c91 | 68 | GUI_DispStringAt(buffer,DISP_LEFTMARGIN, DISP_TOPMARGIN + (GUI_GetFontSizeY()+DISP_LINESPACE) ); |
reedas | 0:01c8e1277c91 | 69 | } |
reedas | 0:01c8e1277c91 | 70 | // updateDisplayNTPFailed |
reedas | 0:01c8e1277c91 | 71 | // updates the display with the number of time the NTP Server has been called |
reedas | 0:01c8e1277c91 | 72 | // and got a failed response |
reedas | 0:01c8e1277c91 | 73 | void updateDisplayNTPFailed(void) |
reedas | 0:01c8e1277c91 | 74 | { |
reedas | 0:01c8e1277c91 | 75 | static int count=0; |
reedas | 0:01c8e1277c91 | 76 | char buffer[128]; |
reedas | 0:01c8e1277c91 | 77 | count = count + 1; |
reedas | 0:01c8e1277c91 | 78 | snprintf(buffer,sizeof(buffer),"NTP Update Failure = %d\n",count); |
reedas | 0:01c8e1277c91 | 79 | GUI_SetFont(GUI_FONT_16_1); |
reedas | 0:01c8e1277c91 | 80 | GUI_DispStringHCenterAt(buffer,LCD_GetXSize()/2,LCD_GetYSize() - 2*GUI_GetFontSizeY()); // near the bottom |
reedas | 0:01c8e1277c91 | 81 | } |
reedas | 0:01c8e1277c91 | 82 | // updateDisplayNTPCount |
reedas | 0:01c8e1277c91 | 83 | // updates the display with the number of time the NTP Server has been called |
reedas | 0:01c8e1277c91 | 84 | void updateDisplayNTPCount(void) |
reedas | 0:01c8e1277c91 | 85 | { |
reedas | 0:01c8e1277c91 | 86 | static int count=0; |
reedas | 0:01c8e1277c91 | 87 | char buffer[128]; |
reedas | 0:01c8e1277c91 | 88 | count = count + 1; |
reedas | 0:01c8e1277c91 | 89 | snprintf(buffer,sizeof(buffer),"NTP Updates = %d\n",count); |
reedas | 0:01c8e1277c91 | 90 | GUI_SetFont(GUI_FONT_16_1); |
reedas | 0:01c8e1277c91 | 91 | GUI_DispStringHCenterAt(buffer,LCD_GetXSize()/2,LCD_GetYSize() - GUI_GetFontSizeY()); // near the bottom |
reedas | 0:01c8e1277c91 | 92 | } |
reedas | 0:01c8e1277c91 | 93 | // updateDisplayTime |
reedas | 0:01c8e1277c91 | 94 | // This function updates the time on the screen |
reedas | 0:01c8e1277c91 | 95 | void updateDisplayTime() |
reedas | 0:01c8e1277c91 | 96 | { |
reedas | 0:01c8e1277c91 | 97 | time_t rawtime; |
reedas | 0:01c8e1277c91 | 98 | struct tm * timeinfo; |
reedas | 0:01c8e1277c91 | 99 | char buffer [128]; |
reedas | 0:01c8e1277c91 | 100 | time (&rawtime); |
reedas | 0:01c8e1277c91 | 101 | //rawtime = rawtime - (4*60*60); // UTC - 4hours ... serious hack which only works in summer |
reedas | 0:01c8e1277c91 | 102 | rawtime = rawtime + 3600; // GMT + 1 for BST |
reedas | 0:01c8e1277c91 | 103 | timeinfo = localtime (&rawtime); |
reedas | 4:6f3c2a46cec2 | 104 | strftime (buffer,sizeof(buffer)," %T ", timeinfo); |
reedas | 0:01c8e1277c91 | 105 | GUI_SetFont(GUI_FONT_32B_1); |
reedas | 0:01c8e1277c91 | 106 | GUI_DispStringHCenterAt(buffer,LCD_GetXSize()/2,LCD_GetYSize()/2 - GUI_GetFontSizeY()/2 - 20); |
reedas | 0:01c8e1277c91 | 107 | printf("%s\r\n", buffer); |
reedas | 0:01c8e1277c91 | 108 | strftime (buffer,sizeof(buffer)," %A ",timeinfo); |
reedas | 0:01c8e1277c91 | 109 | GUI_SetFont(GUI_FONT_32B_1); |
reedas | 0:01c8e1277c91 | 110 | GUI_DispStringHCenterAt(buffer,LCD_GetXSize()/2,LCD_GetYSize()/2 - GUI_GetFontSizeY()/2 + 20); |
reedas | 0:01c8e1277c91 | 111 | printf("%s\r\n", buffer); |
reedas | 4:6f3c2a46cec2 | 112 | strftime (buffer,sizeof(buffer)," %d/%m/%y ",timeinfo); |
reedas | 0:01c8e1277c91 | 113 | GUI_SetFont(GUI_FONT_32B_1); |
reedas | 0:01c8e1277c91 | 114 | GUI_DispStringHCenterAt(buffer,LCD_GetXSize()/2,LCD_GetYSize()/2 - GUI_GetFontSizeY()/2 + 60); |
reedas | 0:01c8e1277c91 | 115 | printf("%s\r\n", buffer); |
reedas | 0:01c8e1277c91 | 116 | #ifdef CY8CKIT_TFT |
reedas | 4:6f3c2a46cec2 | 117 | sprintf(buffer, " Light = %d%c \r\n",int(lightlevel*100), '%'); |
reedas | 0:01c8e1277c91 | 118 | GUI_SetFont(GUI_FONT_32B_1); |
reedas | 0:01c8e1277c91 | 119 | GUI_DispStringHCenterAt(buffer,LCD_GetXSize()/2,LCD_GetYSize()/2 - GUI_GetFontSizeY()/2 - 60); |
reedas | 0:01c8e1277c91 | 120 | printf("%s",buffer); |
reedas | 0:01c8e1277c91 | 121 | #else |
reedas | 0:01c8e1277c91 | 122 | float temperature = (B_CONSTANT / (logf((R_REFERENCE / ( 1 / TempAverage - 1 )) / |
reedas | 0:01c8e1277c91 | 123 | R_INFINITY))) + ABSOLUTE_ZERO; |
reedas | 0:01c8e1277c91 | 124 | |
reedas | 0:01c8e1277c91 | 125 | sprintf(buffer, "Temperature = %d.%1d C\r\n",int(temperature), |
reedas | 0:01c8e1277c91 | 126 | int((temperature-(int)temperature)*10)); |
reedas | 0:01c8e1277c91 | 127 | GUI_SetFont(GUI_FONT_32B_1); |
reedas | 0:01c8e1277c91 | 128 | GUI_DispStringHCenterAt(buffer,LCD_GetXSize()/2,LCD_GetYSize()/2 - GUI_GetFontSizeY()/2 - 60); |
reedas | 0:01c8e1277c91 | 129 | printf("%s",buffer); |
reedas | 0:01c8e1277c91 | 130 | #endif |
reedas | 0:01c8e1277c91 | 131 | printf("%c[4A", 0x1b ); |
reedas | 0:01c8e1277c91 | 132 | } |
reedas | 0:01c8e1277c91 | 133 | void readSensors(){ |
reedas | 0:01c8e1277c91 | 134 | PwrEnable = 1; |
reedas | 0:01c8e1277c91 | 135 | #ifdef CY8CKIT_TFT |
reedas | 0:01c8e1277c91 | 136 | static int lcount = 0; |
reedas | 0:01c8e1277c91 | 137 | static float Light[8]; |
reedas | 0:01c8e1277c91 | 138 | Light[lcount] = ALS; |
reedas | 0:01c8e1277c91 | 139 | lcount = (lcount + 1) & 0x7; |
reedas | 0:01c8e1277c91 | 140 | if (lcount == 0) { |
reedas | 0:01c8e1277c91 | 141 | lightlevel = 0; |
reedas | 0:01c8e1277c91 | 142 | for (int i = 0; i < 8; i++) lightlevel += Light[i]; |
reedas | 0:01c8e1277c91 | 143 | lightlevel = lightlevel/8; |
reedas | 0:01c8e1277c91 | 144 | #ifdef SENSOR_BOARD |
reedas | 0:01c8e1277c91 | 145 | lightlevel = 1 - lightlevel; |
reedas | 0:01c8e1277c91 | 146 | #endif |
reedas | 0:01c8e1277c91 | 147 | #else |
reedas | 0:01c8e1277c91 | 148 | ThermGnd = 0; |
reedas | 0:01c8e1277c91 | 149 | static int lcount = 0; |
reedas | 0:01c8e1277c91 | 150 | static float Therm[8]; |
reedas | 0:01c8e1277c91 | 151 | float thermValue; |
reedas | 0:01c8e1277c91 | 152 | float rThermistor; |
reedas | 0:01c8e1277c91 | 153 | thermValue = Thermistor; |
reedas | 0:01c8e1277c91 | 154 | Therm[lcount] = thermValue; |
reedas | 0:01c8e1277c91 | 155 | lcount = (lcount + 1) & 0x7; |
reedas | 0:01c8e1277c91 | 156 | if (lcount == 0) { |
reedas | 0:01c8e1277c91 | 157 | TempAverage = 0; |
reedas | 0:01c8e1277c91 | 158 | for (int i = 0; i < 8; i++) TempAverage += Therm[i]; |
reedas | 0:01c8e1277c91 | 159 | TempAverage = TempAverage/8; |
reedas | 0:01c8e1277c91 | 160 | /* rThermistor = (R_REFERENCE/(1 / TempAverage -1 )); |
reedas | 0:01c8e1277c91 | 161 | * temperature = |
reedas | 0:01c8e1277c91 | 162 | * (B_CONSTANT / (logf(rThermistor / R_INFINITY))) + ABSOLUTE_ZERO; |
reedas | 0:01c8e1277c91 | 163 | * |
reedas | 0:01c8e1277c91 | 164 | * temperature = (B_CONSTANT / (logf((R_REFERENCE / ( 1 / TempAverage - 1 )) / |
reedas | 0:01c8e1277c91 | 165 | * R_INFINITY))) + ABSOLUTE_ZERO; |
reedas | 0:01c8e1277c91 | 166 | * |
reedas | 0:01c8e1277c91 | 167 | * printf("Temp is %d\r\n",(int)(temperature*10)); |
reedas | 0:01c8e1277c91 | 168 | * for (int i = 0; i < 8; i++) |
reedas | 0:01c8e1277c91 | 169 | * printf("%d ", (int)(Therm[i]*1000)); |
reedas | 0:01c8e1277c91 | 170 | * printf("therm=%d\r\n", (int)(thermValue*1000)); |
reedas | 0:01c8e1277c91 | 171 | */ |
reedas | 0:01c8e1277c91 | 172 | |
reedas | 0:01c8e1277c91 | 173 | #endif |
reedas | 0:01c8e1277c91 | 174 | PwrEnable = 0; |
reedas | 0:01c8e1277c91 | 175 | } |
reedas | 0:01c8e1277c91 | 176 | } |
reedas | 0:01c8e1277c91 | 177 | /****************************************************************************************** |
reedas | 0:01c8e1277c91 | 178 | * NTPTimeThread |
reedas | 0:01c8e1277c91 | 179 | * This thread calls the NTP Timeserver to get the UTC time |
reedas | 0:01c8e1277c91 | 180 | * It then updates the time in the RTC |
reedas | 0:01c8e1277c91 | 181 | * And it updates the display by adding an event to the display queue |
reedas | 0:01c8e1277c91 | 182 | ********************************************************************************************/ |
reedas | 0:01c8e1277c91 | 183 | void NTPTimeThread() |
reedas | 0:01c8e1277c91 | 184 | { |
reedas | 0:01c8e1277c91 | 185 | static time_t old_timestamp = 0, timestamp; |
reedas | 0:01c8e1277c91 | 186 | NTPClient ntpclient(wifi); |
reedas | 0:01c8e1277c91 | 187 | while(1) { |
reedas | 0:01c8e1277c91 | 188 | if(wifi->get_connection_status() == NSAPI_STATUS_GLOBAL_UP) { |
reedas | 0:01c8e1277c91 | 189 | timestamp = ntpclient.get_timestamp(); |
reedas | 3:9d9e29b54a1a | 190 | if (timestamp < 1593627000) { |
reedas | 0:01c8e1277c91 | 191 | displayQueue->call(updateDisplayNTPFailed); |
reedas | 3:9d9e29b54a1a | 192 | printf("faulty timestamp %d\r\n", timestamp); |
reedas | 0:01c8e1277c91 | 193 | } else { |
reedas | 0:01c8e1277c91 | 194 | set_time(timestamp); |
reedas | 2:a92d7ea0f3e3 | 195 | old_timestamp = timestamp; |
reedas | 0:01c8e1277c91 | 196 | displayQueue->call(updateDisplayNTPCount); |
reedas | 0:01c8e1277c91 | 197 | } |
reedas | 0:01c8e1277c91 | 198 | } |
reedas | 0:01c8e1277c91 | 199 | ThisThread::sleep_for(300s); // Goto the NTP server every 5 minutes |
reedas | 0:01c8e1277c91 | 200 | } |
reedas | 0:01c8e1277c91 | 201 | } |
reedas | 0:01c8e1277c91 | 202 | /****************************************************************************************** |
reedas | 0:01c8e1277c91 | 203 | * |
reedas | 0:01c8e1277c91 | 204 | * Main & WiFi Thread |
reedas | 0:01c8e1277c91 | 205 | * |
reedas | 0:01c8e1277c91 | 206 | ********************************************************************************************/ |
reedas | 0:01c8e1277c91 | 207 | // wifiStatusCallback |
reedas | 0:01c8e1277c91 | 208 | // Changes the display when the wifi status is changed |
reedas | 0:01c8e1277c91 | 209 | void wifiStatusCallback(nsapi_event_t status, intptr_t param) |
reedas | 0:01c8e1277c91 | 210 | { |
reedas | 0:01c8e1277c91 | 211 | const int buffSize=40; |
reedas | 0:01c8e1277c91 | 212 | char *statusText; |
reedas | 0:01c8e1277c91 | 213 | SocketAddress a; |
reedas | 0:01c8e1277c91 | 214 | statusText = (char *)malloc(buffSize); |
reedas | 0:01c8e1277c91 | 215 | switch(param) { |
reedas | 0:01c8e1277c91 | 216 | case NSAPI_STATUS_LOCAL_UP: |
reedas | 0:01c8e1277c91 | 217 | wifi->get_ip_address(&a); |
reedas | 0:01c8e1277c91 | 218 | snprintf(statusText,buffSize,"WiFi IP = %s",a.get_ip_address()); |
reedas | 0:01c8e1277c91 | 219 | break; |
reedas | 0:01c8e1277c91 | 220 | case NSAPI_STATUS_GLOBAL_UP: |
reedas | 0:01c8e1277c91 | 221 | wifi->get_ip_address(&a); |
reedas | 0:01c8e1277c91 | 222 | snprintf(statusText,buffSize,"WiFi IP = %s",a.get_ip_address()); |
reedas | 0:01c8e1277c91 | 223 | break; |
reedas | 0:01c8e1277c91 | 224 | case NSAPI_STATUS_DISCONNECTED: |
reedas | 0:01c8e1277c91 | 225 | WiFiSemaphore.release(); |
reedas | 0:01c8e1277c91 | 226 | snprintf(statusText,buffSize,"WiFi Disconnected"); |
reedas | 0:01c8e1277c91 | 227 | break; |
reedas | 0:01c8e1277c91 | 228 | case NSAPI_STATUS_CONNECTING: |
reedas | 0:01c8e1277c91 | 229 | snprintf(statusText,buffSize,"WiFi Connecting"); |
reedas | 0:01c8e1277c91 | 230 | break; |
reedas | 0:01c8e1277c91 | 231 | default: |
reedas | 0:01c8e1277c91 | 232 | snprintf(statusText,buffSize,"Not Supported"); |
reedas | 0:01c8e1277c91 | 233 | break; |
reedas | 0:01c8e1277c91 | 234 | } |
reedas | 0:01c8e1277c91 | 235 | displayQueue->call(updateDisplayWiFiStatus,statusText); |
reedas | 0:01c8e1277c91 | 236 | } |
reedas | 0:01c8e1277c91 | 237 | int main() |
reedas | 0:01c8e1277c91 | 238 | { |
reedas | 0:01c8e1277c91 | 239 | int wifiConnectionAttempts; |
reedas | 0:01c8e1277c91 | 240 | int ret; |
reedas | 0:01c8e1277c91 | 241 | GUI_Init(); |
reedas | 0:01c8e1277c91 | 242 | printf("%c[2J", 0x1b); // Clear Screen |
reedas | 0:01c8e1277c91 | 243 | printf("%c[?25l", 0x1b); // Cursor Off |
reedas | 0:01c8e1277c91 | 244 | displayQueue = mbed_event_queue(); |
reedas | 0:01c8e1277c91 | 245 | displayQueue->call_every(1s, &updateDisplayTime); |
reedas | 0:01c8e1277c91 | 246 | displayQueue->call_every(100ms, &readSensors); |
reedas | 0:01c8e1277c91 | 247 | wifi = WiFiInterface::get_default_instance(); |
reedas | 0:01c8e1277c91 | 248 | wifi->attach(&wifiStatusCallback); |
reedas | 0:01c8e1277c91 | 249 | |
reedas | 0:01c8e1277c91 | 250 | while(1) { |
reedas | 0:01c8e1277c91 | 251 | wifiConnectionAttempts = 1; |
reedas | 0:01c8e1277c91 | 252 | do { |
reedas | 0:01c8e1277c91 | 253 | ret = wifi->connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2); |
reedas | 0:01c8e1277c91 | 254 | displayQueue->call(updateDisplayWiFiConnectAttempts,wifiConnectionAttempts); |
reedas | 0:01c8e1277c91 | 255 | if (ret != 0) { |
reedas | 0:01c8e1277c91 | 256 | wifiConnectionAttempts += 1; |
reedas | 0:01c8e1277c91 | 257 | ThisThread::sleep_for(2s); // If for some reason it doesnt work wait 2s and try again |
reedas | 0:01c8e1277c91 | 258 | } |
reedas | 0:01c8e1277c91 | 259 | } while(ret !=0); |
reedas | 0:01c8e1277c91 | 260 | // If the NTPThread is not running... then start it up |
reedas | 0:01c8e1277c91 | 261 | if(netTimeThreadHandle.get_state() == Thread::Deleted) |
reedas | 0:01c8e1277c91 | 262 | netTimeThreadHandle.start(NTPTimeThread); |
reedas | 0:01c8e1277c91 | 263 | WiFiSemaphore.acquire(); |
reedas | 0:01c8e1277c91 | 264 | } |
reedas | 0:01c8e1277c91 | 265 | } |