Hi. I am currently evaluating nrf9160 on a Thingy 91 board and have the environment for the asset_tracker application up and running.
I want to be able to handle JSON messages sent _from_ the cloud (using the NRF cloud portal to start with) but I can't find any examples of this. Do you know where I can find an example or guide for this? Thanks in advance!
If you are using the asset_tracker application, you receive downlink data in the CLOUD_EVT_DATA_RECEIVED event in the cloud_event_handler function in main.c.
Note that there is a bug in version 1.1 that must be fixed for you to be able to receive the data. You can find the fix in this pull request: https://github.com/NordicPlayground/fw-nrfconnect-nrf/pull/1355/files#diff-71f7a1e3a52c8b609c0dc7cafa716b14L573
I merged in the bug fix and it seems to be working. Thank you!
One more thing: are there any examples of JSON messages that work with the asset_tracker example straight away? For instance, if I want to trigger the buzzer:
CMD_NEW_CHAN(buzzer, CLOUD_CHANNEL_BUZZER, CMD_ARRAY( CMD_NEW_TYPE(enable, CLOUD_CMD_ENABLE), CMD_NEW_TYPE(play_melody, CLOUD_CMD_PLAY_MELODY), CMD_NEW_TYPE(play_note, CLOUD_CMD_PLAY_NOTE)) ))
We do not have any documentation on what commands are supported at the moment.
When I asked the developers two months ago, related to another ticket, the answer I got was that they recommended you to implement your own command parsing and handling.
This was because the little implementation in the repo at the time was quite limited in what scenarios it could handle.
There has been some more work done since then, primarily these PRs:
You might be able to learn from them what commands are supported, or you can create your own.