Hello Everyone. David Conroy here from the National Association of REALTORS. We have already built a product that connects to a variety of sensors, and aggregates it in a time series database.

I would love to add the XDK as one of our supported devices. I have one running the workbench here, but I am unable to find an easy way to just poll the device for its current readings on all sensors in json or xml. I've seen the sample code to print to console, but I would like to just access it over the network since it has wifi.

Am I missing something glaring? Does it have a web server or Is it up to us to build that? 

Please let me know,
Thanks,
Dave Conroy
dconroy@realtors.org

 
0 (0 Votes)
Easiest way to pull all current data in JSON or XML?
Answer
11/20/15 11:15 AM as a reply to David Conroy.
Hi Dave and welcome to the XDK community,

it's great to hear about your plans with the XDK and we're happy to help.

The XDK comes only with a SDK at the moment that allows you to implement your own software components. Apart from that, there is no preinstalled software on the XDK or anything similar to that. 
We provide a handful of demos to you, that are sample implementations to demonstrate what the XDK is capable of. 

For your use case you would have to implement the webService that would provide the sensor data as JSON yourself. If you take a look at the DataLogger Demo you can take their component to create JSON data from the sensors and you would "only" need to implement the webService.
Depending on how you need your webService formed, you might even consider checking the SensorMonitor demo to look how they propagate the data over network and adjust it to your use.

If you can provide me with greater detail of how your other devices are connected and what format you need, we can might help you even further along and consult you in how you can add the XDK as on of your supported devices.

- Florian
0 (0 Votes)
RE: Easiest way to pull all current data in JSON or XML?
Answer
2/2/17 1:48 PM as a reply to Florian Harr.

Hi,

 

Do you mind elaborating on this?

 

0 (0 Votes)
RE: Easiest way to pull all current data in JSON or XML?
Answer
2/2/17 4:54 PM as a reply to Lee Weiyang.

Hello Lee,

I would recommend to take a look at the Bosch-XDK-Portal demo, further at the implementation file bxpSensor.c. There you can find a complete implementation about how to write data into JSON format. 

Please tell me if this solves your issue and do not hesitate to ask if you have further questions.

Kind regards,
Manuel

0 (0 Votes)
RE: Easiest way to pull all current data in JSON or XML?
Answer
2/3/17 12:58 PM as a reply to Manuel Cerny.

Thanks.

I've looked at the document and I think I understand how to parse the data in JSON Format.

However, I would like to know how does this function: void Sensor_sendReportData(void),

push the data to the webservice after generating the report?

 

Is it via this?

 

/* Forever Loop Necessary for freeRTOS Task */
    for(;;)
    {
    	WDG_feedingWatchdog();
    	/* Publish Live Data Stream */
        if(g_sensorStreamBuffer.length > NUMBER_UINT32_ZERO)
        {
            msg.id = clientMessageId++;
            msg.qos = 0;
            msg.payload = g_sensorStreamBuffer.data;
            msg.payloadlen = g_sensorStreamBuffer.length;
            MQTTPublish(&c, clientTopicStream_ptr, &msg);

        	memset(g_sensorStreamBuffer.data, 0x00, SENSOR_DATA_BUF_SIZE);
        	g_sensorStreamBuffer.length = NUMBER_UINT32_ZERO;
        }
    	/* Publish Report Data Stream */
        else if(g_sensorReportBuffer.length > NUMBER_UINT32_ZERO)
        {
            msg.id = clientMessageId++;
            msg.qos = 0;
            msg.payload = g_sensorReportBuffer.data;
            msg.payloadlen = g_sensorReportBuffer.length;
            MQTTPublish(&c, clientTopicReport_ptr, &msg);

        	memset(g_sensorReportBuffer.data, 0x00, SENSOR_DATA_BUF_SIZE);
        	g_sensorReportBuffer.length = NUMBER_UINT32_ZERO;
        }
    	/* Publish Config Data Stream */
        else if(g_sensorConfigBuffer.length > NUMBER_UINT32_ZERO)
        {
            msg.id = clientMessageId++;
            msg.qos = 0;
            msg.payload = g_sensorConfigBuffer.data;
            msg.payloadlen = g_sensorConfigBuffer.length;
            MQTTPublish(&c, clientTopicConfig_ptr, &msg);

        	memset(g_sensorConfigBuffer.data, 0x00, SENSOR_DATA_BUF_SIZE);
        	g_sensorConfigBuffer.length = NUMBER_UINT32_ZERO;
        }

 

0 (0 Votes)
RE: Easiest way to pull all current data in JSON or XML?
Answer
2/4/17 3:50 PM as a reply to Lee Weiyang.

Hello Lee,

the function uses the MQTT protocol to transmit the data to the Bosch MQTT broker. In detail  the data is passed to the struct MQTTMessage first, and then send via MQTTPublish() to the Bosch MQTT broker. Afterwards the data is accessed from the Bosch MQTT broker by a subscribing MQTT client.

If you wand to get more information about MQTT, how it works and about the implementation please refer to the MQTT guide. Please note that MQTT is not necessary for JSON. You can send JSON via other protocols as well.

Please tell me if was helpful and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 Votes)