Bosch XDK to Bosch IoT Cloud
Risposta
03/09/18 10.06

I am trying to connect Bosch XDK toBosch IoT Cloud. I am following the instruction of a tutorial on bosch iot suite website. It is mentioned there to copy the config.txt file to SD card and place the SD card in the sd card slot of XDK but the problem is that I don't have any SD card in my XDK. What should I do? Can I use the XDK without SD card to connect it with Bosch IoT Cloud or not?

Thank you.

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
03/09/18 14.58 come risposta a Sajid Baloch.
Hello Sajid,

currently, the connection to the Bosch IoT cloud can only get established with the BoschXDKCloudConnectivity example, using a configuration file on the XDK's plugged SD card.

Since the settings get directly loaded from the config.txt file into the XDKs Wi-Fi chip, there is no workaround without the need of a SD card.

To the SD card requirements:

The XDK supports micro SD cards up to a capacity of 32 GB.
The required filesystem is FAT32.
The filesystems NTFS and SDXC are NOT supported!
To guarantee a smooth performance, class 4 cards and above are highly recommended.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo
0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
03/09/18 15.35 come risposta a Franjo Stjepandic.

Thanks for your response. I installed a class 10 SD Card (32-GB) having the config file in root directory and now I am trying to send the data to Bosch IoT cloud. 

- I have created a Thing and set the API Token but still not being able to get the live data. 

Is it due to the authorization/permission? 

How can I get the live data?

Can you please help me and guide me step by step?

I am trying to send the temperature and humidity data to Cloud and get it on any device. Please suggest me the easiest way to do it. Thanks.

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
03/09/18 15.41 come risposta a Sajid Baloch.
I also want to ask that I am not being able to create a new subscription. It says "Failed (Quota)". Can you help me in this as well?
0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
04/09/18 15.25 come risposta a Sajid Baloch.

Hello Sajid,

first, I require more informations about your use case scenario, before I can conclude about the root of your issue.

Did you follow all instructions at to configure your account settings, in order to receive data from the XDK?

Regarding the live data:
There exists a slider Live Data, which can be found within the same menu as the slider My Things. Using this, you can take a look at the data one of your XDK's streaming over the BoschXDKCloudConnectivity example.

Could you please provide an outline of your XDK-Workbench console, while running the BoschXDKCloudConnectivity example? Yesterday occured an issue, located in the backend, so your problem could be already solved.


This thread here provides further informations.

Also, there exists a slider called API, which you can use to obtain the data for your own application (e.g. requesting to any device with a complementary app).

In regards to the subscription, could you please provide more detail about the subscription itself, you try to generate and also about the location, at which step the process exactly fails?

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

Kind regards,
Franjo

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
05/09/18 10.13 come risposta a Franjo Stjepandic.

Thanks for your response.


--Did you follow all instructions at to configure your account settings, in order to receive data from the XDK?
                 YES, I did follow all the instructions of the tutorial. I don't know whether I need to do some changes in the BoschXDKCloudConnectivity or not. I haven't changed anything, just flashed the code as it is in th XDK. 


Regarding the live data:
There exists a slider Live Data, which can be found within the same menu as the slider My Things. Using this, you can take a look at the data one of your XDK's streaming over the BoschXDKCloudConnectivity example.

Yes, I am getting the Live Data now. I wasn't getting it before.

 

Can I save the data over Bosch IoT Cloud? I haven't used the IoT Hub, IoT Analytics or any other service but still I am getting the data. Are these services for subscribing or publishing? 

I want to ask, How can I setup my own application to get the value?

What are the options to get the data on a device or app? Can you guide me the easiest way to get the data on any other device? There are no preferences for the device/app.


 

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
05/09/18 14.20 come risposta a Sajid Baloch.
Hello Sajid,

thank you for answering the questions.

Good, you followed the tutorial. If your config file, which is stored on the SD card, includes username and password, like in the tutorial explained, there is no need to change the example code at all.

Glad to hear, you are able to receive the live data now.

For storing your data on the Bosch IoT Cloud server, Bosch IoT Things is a good way to go and works with a free account.
A detailed information about this service, you can find at the Bosch IoT Things website . Your questions regarding the wish to share data from the cloud to other devices or applications will probably clear itself when you step into the topic IoT Things. Bosch IoT Things offers huge possibilities, including your imagined scenario.

I deeply advise you to not rush into this topic by the thought of finishing your project as fast as possible.
Better take your time and enjoy all the incoming knowledge for an even better output.

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

