7: Receive message on devkit

In this chapter you learn how to send a downlink message to your devkit using the Rest API of IoT Creator SCS

👍

If you end up here in the last step of Getting Started tutorials you are almost a hero ⭐ 👏 👏! Only the last piece of the puzzle is missing: You need to receive your downlink message on your devkit.

Here you work with your devkit to receive the downlink message which has been posted to the API of IoT Creators SCS.

Preliminary Work on your Devkit

Before you can receive "Hello World" downlink message on your device make sure you did the following steps:

  • Register your device with the correct IMEI in the IoT Creators Portal.
    To insure that you used the correct IMEI you can query it with the AT command directly from the device. For BC66 device this command is: AT+CGSN=1
  • Connect the device via USB cable to your laptop.
  • Start your terminal program such as putty (Windows) or screen (Linux) with a baudrate of 115200.
  • Switch on the device by pressing the "switch on/off" button.
  • Deactivate auto-sleep with AT command: AT+QSCLK=0
  • Activate echo of console inputs with AT command: ATE1
  • Wait until the device display the IP address of the network attachment such as +IP: 10.0.0.239
  • Open the UDP server of IoT Creators**

As the result you should see on your console an output like:

F1: 0000 0000
V0: 0000 0000 [0001]
00: 0006 000C
01: 0000 0000
U0: 0000 0001 [0000]
T0: 0000 00B4
Leaving the BROM

AT+QSCLK=0
OK
ATE1
OK

+IP: 10.128.1.98

AT+QIOPEN=1,1,"UDP","172.27.131.100",15683,1001,0,0
OK

+QIOPEN: 1,0

🚧

You should only continue with the next steps if you seen the IP address of the network attachment displayed on the console.
If you don't see the IP address unfortunatelly you will have to start troubleshooting :(

Receive Downlink Message on your Devkit

As mentioned before IoT Creators queues the posted downlink messages for a device until the device sends an uplink message. After IoT Creators received the uplink message it delivers the queued downlink messages to the device.

Go to the console of the device and send "i am alive" heartbeat message to IoT Creators.

AT+QISENDEX=1,10,6920616d20616c697665
OK

SEND OK

+QIURC: "recv",1,24

AT+QIRD=1,24
+QIRD: 24,0
48656c6c6f20446576696365

OK

As you can see in the AT command console above it appears a +QIURC: "recv",1,24. This indicates that the device has received a message with 24 bytes on connection channel 1.

You can get the payload of the message with the AT command AT+QIRD=1,24. First the +QIRD: 24,0 is displayed to indicate that 24 are returned in the next line and that 0 data is available any more in the buffer.

If you decode the hex string 48656c6c6f20446576696365 you get your Hello Device again.

👍

CONGRATULATIONS!! You just sent your first downlink message from the cloud to your device.

The whole story works exactly the same if you have your device powered off, and sent the downlink message first. Then you just switch on your device, perform the alive-ping and receive the queued downlink message.

AT Commands to receive Hello Device

# Deactivate auto-sleep
AT+QSCLK=0
OK

# Activate echo of console input
ATE1
OK

+IP: 10.128.1.98

# Open UDP socket for communication with IoT Creators server
AT+QIOPEN=1,1,"UDP","172.27.131.100",15683,1001,0,0
OK

+QIOPEN: 1,0

# Send "i am alive" message 
AT+QISENDEX=1,10,6920616d20616c697665
OK

SEND OK

+QIURC: "recv",1,24

# Retrieve the received downlink message
AT+QIRD=1,24
+QIRD: 24,0
48656c6c6f20446576696365

OK