[][src]Function app::app_network::send_sensor_data

fn send_sensor_data(val: &SensorValue) -> MynewtResult<()>

Compose a CoAP JSON message with the Sensor Key (field name), Value and Geolocation (optional) in val and send to the CoAP server. The message will be enqueued for transmission by the CoAP / OIC Background Task so this function will return without waiting for the message to be transmitted. Return Ok() if successful, SYS_EAGAIN if network is not ready yet. For the CoAP server hosted at thethings.io, the CoAP payload shall be encoded in JSON like this:

{"values":[
  {"key":"t",      "value":1715, "geo": { "lat": ..., "long": ... }},
  {"key":"device", "value":"0102030405060708090a0b0c0d0e0f10"}
]}