Kind regards,
Franjo
0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
05/09/18 15.28 come risposta a Franjo Stjepandic.

Thanks for your kind suggestions.

For storing your data on the Bosch IoT Cloud server, Bosch IoT Things is a good way to go and works with a free account.

I am already using Bosch IoT Things. I did registered my XDK as a Thing and that's why being able to get the live data. 

 

A detailed information about this service, you can find at the Bosch IoT Things website . Your questions regarding the wish to share data from the cloud to other devices or applications will probably clear itself when you step into the topic IoT Things. Bosch IoT Things offers huge possibilities, including your imagined scenario.
Okay, I will look into it.


I am still not being able to add new subscription on Bosch IoT Suite. The screenshot is attached.

 

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
06/09/18 15.18 come risposta a Sajid Baloch.
Hello Sajid,

thank you for your attached screenshot.
Okay, obviously there is an issue with your current IoT Hub subscription, so I suggest you to remove it first.

I reconstructed the scenario with two different subscriptions and had no issues as you can see in the attached screenshot.

Here my proceeded steps you can follow:
 
  1. I went to My Account, then to Service Subscriptions.
    You also can enter the site by clicking this link, if you are logged in as user.
  2. When I clicked the + New Subscription button, a pop up menu appears.
    For the first subscription, I choose Bosch IoT Things.
  3. On the directed service configuration page, I named the instance and created a namespace.
    Followed with the click on Subscribe, the first IoT Things Subscription was done.
    It took a few minutes, then this service was activated.
  4. Back to the Service Subscription page, I repeated steps 2 and 3, except for choosing a IoT Hub subscription this time.
I hope it will work with your next try.
If you still struggle to subscribe to IoT Things, please provide detailed informations about the failure itself.

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

Kind regards,
Franjo
0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
16/10/18 9.40 come risposta a Franjo Stjepandic.

Thank you for your support. 

Recently, I tried connecting the XDk witht th Bosch IoT Cloud using the Bosch XDK Cluid connectivity example but it doesn't work accordingly. The example seems to be changed. Has it changed with the updated version of Workbench? If yes, then how can we connect it now? BEcause the tutorial is still the old one.

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
16/10/18 15.00 come risposta a Sajid Baloch.

Thank you for your continuous help.

I want to connect the XDK to Amazon DynamoDB and as I depicted from what I have searched, I came to know that I have to code a javascript file in order to publish and subscribe the data and save them to the database.

I don't know from where to start since I am not good in javascript. Can you please guide me in detail how to send the XDK sensor data to the DynamoDB?

 I already setup the XDk and getting the Live Data. But from the old code not with the new example code.

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
16/10/18 16.01 come risposta a Sajid Baloch.
Hello Sajid,

the issue regarding the BoschXDKCloudConnectivity example in combination with the latest XDK Workbench 3.4.0 is an already known and reported bug.

Until this bug is fixed, I suggest to use the older BoschXDKCloudConnectivity example from the XDK Workbench 3.3.1. Keep in mind, this BoschXDKCloudConnectivity example needs to be used within the XDK Workbench 3.3.1 and should not be imported into the XDK Workbench 3.4.0.

To your latest post, I can recommend Amazon's JavaScript and DynamoDB developer guide .
To get an idea what it is supposed to look like finished, Amazon also published some DynamoDB Examples . Their site also links an article with API references, which could be helpful.

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

Kind regards,
Franjo
0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
17/10/18 10.39 come risposta a Franjo Stjepandic.

Thank you for your response. 

Can you tell me when the bug will be resolved? Is there any way to be notified once it solved?

 

The live data is being displayed on Bosch Iot Things with the help of IoT Things subscription. I want to know, how can I get the selected sensor data and send it to dynamoDB? Do I have to use XDKCloudConnectivity example or any other example code to flash on XDK? I can send the data using javascript but for that I need the data. And for data, I need to code something on XDK from Workbench. 

Thanks a lot for your kind support.

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
17/10/18 11.56 come risposta a Sajid Baloch.

Do you think this will solve my problem?

https://xdk.bosch-connectivity.com/community/-/message_boards/message/294438

Because I also want to get the sensor data and save it somewhere in the cloud e.g. DynamoDB. 

Is there any Cloud Storage by Bosch? How can I save the data on Bosch Cloud if there is a service liek that?

So that I can subscribe it from wherever and whenever I want. 

A typical IoT Application.  

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
17/10/18 11.21 come risposta a Sajid Baloch.

What I really want is an IoT application. 

I want to access the XDK sensor values from the internet. 

