IMPORTANT NOTE: This agent is no longer maintained.
IMPORTANT NOTE: This release has changes that break funcionality in previous releases. You have to delete your device from Cumulocity, change your configuration in
config.txt
and register it again.CHANGES
- The format of the configuration in
config.txt
changed. From now on all parameters don't haveENABELED
in their name, e.g.ACCELENABELED
becomesACCEL
- This version will only work with Bosch XDK Workbench version 3.6.1. This version contains an improved error handling in case the MQTT connection get disconnected
- The format of the device Id changed from
XDK_7C_7C_7C_7C_7C_7C
to7C7C7C7C7C7C
. Where7C7C7C7C7C7C
should be replaced by your MAC WLAN printed on the bottom sticker of your XDK
Background: Since the memory of the XDK is limited changes were introduced to reduce the length of keys.
This project is a device agent to connect the Bosch XDK to Cumulocity (C8Y Agent for XDK). The XDK is a quick and professional prototyping platform for prototyping IoT use cases.
For this demo a Cumulocity tenant and an XDK device is required. For a free trial tenant you can register here.
When the XDK is registered in a Cumulocity tenant the environmental sensor readings measured by the XDK are sent to the Cumulocity IoT cloud. Potential use cases are:
The device agent allows to send measurements from the XDK to your Cumulocity tenant. These measurements can be visualised in dashboards.
In the downstream direction operation commands can be sent to the XDK using the device managment app in Cumulocity: change configuration of sensors, stop/start publishing measurements and restarting the device.
To get an idea of the currently active configuration the device agent sends its current configuration to the tenant. So in the devicemanagment app you can view always the currently active configuration.
But before running the XDK in OPERATION mode you have to register the device in your Cumulocity tenant. Initially the XDK is in REGISTRATION mode. The registration is achieved automatically through the bootstrap meachnism. This is described in further detail here.
After successful registration - device credentials are received by the XDK - the XDK restarts automatically. Commands can be send from the Cumulocity App Devicemanagement to change the sensor speed, toogle an LED or switch on/off sensors, see documentation https://www.cumulocity.com/guides/users-guide/device-management/#shell .
NOTE: Make sure your SD card is smaller than 32GB, otherwise it can't be formatted in the FAT filesystem format
- Format SD in FAT format
- Adapt settings in
config.txt
and copy to SD card. A template for config.txt exists in the project "cumulocity-xdk-agent/resources". Ideally you only need to changeWIFISSID
andWIFIPASSWORD
.- If your tenant is on an instance other than
cumulocity.com
, then you need to update:MQTTBROKERNAME
, e.g. tomqtt.eu-latest.cumulocity.com
if your tenant url looks like:XXX.eu-latest.cumulocity.com
WLAN: 7C_7C_7C_7C_7C_7C
, e.g. 7C7C7C7C7C7C
NOTE: remove the
_
form the WLAN MAC adress
Install the XDK Workbench: https://xdk.bosch-connectivity.com/software-downloads
NOTE: The installation path must not contains blanks.
NOTE: The current version of the Workbench 3.6.1 defines a buffer size that is not sufficient for the certificate being used for Cumulocity. Therefore the buffer has to be increased.
In order to avoid a buffer overflow, as seen in the following error message:
INFO | XDK DEVICE 1: MQTT_ConnectToBroker_Z: connecting secure
INFO | XDK DEVICE 1: 11 [SSL:1] Sec_receiveCB: HORRIBLE Buffer full state=1 (0x200023fc)
Increase MBEDTLS_SSL_MAX_CONTENT_LEN macro value from 4850 to 5950 in Common/config/MbedTLS/ MbedtlsConfigTLS.h in line 2921. The macro MBEDTLS_SSL_MAX_CONTENT_LEN determines the size of both the incoming and outgoing TLS I/O buffer used by MbedTLS library.
git clone https://github.com/SoftwareAG/cumulocity-xdk-agent.git
NOTE: connect your XDK using USB cable to get debug messages.
config.txt
stored on the SD cardThis section contains all information that is relevant once the XDK is registered in Cumulocity
The XDK can receive operations and messages initiated in your C8Y tenant. Operations to the XDK can either be issued by using:
cockpit
and execute "Restart device" from dropdown-menue "More"The following commands are supported:
speed 1000
: to publish measurements every 1000 m, changing the speed is written to the config file on the WIFI chiptoggle
sensor NOISE TRUE
or sensor NOISE TRUE
: to enable/disable the noise sensor. To tkae effect an restart is required. Enabling/disabling the sensor is written to the config file on the WIFI chipstop
start
You can view the last events transmitted form the XDK by accessing the app Device management
and follow: Device Management>Devices>All Devices. Then choose your XDK and select the Events
template
You can see events like::
The buttons have following on the XDK have the following functions:
config.txt
file on the filesystem of the WIFI chipThe C8Y Agent for XDK sends the following sensor measurements to C8Y:
ACCEL=<TRUE TO SEND MEASUREMENTS, FALSE OTHERWISE> | default-value true
# unit gGYRO=<TRUE TO SEND MEASUREMENTS, FALSE OTHERWISE> | default-value true
MAG=<TRUE TO SEND MEASUREMENTS, FALSE OTHERWISE> | default-value true
ENV=<TRUE TO SEND MEASUREMENTS, FALSE OTHERWISE> | default-value true
# unit temp C, pressure hPaLIGHT=<TRUE TO SEND MEASUREMENTS, FALSE OTHERWISE> | default-value true
# unit LuxNOISE=<TRUE TO SEND MEASUREMENTS, FALSE OTHERWISE> | default-value false
#with the defined streamrate:
STREAMRATE=<SPEED TO SEND MEASUREMENTS TO C8Y IN MILLISECONDS> | default-value 5000
Measurements types can be switched on/off in config.txt
by setting the value to TRUE
, FALSE
.
NOTE: Make sure you use Unix line endings instead of Windows line endings. Otherwise the config file cannot be parsed correctly.
NOTE: Don't use blanks anywhere in the file. After the last config line a newline is required.
The configuration for the XDK uses two sources:
config.txt
on the SDCardconfig.txt
on the filesystem of the WIFI chip When registering the XDK a config on an SD card has to be inserted in the XDK. Upon sucessful registration, i.e. device receives credentials from Cumulocity, the config value including theMQTTUSER
, MQTTPASSWORD
are written to the config file on WIFI. From then on the XDK can operate without an SDCard.
Nevertheless in certain situations it is helpful to only change the WIFI settings and keep all the other settings. Then one can set values for WIFISSID
,WIFIPASSWORD
in the config.txt
on SD and thus overwrite settings stored on the file system of the WIFI chip.
The values defined in the config on the SDCard always take precedence.
NOTE: When setting up a hot spot for the WIFI connection, mak esure you use a network band of 2.4GHz, the XDK only supports this band.
In addition to the above listed measurements the battery staus is send ervery minute.
Red | Orange | Yellow | Mode | Status | Possible Cause |
---|---|---|---|---|---|
Blinking | Off | Off | Operation & Registration | Starting | |
On | Off | Off | Operation & Registration | Error | wrong config, no Wifi access, SNTP server not reachable |
Blinking once | Any | Any | Operation | Received command | |
Off | Blinking | Any | Operation | Running - Publishing | |
Off | On | Any | Operation | Running - Publishing stopped | |
Blinking | Blinking | Any | Operation | Restarting | |
Off | Off | Blinking | Registration | Running - Waiting for credentials | |
Off | Off | On | Registration | Running - Registration successful |
For TLS the root certificate of the CA has to be flashed to the XDK.
This certificate in included in the header file source\ServerCA.h in PEM format. The currently included certificate from "Go Daddy Class 2 Certification Authority" is used for tenants *.cumulcity.com.
If your CA is different this needs to be changed.
When you use a XDK with bootloader version 1.1.0 the maximal allowed size of the flashed binary cumulocity-xdk-agent.bin
can't exceed 600MB. In this case either:
SENSOR_TOOLBOX
library in AppController.h
. This will reduce the size below 600MB
#define ENABLE_SENSOR_TOOLBOX 0
INFO | Transmission successfully completed!
INFO | Booting application...
INFO | XDK DEVICE 1: Performing application CRC validation (this will take a couple of seconds)
INFO | XDK DEVICE 1: Application Firmware Corrupted
INFO | XDK DEVICE 1: Invalid application
mingw32-make -j 2 -j8 clean
C:\XDK-Workbench\XDK\make\mingw32-make.exe -C C:\XDK-Workbench\XDK\SDK/xdk110/Common -f application.mk clean
new_bootloader
mingw32-make[1]: Entering directory 'C:/XDK-Workbench/XDK/SDK/xdk110/Common'
application.mk:368: *** mixed implicit and normal rules. Stop.
mingw32-make[1]: Leaving directory 'C:/XDK-Workbench/XDK/SDK/xdk110/Common'
mingw32-make: *** [clean] Error 2
Makefile:53: recipe for target 'clean' failed
Connection to port 'COM9' established
INFO | Flashing file 'C:/Users/XXX/cumulocity/cumulocity-xdk-agent/debug/cumulocity-xdk-agent.bin'...
INFO | XDK DEVICE 1: Ready
INFO | XDK DEVICE 1: C
INFO | XDK DEVICE 1: XMODEM Download Success
INFO | XDK DEVICE 1: c
INFO | XDK DEVICE 1: CRC of application area
INFO | XDK DEVICE 1: CRC0000B4E4
INFO | Application checksum 'b4e4' successfully verified.
INFO | Transmission successfully completed!
INFO | Booting application...
INFO | XDK DEVICE 1: b
INFO | XDK DEVICE 1: Invalid application
If this doesn't help pls. flash a standard click app to the device, e.g LedsandButtons
. If this works try to flash the device agent again.
----- HEAP ISSUE ----
When you see an exception as below, then you should increase the heap size in xdk110/Common/config/AmazonFreeRTOS/FreeRTOS/FreeRTOSConfig.h
.
INFO | XDK DEVICE 2: MQTTOperation_Init: Reading boot status: [0]
INFO | XDK DEVICE 2: SntpSentCallback : Success
INFO | XDK DEVICE 2: SntpTimeCallback : received
INFO | XDK DEVICE 2: ----- HEAP ISSUE ----
INFO | XDK DEVICE 2: MQTT_ConnectToBroker_Z: Failed since Connect event was not received
INFO | XDK DEVICE 2: MQTTOperation: MQTT connection to the broker failed [0] time, try again ...
Increase heap size in xdk110/Common/config/AmazonFreeRTOS/FreeRTOS/FreeRTOSConfig.h
by changing the following value:
#define configTOTAL_HEAP_SIZE (( size_t )(72 * 1024 )) # old value is (( size_t )(70 * 1024 ))
Please verify if you used Linux line endings \n
A sample dashboard can be build using the resources/Container_V01.svg.
Please see: https://www.cumulocity.com/guides/users-guide/optional-services/ for a documentation on how to use the svg in a SCADA widget.
Dashboard from above is build using the following standard Cumulocity widgets:
c8y_Light
with min 50000 and max 100000c8y_acceleration=>accelerationX
, c8y_acceleration=>accelerationY
and c8y_acceleration=>accelerationZ
Using the Cumulocity custom widget published on the github: https://github.com/SoftwareAG/cumulocity-collada-3d-widget you can view the rotation of the XDK
After installation of the collada widget you will need to upload the 3D model of the XDk. This is available resources/XDK.dae
. The following screenshots shows the required configuration:
These tools are provided as-is and without warranty or support. They do not constitute part of the Software AG product suite. Users are free to use, fork and modify them, subject to the license agreement. While Software AG welcomes contributions, we cannot guarantee to include every contribution in the master project.
For more information you can Ask a Question in the TECHcommunity Forums.
You can find additional information in the Software AG TECHcommunity.
Contact us at TECHcommunity if you have any questions.