I am looking for some suggestions to build on top of the existing application as an enhancement.
The application leverages Observer design pattern and acts more like a temperature monitoring through subscriptions; as long as user is subscribed to temperature readings, every X seconds or so a temperature value will be read off the sensor, and broadcast to it the UART port + the BLE service.
The high level design includes:
- TemperatureSensor: contains a
Run()
task that reads and publishes a sensor value continuously
void TemperatureSensor::Run()
{
while(true)
{
Read(); // send a read I2C byte
// block until signalled from within ISR that RX transmission is complete
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
Notify(); // notify its subscribers that the value is ready to be read
vTaskDelay(pdMS_TO_TICKS(DELAY_PER_READ));
}
}
SystemTask
: contains aRun
task that’s blocked on a queue. Currently, it’s only unblocked by UART RX and BLE RX messages i.e, user inputs
void SystemTask::Run()
{
InitializeModules();
while(true)
{
SystemTask::Message msg;
if (xQueueReceive(taskQueue, &msg, portMAX_DELAY) == pdPASS)
{
/* check whether msg contains anything related to subscribe or unsubscribe;
if unsubscribe: block the Temperature sensor task indefinitely until a request comes to subscribe again...
*/
}
}
That’s mostly the gist. The rest is low-level details. I’d like to leverage more of FreeRTOS primitives though 1) for learning 2) for making the application perhaps more complex.
One thing I thought of was to add a functionality to be able to view the sensor data in real-time on a webpage but 1) I may require an internet connection on my MCU which I’m not sure about 2) doesn’t involve much embedded programming
Any ideas would be greatly appreciated.