Added thread lock around timezone update function

This commit is contained in:
Rutger Huijgen 2020-07-17 15:48:57 +02:00
parent 5fb09f67d6
commit d72d11c200

View file

@ -49,12 +49,14 @@ void sntp_init(void);
// Sets time zone. // Sets time zone.
// NOTE: Settings do not take effect until SNTP time is updated. // NOTE: Settings do not take effect until SNTP time is updated.
void sntp_set_timezone(const struct timezone *tz) { void sntp_set_timezone(const struct timezone *tz) {
xSemaphoreTake(sntp_sem, portMAX_DELAY);
if (tz) { if (tz) {
stz = *tz; stz = *tz;
} else { } else {
stz.tz_minuteswest = 0; stz.tz_minuteswest = 0;
stz.tz_dsttime = 0; stz.tz_dsttime = 0;
} }
xSemaphoreGive(sntp_sem);
} }
// Initialization // Initialization