For example, 

I want to get the value of temperature recorded by XDK in my computer at any time instance. Whenever I want to know the temperature, I should be getting it. 

Can you please explain me how it can be done efficiently and easily?

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
17/10/18 16.09 come risposta a Sajid Baloch.
Hello Sajid,

Unfortunately, I do not know the upcoming release date regarding the bugfix yet, but I will inform you in this thread here, when an update is available.

Regarding your project goals, I would prefer a simple HTTP connection to a HTTP server. With an HTTP POST-request you can transfer the temperature data to the server.
If you decide to show the temperature data on a local or a global website, depends on your interest.

A good HTTP article which includes a full code example for a HTTP POST-request can be found at the XDK knowledgebase , after a free registration and a click at the button getting started . To open the article, choose at the left sided menu the topic Protocols , then click on HTTP .

A second option would be the use of MQTT. MQTT is a much lighter internet protocol than HTTP and optimized for IoT. Instead a HTTP server, it requires a MQTT broker. Devices that want to receive the by the XDK published value need to subscribe to a broker's topic. The linked knowledgebase from above also offers a good MQTT article, which you could take a look at.

For an easy solution, I recommend you the HTTP POST-request. The professional, efficient IoT solution could be the use of MQTT.

To answer your questions from the other posts, when you are talking about DynamoDB, do you mean this in the context of an AWS service, or is any other cloud sufficient? Please note that my suggestions beforehand depend on this, since AWS requires a specific handling regarding establishing a connection to it.

Furthermore, you could also use the data from the BoschXDKCloudConnectivity example, which is provided in the Bosch IoT cloud and send it to your own web service with the integrated HTTP API from the backend of the BoschXDKCloudConnectivity example. Otherwise, I recommend a solution as mentioned in the beginning of this post.

In regards to the cloud storage by Bosch, it depends on the services, the Bosch IoT cloud is providing. I assume the Bosch IoT Insights service from the Bosch IoT cloud could be a service you are looking for.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo
0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
18/10/18 10.22 come risposta a Franjo Stjepandic.

Thanks a lot Franjo. 

I think Bosch IoT Insights is the right service for which I am looking for. Can you please explain how can I send and analyse the data from XDK to Bosch IoT Insights? 

I have one more question. Can you please explain the difference between Bosch IoT Analytics and Bosch IoT Insights?

Thank you. 

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
18/10/18 14.56 come risposta a Sajid Baloch.
RE: Bosch XDK to Bosch IoT Cloud
0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
18/10/18 15.27 come risposta a Sajid Baloch.

Hi. I have seen the knowledgebase and I want to use the MQTT protocol. 

I set up everything accordingly. 

Then, I am getting this compilation error:

