Reading XDK Value
Answer
7/11/18 5:39 AM

Hello guys,

I'm a newbie in Python and I have a question:

Is it possible to read data values of XDK using HTTP API with Python script ? Could you please give me some examples or documents ? Thanks you !

0 (0 Votes)
RE: Reading XDK Value
Answer
7/11/18 2:35 PM as a reply to Nhan Tran Dinh.
Hello Nhan,

First, I would like to welcome you to the XDK community.

In general, it is possible to transmit the sensor data from the XDK over a serial or wireless transmission to any destination and then fetch the data over a python script.

On the XDK side, you could use the StreamSensorDataOverUsb example, send the data over USB and then fetch the data over a python script, which listens on the serial port.

Otherwise, you could also use the BoschXDKCloudConnectivity example, send the data to the Bosch IoT cloud and then fetch this data with an in python implemented HTTP API on your own server.

Alternatively, you could also build your own XDK application from the scratch by using the XDK guides from the Learning section as starting point to suit your use case best.

In regards to learning python, I recommend that you go through some tutorials, for example, this here to get familiar with the language.

For specific python implementations, for example a HTTP server, I recommend taking a look at the free available implementations at GitHub .

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: Reading XDK Value
Answer
7/13/18 3:40 PM as a reply to Franjo Stjepandic.

Hi!

On this link there is and example of reading temperature over USB and a python script that graph the data on screen and send a Twitter notification.

Link: XDK and Python over serial port

0 (0 Votes)
RE: Reading XDK Value
Answer
7/16/18 3:48 PM as a reply to Rolando Gonzalez.
Hello Rolando,

thank you for the input on this graphical representation.

I'm sure that a lot of our community members will benefit from the project you found.

Kind regards,
Franjo
0 (0 Votes)
RE: Reading XDK Value
Answer
8/1/18 9:18 AM as a reply to Franjo Stjepandic.

Hi Franjo,

I had read the sensor data using Python and HTTP API with request lib successful.I declared headers dict like this :

headers={'x-cr-api-token':'***',
         'Accept': 'application/json',
         'Authorization':'***' }

Everything was good in about 30-45 mins and I received response code 401.The authorization maybe expired and I had to get a new one. How could I fix this error ? Or any solution to get new Authorization automatically ?

0 (0 Votes)
RE: Reading XDK Value
Answer
8/1/18 1:40 PM as a reply to Nhan Tran Dinh.
Hello Nhan,

a possible solution depends on how you implement the HTTP functionality in your XDK application to send out requests to your python HTTP server.

As far as I understand, you are making one request containing regarding the authentification credentials at the beginning and then you send the data without the authentification header to your python HTTP server. Am I right so far?

If that is the case, then you could simply add the authentication header at a certain number of requests and reauthenticate the XDK at certain points in time.

Otherwise, it would be very helpful if you could provide your XDK HTTP implementation where you send the HTTP requests including the authentication header.

Kind regards,
Franjo
0 (0 Votes)
RE: Reading XDK Value
Answer
8/6/18 3:17 AM as a reply to Franjo Stjepandic.

Hi Franjo,

Because I want to monitoring data from XDK and visualize it.I put request into the Python loop so it can get realtime data from XDK and visualize, I am using BoschConnectivity example and this HTTP API (https://things.s-apps.de1.bosch-iot-cloud.com/documentation/rest/#!/Things/get_things) but I could only monitoring for about 30 mins and I have to refesh HTTP API page to get new authorization.It's inconvinience ! 

0 (0 Votes)
RE: Reading XDK Value
Answer
8/7/18 7:49 AM as a reply to Nhan Tran Dinh.
Hello Nhan,

since you mentioned that refreshing the HTTP API page solves this issue, I assume the error is located on the server site.
The important part is if the XDK is still sending data after 30 minutes. This would pinpoint the source of failure to either XDK or server.

I assume that there is no limitation for the sending duration or in other words I guess that sending is not capped at 30 minutes.

Please note that the BoschConnectivity Example has a maximum data volume of this free service that you can find here .

It is possible for you to reach the maximum data limit. As soon as you refresh the page, you will delete all the "old" data, which results in a new data volume for data provided by the XDK.

Sumarized I assume that this issue is not directly related to the XDK. I would recommend you ask the support of the Bosch IoT cloud since they take care of their systems.

Please do not hesitate to ask further questions.

Kind regards,
Franjo
0 (0 Votes)