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

LoRa Downlink Messages

TaskDatahandler allows you to get Downlink Messages. It sends all received Messages via MessageQueue to the TaskCommandHandler where the Donwlink Messages are getting processed.

There are some predefined commands that can be received (Hex values).

You can adapt them or define new ones. Its highly recommended to use Hex values as they dont need much bandwith.

predefined hex values that act as commands that can be received. see main.h

#define LORA_COMMAND_ACTION_0				0x00
#define LORA_COMMAND_ACTION_1				0x01
#define LORA_COMMAND_ACTION_2				0x02

This are hex values that you need to send as downlinks. In this format you are able to define upto 256 different commands which should be enough for most use cases.

Received Commands (hex values) are processed according to their Value. You can define your logic for a received Commands inside TaskCommandHandler::processCommands(). An example shows you how to turn on/off a Led connected to D6 Pin on the mDot according to the received command.

processing received commands

void TaskCommandHandler::processCommands(){

	debugSerial->printf("\n");
	if (commandReceiveEvent.status == osEventMessage) {

		CommandMessage* commandMessage = (CommandMessage*) commandReceiveEvent.value.p;
//		 Do your own stuff according to the received command
//		 For example turn on LED if 0x00 was sent or turn it off if 0x01 was sent
		DigitalOut* pinD6 = new DigitalOut(PA_1);

		switch(commandMessage->getCommandHex()){

		case LORA_COMMAND_ACTION_0:
			pinD6->write(0);
			break;

		case LORA_COMMAND_ACTION_1:
			pinD6->write(1);
			break;

		}

		debugSerial->printf("Received Command: %s\n",commandMessage->getCommandString().c_str());

	}

}

You can extend that switch case for additional commands or costumize it for your own needs.

Important: At the moment the firmware delivers you functionality for a Class A device. This means you are only able to receive messages after you've sent some uplinks. The reception happens when a short receive window is opend after a sent uplink.


All wikipages