Creating .out C:/Users/HP/XDK-Workspace/XDKMQTT/debug/XDKMQTT.out
c:/xdk-workbench/xdk/armgcc/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7-m/crt0.o: In function `start':
(.text+0x4a): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status
application.mk:391: recipe for target 'C:/Users/HP/XDK-Workspace/XDKMQTT/debug/XDKMQTT.out' failed
mingw32-make[1]: *** [C:/Users/HP/XDK-Workspace/XDKMQTT/debug/XDKMQTT.out] Error 1
mingw32-make[1]: Leaving directory 'C:/XDK-Workbench/XDK/SDK/xdk110/Common'
Makefile:31: recipe for target 'debug' failed
mingw32-make: *** [debug] Error 2

What I depicted is that, there should be a main function which calls the defined function. How can I do it? 

Tell me if I have understood it wrong.

Thank you.

0 (0 Voti)
RE: Bosch XDK to Bosch IoT Cloud
Risposta
18/10/18 15.30 come risposta a Sajid Baloch.

/* own header files */
#include "XdkAppInfo.h"
#undef BCDS_MODULE_ID  /* Module ID define before including Basics package*/
#define BCDS_MODULE_ID XDK_APP_MODULE_ID_APP_CONTROLLER

/* system header files */
#include <stdio.h>
#include "XdkSystemStartup.h"
/* additional interface header files */
#include "BCDS_CmdProcessor.h"
#include "FreeRTOS.h"
#include "BCDS_NetworkConfig.h"
#include "BCDS_WlanConnect.h"
#include "BCDS_ServalPal.h"
#include "BCDS_ServalPalWiFi.h"
#include "PAL_initialize_ih.h"
#include "AppController.h"
// MQTT API
#include "Serval_Mqtt.h"

/* --------------------------------------------------------------------------- |
 * HANDLES ******************************************************************* |
 * -------------------------------------------------------------------------- */
static CmdProcessor_T * AppCmdProcessor;
static CmdProcessor_T CmdProcessorHandleServalPAL;

/* --------------------------------------------------------------------------- |
 * VARIABLES ***************************************************************** |
 * -------------------------------------------------------------------------- */

#define TASK_PRIORITY_SERVALPAL_CMD_PROC            UINT32_C(3)
#define TASK_STACK_SIZE_SERVALPAL_CMD_PROC          UINT32_C(600)
#define TASK_QUEUE_LEN_SERVALPAL_CMD_PROC           UINT32_C(10)

#define MQTT_BROKER_HOST "broker.hivemq.com"
#define MQTT_BROKER_PORT 1883
static MqttSession_T session;
static MqttSession_T *session_ptr = &session;

/* --------------------------------------------------------------------------- |
 * EXECUTING FUNCTIONS ******************************************************* |
 * -------------------------------------------------------------------------- */

static Retcode_T ServalPalSetup(void)
{
    Retcode_T returnValue = RETCODE_OK;
    returnValue = CmdProcessor_Initialize(&CmdProcessorHandleServalPAL, (char *)"Serval PAL", TASK_PRIORITY_SERVALPAL_CMD_PROC, TASK_STACK_SIZE_SERVALPAL_CMD_PROC, TASK_QUEUE_LEN_SERVALPAL_CMD_PROC);
    /* serval pal common init */
    if (RETCODE_OK == returnValue)
    {
        returnValue = ServalPal_Initialize(&CmdProcessorHandleServalPAL);
    }
    if (RETCODE_OK == returnValue)
    {
        returnValue = ServalPalWiFi_Init();
    }
    if (RETCODE_OK == returnValue)
    {
        ServalPalWiFi_StateChangeInfo_T stateChangeInfo = { SERVALPALWIFI_OPEN, 0 };
        returnValue = ServalPalWiFi_NotifyWiFiEvent(SERVALPALWIFI_STATE_CHANGE, &stateChangeInfo);
    }
    return returnValue;
}

void networkSetup(void) {
    WlanConnect_SSID_T connectSSID = (WlanConnect_SSID_T) "HT16Pro";
    WlanConnect_PassPhrase_T connectPassPhrase = (WlanConnect_PassPhrase_T) "437185b2f716";
    WlanConnect_Init();
    NetworkConfig_SetIpDhcp(0);
    WlanConnect_WPA(connectSSID, connectPassPhrase, NULL);

    ServalPalSetup();

    NetworkConfig_IpSettings_T myIp;
    NetworkConfig_GetIpSettings(&myIp);

    // insert a delay here, if the IP is not properly printed
    printf("The IP was retrieved: %u.%u.%u.%u \n\r",
        (unsigned int) (NetworkConfig_Ipv4Byte(myIp.ipV4, 3)),
        (unsigned int) (NetworkConfig_Ipv4Byte(myIp.ipV4, 2)),
        (unsigned int) (NetworkConfig_Ipv4Byte(myIp.ipV4, 1)),
        (unsigned int) (NetworkConfig_Ipv4Byte(myIp.ipV4, 0)));
}

retcode_t init(void) {
    retcode_t rc_initialize = Mqtt_initialize();
    if (rc_initialize == RC_OK) {
        session_ptr = &session;
        Mqtt_initializeInternalSession(session_ptr);
    }
    return rc_initialize;
}

static void subscribe(void) {
    static char *sub_topic = "your/publish/topic";
    static StringDescr_T subscription_topics[1];
    static Mqtt_qos_t qos[1];
    StringDescr_wrap(&(subscription_topics[0]), sub_topic);
    qos[0] = MQTT_QOS_AT_MOST_ONE;
    Mqtt_subscribe(session_ptr, 1, subscription_topics, qos);
}

static void publish(void) {
    static char *pub_message = "Hello World";
    static char *pub_topic = "your/publish/topic";
    static StringDescr_T pub_topic_descr;
    StringDescr_wrap(&pub_topic_descr, pub_topic);

    Mqtt_publish(session_ptr, pub_topic_descr, pub_message, strlen(pub_message),
            MQTT_QOS_AT_MOST_ONE, false);
}

static void handleIncomingPublish(MqttPublishData_T publishData) {
    int topic_length = publishData.topic.length + 1;
    int data_length = publishData.length + 1;
    char published_topic_buffer[topic_length];
    char published_data_buffer[data_length];
    snprintf(published_topic_buffer, topic_length, publishData.topic.start);
    snprintf(published_data_buffer, data_length, (char *) publishData.payload);
    printf("Incoming Published Message:\n\r"
            "\tTopic: %s\n\r"
            "\tPayload: %s\n\r", published_topic_buffer, published_data_buffer);
}

static void handleConnection(MqttConnectionEstablishedEvent_T connectionData) {
    int rc_connect = (int) connectionData.connectReturnCode;
    printf("Connection Event:\n\r"
            "\tServer Return Code: %d (0 for success)\n\r", (int) rc_connect);
}

retcode_t eventHandler(MqttSession_T* session, MqttEvent_t event,
        const MqttEventData_t* eventData) {
    BCDS_UNUSED(session);
    switch (event) {
    case MQTT_CONNECTION_ESTABLISHED:
        handleConnection(eventData->connect);
        // subscribing and publishing can now be done
        subscribe();
        //publish();
        break;
    case MQTT_CONNECTION_ERROR:
        handleConnection(eventData->connect);
        break;
    case MQTT_INCOMING_PUBLISH:
        handleIncomingPublish(eventData->publish);
        break;
    case MQTT_SUBSCRIPTION_ACKNOWLEDGED:
        printf("Subscription Successful\n\r");
        publish();
        break;
    case MQTT_PUBLISHED_DATA:
        printf("Publish Successful\n\r");
        break;
    default:
        printf("Unhandled MQTT Event: %d\n\r", event);
        break;
    }
    return RC_OK;
}

void configSetTarget(void) {
    static char mqtt_broker[64];
    const char *mqtt_broker_format = "mqtt://%s:%d";
    char server_ip_buffer[13];
    Ip_Address_T ip;

    PAL_getIpaddress((uint8_t *) MQTT_BROKER_HOST, &ip);
    Ip_convertAddrToString(&ip, server_ip_buffer);
    sprintf(mqtt_broker, mqtt_broker_format, server_ip_buffer,
            MQTT_BROKER_PORT);

    SupportedUrl_fromString(mqtt_broker, (uint16_t) strlen(mqtt_broker),
            &session_ptr->target);
}

void configSetConnectData(void) {
    static char *device_name = "XDK110_Guide_Device";
    session_ptr->MQTTVersion = 3;
    session_ptr->keepAliveInterval = 100;
    session_ptr->cleanSession = true;
    session_ptr->will.haveWill = false;

    StringDescr_T device_name_descr;
    StringDescr_wrap(&device_name_descr, device_name);
    session_ptr->clientID = device_name_descr;
}

void configSetEventHandler(void) {
    session_ptr->onMqttEvent = eventHandler;
}

retcode_t connectToBroker(void) {
    retcode_t rc = RC_INVALID_STATUS;
    rc = Mqtt_connect(session_ptr);
    if (rc != RC_OK) {
        printf("Could not connectToBroker, error 0x%04x\n", rc);
    }
    return rc;
}

int main(void)
{
    /* Mapping Default Error Handling function */
    Retcode_T retcode = Retcode_Initialize(DefaultErrorHandlingFunc);
    if (RETCODE_OK == retcode)
    {
        retcode = systemStartup();
    }
    if (RETCODE_OK == retcode)
    {
        retcode = CmdProcessor_Initialize(&AppCmdProcessor, (char *) "AppCmdProcessor", TASK_PRIO_MAIN_CMD_PROCESSOR, TASK_STACK_SIZE_MAIN_CMD_PROCESSOR, TASK_Q_LEN_MAIN_CMD_PROCESSOR);
    }
    if (RETCODE_OK == retcode)
    {
        /* Here we enqueue the application initialization into the command
         * processor, such that the initialization function will be invoked
         * once the RTOS scheduler is started below.
         */
        retcode = CmdProcessor_Enqueue(&AppCmdProcessor, AppController_Init, &AppCmdProcessor, UINT32_C(0));
    }
    if (RETCODE_OK == retcode)
    {
        /* start scheduler */
        vTaskStartScheduler();
        /* Code must not reach here since the OS must take control. If not, we will assert. */
    }
    else
    {
        Retcode_RaiseError(retcode);
        printf("main : XDK System Startup failed.\r\n");
    }
    assert(false);
}
/** ************************************************************************* */

This is my code with main function. There are no errors but when I flash it on XDK. The XDK isn't being connected to the WLAN. Do I need to use SD Card with config setttings or not?

I don't know where the problem is. It gets flashed and does nothing.

0 (0 Voti)