A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

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_ModeTaskLightTaskTemperatureTaskPressureTaskHumidityTaskAccelerationTaskGyroscopeTaskMagnetometerTaskProximityTaskGPS
Application_Mode_1XXXXXXXXX
Application_Mode_2.XXX....X
Application_Mode_3.XXX.....
Application_Mode_4....XXX.X
Application_Mode_5....XXX..
Application_Mode_6XX..X...X
Application_Mode_7XX..X....
Application_Mode_8X.......X
Application_Mode_9X........
Application_Mode_10.......XX
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;
}

All wikipages