Skip navigation
Home > All Places > WICED Studio Wi-Fi/Combo > WICED Studio Wi-Fi/Combo Forums > Blog > 2016 > July

This application will demonstrate how to sent a device-to-cloud message from a WICED device to the Azure IoT Hub over HTTP.


Before running the app, you will need to have an Azure IoT Hub set up, and a device provisioned in the account.

Configuring Azure:

  1. Create an account at
  2. 1.PNG
  3. Follow the instructions here (or below) to set up an IoT Hub in your account
    1. Log in to
    2. On the left sidebar, select New -> Internet of Things -> IoT Hub
    3. Fill in the form and submit to create the IoT Hub. Deployment of the IoT Hub will take a few minutes.
    4. On your console dashboard, open the IoT Hub that was just created.
    5. Click on the key icon to open Shared Access Policies. Open the iothubowner policy and copy the connection string.
  4. 2.1.PNG
  5. Use the Device Explorer GUI (Windows only) to provision a device. Instructions; Download (scroll down to downloads)
    Use the iothub-explorer command line utility (cross platform) to provision a device. Instructions
    1. Open Device Explorer and paste the connection string into the IoT Hub Connection String field and press update.
    2. Open the Management tab and create a device. Use your own device ID take note or the device ID if the Auto Generate ID option is selected.
  6. Use the Device Explorer or WICED functions to generate a SAS token.
    Using Device ExplorerUsing WICED functions
    1. Select the SAS Token action
    2. Select the desired device and enter a TTL value.
    3. Generate the token

    Psuedocode to generate SAS:

    stringtosign = resourceURI + '\n' + expiryTimeInUTCsecs

    signedstring = base64(hmacsha265(stringtosign,secretkey))


    snprintf(SAS,length, "SharedAccessSignature sr=%s&sig=%s&se=",URIencode(resourceURI),URIencode(signedstring),expiryTimeInUTCsec)

  7. 4.PNG5.PNG6.PNG


Configuring WICED app:

  1. Download the attached .zip file and extract into apps/snip.
  2. Modify wifi_config_dct.h with credentials for your WiFi AP.
  3. Modify the HUBNAME, DEVICENAME, and SASTOKEN fields with credentials from your Azure IoT Hub.
    The SAS token has the format: SharedAccessSignature sr=<devicehubname><deviceid>&sig=<signature>&se=<expiry>
  4. As of SDK 3.7.0, TLS v1.1 is needed to connect to IIS servers. This workaround is temporary and should be patched in the next SDK release.

    Open the file <WICEDSDK>/WICED/security/BESL/host/WICED/tls_cipher_suites.c

    tls_version_num_t tls_maximum_version = TLS1_2;


    tls_version_num_t tls_maximum_version = TLS1_1;

  5. Compile and run the app with the target "snip.azure_https_client-<platform> download run"
  6. Open Device Explorer to the "Data" tab and start monitoring for data
    follow the instructions for iothub-explorer to monitor device-to-cloud messages
  7. 7.PNG8.1.PNG

Device Messaging REST API documentation can be found here: Device Messaging REST APIs

The ble_addr_toggle snippet application demonstrates how to change the Bluetooth MAC address. The app starts advertising with the default MAC address on the board. Pressing the user button on the WICED eval board will toggle the MAC address between two predetermined MAC addresses. Please note that the MAC addresses used are for demonstration only and do not follow the specifications for MAC address. To follow the demonstration, you will need two combo WICED based eval boards, or a WICED based eval board and a Bluetooth enabled device to scan for the MAC address.


Step by Step Walkthrough:

