Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed
Application Modes
Application Modes¶
There are some predefined Application Modes that define which measurements are taken. Each measurment is encapsulated in a Task. So therefore the Tasks that run define which measurments are taken.
| Application_Mode | TaskLight | TaskTemperature | TaskPressure | TaskHumidity | TaskAcceleration | TaskGyroscope | TaskMagnetometer | TaskProximity | TaskGPS |
|---|---|---|---|---|---|---|---|---|---|
| Application_Mode_1 | X | X | X | X | X | X | X | X | X |
| Application_Mode_2 | . | X | X | X | . | . | . | . | X |
| Application_Mode_3 | . | X | X | X | . | . | . | . | . |
| Application_Mode_4 | . | . | . | . | X | X | X | . | X |
| Application_Mode_5 | . | . | . | . | X | X | X | . | . |
| Application_Mode_6 | X | X | . | . | X | . | . | . | X |
| Application_Mode_7 | X | X | . | . | X | . | . | . | . |
| Application_Mode_8 | X | . | . | . | . | . | . | . | X |
| Application_Mode_9 | X | . | . | . | . | . | . | . | . |
| Application_Mode_10 | . | . | . | . | . | . | . | X | X |
| Application_Mode_11 | . | . | . | . | . | . | . | X | . |
Important: At the moment it is not possible to send all the data mDot aqcuired using APPLICATION_MODE_1 because it's to much data to send. So APPLICATION_MODE_1 is useless at the moment
Definition of the Application Modes¶
Which tasks are running (Sensors are measuring) is defined inside ApplicationConfig::build(APPLICATION_MODE)
definition of an Application Mode inside ApplicationConfig::build(APPLICATION_MODE)
void ApplicationConfig::build(APPLICATION_MODE desiredMode) {
switch (desiredMode) {
...
case APPLICATION_MODE_2:
setStateTaskLight(SLEEPING);
setStateTaskTemperature(RUNNING);
setStateTaskPressure(RUNNING);
setStateTaskHumidity(RUNNING);
setStateTaskAcceleration(SLEEPING);
setStateTaskGyroscope(SLEEPING);
setStateTaskTesla(SLEEPING);
setStateTaskProximity(SLEEPING);
setStateTaskGPS(RUNNING);
setStateTaskLoRaMeasurement(SLEEPING);
setMAX44009_MODE(MAX44009_MODE_1);
setBME280_MODE(BME280_MODE_1);
setMPU9250_MODE(MPU9250_MODE_1);
setSI1143_MODE(SI1143_MODE_1);
setuBlox_MODE(uBLOX_MODE_1);
setLORA_MODE(LORA_MODE_1);
break;
...
}
}
The setStateTaskXXX(TASK_STATE) methods are used to set a Task(Measurement) running or sleeping. However its possible to adapt the existing modes by changing the TASK_STATE.
Defining your own Application Modes¶
If you want to define your own APPLICATION_MODE first thing you have to do is to add a new APPLICATION_MODE enum (e.x. YOUR_OWN_NEW_APPLICATION_MODE) inside ApplicationConfig.h
definition of your own APPLICATION_MODE enum inside ApplicationConfig.h
/**
* Application Modes. Modes define different Usages of the LoRa sensor node
*/
enum APPLICATION_MODE {
APPLICATION_MODE_1, //!< APPLICATION_MODE_1
APPLICATION_MODE_2, //!< APPLICATION_MODE_2
APPLICATION_MODE_3, //!< APPLICATION_MODE_3
APPLICATION_MODE_4, //!< APPLICATION_MODE_4
APPLICATION_MODE_5, //!< APPLICATION_MODE_5
APPLICATION_MODE_6, //!< APPLICATION_MODE_6
APPLICATION_MODE_7, //!< APPLICATION_MODE_7
APPLICATION_MODE_8, //!< APPLICATION_MODE_8
APPLICATION_MODE_9, //!< APPLICATION_MODE_9
APPLICATION_MODE_10, //!< APPLICATION_MODE_10
APPLICATION_MODE_11, //!< APPLICATION_MODE_11
APPLICATION_MODE_99, //!< APPLICATION_MODE_99
YOUR_OWN_APPLICATION_MODE //!< Your newly defined Application Mode
};
After that you can add a new switch-case for your newly defined APPLICATION_MODE enum inside ApplicationConfig::build(APPLICATION_MODE).
definition of your own APPLICATION_MODE switch-case inside ApplicationConfig::build(APPLICATION_MODE)
void ApplicationConfig::build(APPLICATION_MODE desiredMode) {
switch (desiredMode) {
...
case APPLICATION_MODE_2:
setStateTaskLight(SLEEPING);
setStateTaskTemperature(RUNNING);
setStateTaskPressure(RUNNING);
setStateTaskHumidity(RUNNING);
setStateTaskAcceleration(SLEEPING);
setStateTaskGyroscope(SLEEPING);
setStateTaskTesla(SLEEPING);
setStateTaskProximity(SLEEPING);
setStateTaskGPS(RUNNING);
setStateTaskLoRaMeasurement(SLEEPING);
setMAX44009_MODE(MAX44009_MODE_1);
setBME280_MODE(BME280_MODE_1);
setMPU9250_MODE(MPU9250_MODE_1);
setSI1143_MODE(SI1143_MODE_1);
setuBlox_MODE(uBLOX_MODE_1);
setLORA_MODE(LORA_MODE_1);
break;
...
case YOUR_OWN_APPLICATION_MODE:
setStateTaskLight(SLEEPING);
setStateTaskTemperature(RUNNING);
setStateTaskPressure(SLEEPING);
setStateTaskHumidity(SLEEPING);
setStateTaskAcceleration(SLEEPING);
setStateTaskGyroscope(SLEEPING);
setStateTaskTesla(SLEEPING);
setStateTaskProximity(SLEEPING);
setStateTaskGPS(SLEEPING);
setStateTaskLoRaMeasurement(SLEEPING);
setMAX44009_MODE(MAX44009_MODE_1);
setBME280_MODE(BME280_MODE_1);
setMPU9250_MODE(MPU9250_MODE_1);
setSI1143_MODE(SI1143_MODE_1);
setuBlox_MODE(uBLOX_MODE_1);
setLORA_MODE(LORA_MODE_1);
break;
...
}
}
The Listing above shows the previous listing with a newly added switch-case for YOUR_OWN_APPLICATION_MODE. Inside this switch case you define the States of every Task by using their setStateTaskXXX(TASK_STATE) methods. For example the Listing above shows you that YOUR_OWN_APPLICATION_MODE only measures the Temperature.
If you add your own APPLICATION_MODES to this switch case make sure that they work with SENSOR_MODES. For example If you want to measure Temperature make sure that you choose a BME280_MODE where the BME280 is turned on and is able to measure the temperature.
After you've created a new APPLICATION_MODE enum and have added a new switch-case use YOUR_OWN_APPLICATION_MODE as a parameter to build the Application
building of a specific Sensorapplication using a selfdefined YOUR_OWN_APPLICATION_MODE
int main() {
Application application;
application.init(YOUR_OWN_APPLICATION_MODE);
while (true) {
sleep();
}
return 0;
}