LoRa P2P communication is an alternative to LoRaWAN. LoRa P2P’s advantages are in the simple setup for small private networks without the need for an (expensive) LoRaWAN gateway and it doesn’t require a LoRaWAN server (local or in the cloud). But LoRa P2P lacks features like packet encryption, node addresses and confirmed transmissions. However, with LoRa P2P a low cost gateway can be build with WisBlock modules to forward node data to a local server or to the cloud.
This PoC shows how to setup a simple LoRa P2P gateway, receive data from sensor nodes and forward them to an MQTT broker or an HTTP Post service.
You can add a node ID to the message. If you use my examples as a base, there is a function
/**
* @brief Add device ID to payload
*
* @param channel LPP channel
* @param dev_id pointer to 4 byte long array with the device ID
* @return uint8_t bytes added to the data packet
*/
uint8_t WisCayenne::addDevID(uint8_t channel, uint8_t *dev_id)
That can be used to add a 4 byte node ID to the payload.
You have to prepare your decoder to get this node ID out of the payload.
The node ID will be 6 bytes
<1 byte sensor number == channel><1 byte sensor type == 255><4 bytes node ID>
// Add unique identifier in front of the P2P packet, here we use the DevEUI
g_solution_data.addDevID(0, &g_lorawan_settings.node_device_eui[4]);
// Send packet over LoRa
if (send_p2p_packet(g_solution_data.getBuffer(), g_solution_data.getSize()))
{
MYLOG("APP", "Packet enqueued");
}
else
{
AT_PRINTF("+EVT:SIZE_ERROR\n");
MYLOG("APP", "Packet too big");
}
Yes, you could add a “custom” AT command to setup a 4 byte node ID.
Unfortunately with the open source version, it is not as easy to add an AT command as with our RUI3.
But it is doable.
(1) you need to define the functions
(2) you have to write the functions to parse the AT command
(3) (optional) you have to write the function to query the value
(4) you have to write the functions to save the value in Flash and read them back on boot-up
(5) you have to add the new AT command to the existing AT commands
(6) you have to change g_solution_data.addDevID(0, &g_lorawan_settings.node_device_eui[4]); to use that value as node ID
I am using many different custom AT commands in my "WisBlock-Sensor-For-LoRaWAN ". You can check them in user_at_cmd.cpp