If using a non-WICED device to scan for your BT MAC address, skip to step 4.


  1. Configure your wifi_config_dct.h in the demo.bt_smartbridge folder. The WICED board will need to connect to an access point to display the scan data.
  2. Build and run the demo.bt_smartbridge app on your first WICED device using the target "demo.bt_smartbridge-<PLATFORM> download run".
  3. Disconnect the WICED board or the next steps might be applied to this board instead of the second board.
  4. Download the attached file and unzip the folder into apps/snip.
  5. Build and run the ble_addr_toggle app on your second WICED device using the target "snip.ble_addr_toggle-<PLATFORM> download run".
  6. Reconnect the first WICED board or start your non-WICED device to start scanning to Bluetooth devices.
  7. Start two instances of a terminal program (e.g. teraterm, putty, etc) to view the output from the boards.
  8. Open a web browser and navigate to the SmartBridge Demo Application web page. The IP address can be found on the terminal output from the board running the bt_smartbridge app.
  9. web1.PNG
  10. Connect/reset the board running the ble_addr_toggle app. The board will start advertising with the default MAC address and a device name of "HELLO".
  11. cmd1.PNGweb2.PNG
  12. Press the button on the WICED board (SW2) to change the MAC to the first of the predetermined addresses. This by default is 00:00:00:00:00:00.
    You can uncomment the last line in to inclue the wiced_bt_cfg.h file. This file will override the first predetermined MAC address with the one defined in wiced_bt_cfg.h. The address, by default, is 11:22:33:AA:BB:CC.
    NOTE: The app may seem unresponsive because 10 seconds are allocated to deinitialize and reinitialize the Bluetooth stack.
  13. Press "Rescan" on the webpage to scan and update the list of Bluetooth devices.
  14. wiced_bt_cfg not inlcuded:
    wiced_bt_cfg included:
  15. Press the button on the WICED board again to change the MAC address to the second predetermined MAC address. This by default is FF:FF:FF:FF:FF:FF.
  16. Press "Rescan" on the webpage to scan and update the list of Bluetooth devices.
  17. cmd3.PNG
  18. Pressing the button further will continue to toggle the MAC address between the two preconfigured addresses.


The API call to change the Bluetooth address is wiced_bt_set_local_bdaddr ( wiced_bt_device_address_t )


BLE WiFi Introducer

Posted by AndrewY_86 Jul 18, 2016

The BLE WiFi Introducer app shows an example interfacing the BLE and WiFi components on a combo chip. It demonstrates GATT database initialization, DCT configuration, processing read/write requests from a BLE client, and sending data to the client. The BLE WiFi Introducer has two components, an app running on a WICED devices, and an app running on an iOS device.


WICED App Functionality:

  • Reads WiFi network configuration from DCT and attempts to connect to the network
  • Upon failure to join the network, BLE GATT server is started to advertise network connection characteristic values
  • When the iOS app triggers the BLE GATT characteristic write event, the network credential values are received. The WICED device will attempt to connect to the network and send the result via a notification message to the iOS device
  • Pressing the user button on the WICED board wipes the WiFi network credentials from the DCT and the system is rebooted


iOS App Functionality:

  • Scans for a WICED based device and reads advertising data
  • Connects to the WICED device and allows user to enter network credentials for the currently connected network
  • Writes the network credentials to the corresponding BLE GATT characteristic values
  • Indicates the success or failure state of the WICED device network connection and allows for re-entering credentials upon connection failure


Step by step usage guide:

  1. Use an OS X system to install the iOS Demo App (WiFIIntroducer) onto an iOS device. The files are located at <WICED_SDK>/apps/demo/ble_wifi_introducer/peerapps/iOS
  2. Compile and download the ble_wifi_introducer app onto a WICED device using the target "demo.ble_wifi_introducer-<platform> download run"
  3. Open a terminal to view the output. Since WiFi network credentials were not edited in the wifi_config_dct, the connection will fail and the BLE GATT server will start advertising. You should see output similar to the following,
  4. On the iOS device, connect to the WiFi AP that you want the WICED device to connect to. Open the WiFiIntroducer application and you should be greeted with the following splash screen,
  5. The app will scan until a nearby WICED device is detected. Bring the WICED device close to the iOS device and the following screen will be brought up
    Note: If the iOS app does not detect the WICED device, kill and reopen the iOS application

  6. Enter the WiFi AP passphrase and press connect. You will be prompted to pair the device. Select "Pair" and a secure LE connection will be made between the iOS device and the WICED device using the ECDH algorithm to generate and exchange the secure keys.
    Note: If the device has been previously paired, it may be necessary to remove the pairing before the app will run correctly. Do this by going to Settings > Bluetooth. Under My Devices, click the "i" icon next to WiFiInt and select "Forget This Device"

  7. The WiFi network credentials will be sent to the WICED device and the connection result will be pushed back to the iOS device. If the connection fails, press "Try Again" to re-input the passphrase. Upon successful connection, the network credentials will be saved to the DCT.
  8. When rebooting the WICED device, since the DCT has configured Network credentials, the BLE GATT server will not be started. You can press the user button on the WICED board to reset the DCT. The device will reboot and the BLE GATT server will start advertising.

Filter Blog

By date:
By tag: