Skip to content
Snippets Groups Projects
Verified Commit b7494847 authored by Zoe Michaela Dietmar Pfister's avatar Zoe Michaela Dietmar Pfister :gay_pride_flag:
Browse files

WIP: mutex

parent 86ae69d9
No related branches found
No related tags found
4 merge requests!39Merge Develop into Main,!19development into master,!17Inital Host, initial Client,!14Merge gsm host into development
......@@ -18,7 +18,7 @@ const char *ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 0;
const int daylightOffset_sec = 0;
SemaphoreHandle_t xBinarySemaphore;
SemaphoreHandle_t xMutex;
TaskHandle_t Task1;
......@@ -89,9 +89,9 @@ void on_data_recv(const uint8_t *mac, const uint8_t *incomingData, int len)
+ measurementType + "=" + value + " " + timestamp;
Serial.println(lineData);
xSemaphoreTake(xBinarySemaphore, portMAX_DELAY);
xSemaphoreTake(xMutex, portMAX_DELAY);
queue.push(lineData);
xSemaphoreGive(xBinarySemaphore);
xSemaphoreGive(xMutex);
}
[[noreturn]] void Task1code(void *parameter)
......@@ -197,7 +197,7 @@ void setup()
Serial.println(str);
}
xBinarySemaphore = xSemaphoreCreateBinary();
xMutex = xSemaphoreCreateMutex();
Serial.println("\nWait...");
......@@ -364,10 +364,10 @@ void loop()
return;
}
xSemaphoreTake(xBinarySemaphore, portMAX_DELAY);
xSemaphoreTake(xMutex, portMAX_DELAY);
String lineData = queue.front();
queue.pop();
xSemaphoreGive(xBinarySemaphore);
xSemaphoreGive(xMutex);
//"sensorName":"DRS26","timestamp":1666872216,"protocol":"I2C","value":0,"channel":0,"measurementType":"CIRCUMFERENCE_INCREMENT"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment