Skip to content

Event: When I receive a LoRa frame with: port, payload

Jaume Olivé Petrus edited this page Oct 30, 2017 · 2 revisions

This block is a LoRa block and an Event block that is activated when a LoRa frame is received. When the block is activated its script is executed. Before using this block you must configure LoRa.

Remember that due to the LoRa specs the reception windows are created after a transmission.

When this block is activated 2 Reporter blocks are available to obtain the port where the frame is received and the payload. To create this blocks, right-click over the shape and select one of the Created options in the contextual menu:

The payload is a hexadecimal string. A hexadecimal string is a representation of a serie of bytes in text format, in which every byte is converted to it's hexadecimal representation in text. For example, the integer value 127 are represented by the "7F" string.

To minimize the time on air, the block converts the hexadecimal string to a byte representation and transmit this bytes.

To avoid working with bytes from blocks, we provide the "Unpack hex string () to (), to (), ..." block which decodes a hexadecimal string coded using the same encoding mechanism used by the "Pack hex string with (), with(), ..." block.

Shape

Example

This examples waits for a LoRa frame. When the frame is received:

  • Payload is unpacked. In this case, we assume that the cloud app, send us the action to execute in the first packed value in the payload, so we unpack to the action variable.
  • If action equals to 1 a led is turn on.
  • If action equals to 2 a led is turn off.

Take note that we must to transmit a LoRa frame to enable the receive window. In this case we send an empty payload.

Run this example in The Whitecat IDE.

Clone this wiki locally