Connect through Wifi to IBM MQTT cloud https://quickstart.internetofthings.ibmcloud.com

Dependencies:   MQTT NetworkSocketAPI X_NUCLEO_IDW01M1v2 X_NUCLEO_IKS01A1 mbed NDefLib X_NUCLEO_NFC01A1

Fork of IDW01M1_Cloud_IBM by ST Expansion SW Team

To start the demo the following expansion boards are required

X_NUCLEO_IDW01M1v2, X_NUCLEO_IKS01A1, X_NUCLEO_NFC01A1

After having mounted the board stack on the Nucleo board the below steps should be followed:

  • Program in the application source code you local WiFi SSID and password and flash the binary. Make sure the Wifi network has visible SSID.
  • Reset the Nucleo board and after few seconds the Nucleo green led will be on (it means the Nucleo is connected to the local Wifi and to the IBM cloud server)
  • Read the NFC tag with an Android device and the browser will be automatically opened and directed to the specific brocker IBM demo page where the environmental values are displayed in form of a x-y graph. The values are updated every few seconds. On the Hyperterminal is possible to see the values sent to the IBM cloud server and the board mac address to be entered on the IBM quickstart web page if a manual connection is needed (eg. to connect from a PC browser).
Committer:
mridup
Date:
Thu Apr 14 06:20:36 2016 +0000
Revision:
3:dfb8c6c8c31b
Parent:
2:ba0531d896f0
Child:
4:1ed7f173eec5
change in main

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mridup 2:ba0531d896f0 1 /* NetworkSocketAPI Example Program
mridup 2:ba0531d896f0 2 * Copyright (c) 2015 ARM Limited
mridup 2:ba0531d896f0 3 *
mridup 2:ba0531d896f0 4 * Licensed under the Apache License, Version 2.0 (the "License");
mridup 2:ba0531d896f0 5 * you may not use this file except in compliance with the License.
mridup 2:ba0531d896f0 6 * You may obtain a copy of the License at
mridup 2:ba0531d896f0 7 *
mridup 2:ba0531d896f0 8 * http://www.apache.org/licenses/LICENSE-2.0
mridup 2:ba0531d896f0 9 *
mridup 2:ba0531d896f0 10 * Unless required by applicable law or agreed to in writing, software
mridup 2:ba0531d896f0 11 * distributed under the License is distributed on an "AS IS" BASIS,
mridup 2:ba0531d896f0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mridup 2:ba0531d896f0 13 * See the License for the specific language governing permissions and
mridup 2:ba0531d896f0 14 * limitations under the License.
mridup 2:ba0531d896f0 15 */
mridup 2:ba0531d896f0 16
mridup 0:cbf8bc43bc9e 17 #include "mbed.h"
mridup 0:cbf8bc43bc9e 18 #include "SPWFInterface.h"
mridup 2:ba0531d896f0 19 #include "NSAPITests.h"
mridup 0:cbf8bc43bc9e 20
mridup 0:cbf8bc43bc9e 21 //------------------------------------
mridup 0:cbf8bc43bc9e 22 // Hyperterminal configuration
mridup 0:cbf8bc43bc9e 23 // 9600 bauds, 8-bit data, no parity
mridup 0:cbf8bc43bc9e 24 //------------------------------------
mridup 0:cbf8bc43bc9e 25
mridup 0:cbf8bc43bc9e 26 Serial pc(SERIAL_TX, SERIAL_RX);
mridup 3:dfb8c6c8c31b 27 DigitalOut myled(LED1);
mridup 0:cbf8bc43bc9e 28 SpwfSAInterface *spwf;
mridup 2:ba0531d896f0 29
mridup 2:ba0531d896f0 30 int main()
mridup 2:ba0531d896f0 31 {
mridup 2:ba0531d896f0 32 int32_t err;
mridup 0:cbf8bc43bc9e 33 char * ssid = "STM";
mridup 0:cbf8bc43bc9e 34 char * seckey = "STMdemoPWD";
mridup 2:ba0531d896f0 35
mridup 3:dfb8c6c8c31b 36 pc.printf("\r\nSpwf Interface NSAPI Tests\r\n");
mridup 3:dfb8c6c8c31b 37
mridup 0:cbf8bc43bc9e 38 spwf = createSPWFInstance();
mridup 0:cbf8bc43bc9e 39 err = spwf->init();
mridup 0:cbf8bc43bc9e 40 if(err!=0)
mridup 0:cbf8bc43bc9e 41 {
mridup 2:ba0531d896f0 42 pc.printf("\r\nerror initializing.\r\n");
mridup 0:cbf8bc43bc9e 43 return -1;
mridup 0:cbf8bc43bc9e 44 }
mridup 3:dfb8c6c8c31b 45
mridup 2:ba0531d896f0 46 pc.printf("\r\nconnecting to AP\r\n");
mridup 0:cbf8bc43bc9e 47
mridup 2:ba0531d896f0 48 err = spwf->connect(ssid, seckey, NS_SECURITY_WPA);
mridup 2:ba0531d896f0 49
mridup 2:ba0531d896f0 50 if (err) {
mridup 2:ba0531d896f0 51 printf("Interface failed to connect with code %d\r\n", err);
mridup 2:ba0531d896f0 52 } else {
mridup 2:ba0531d896f0 53 nsapi_tests("SPWF Tests", spwf, "192.168.1.5", 32001);
mridup 2:ba0531d896f0 54 spwf->disconnect();
mridup 0:cbf8bc43bc9e 55 }
mridup 3:dfb8c6c8c31b 56
mridup 3:dfb8c6c8c31b 57 while(1)
mridup 3:dfb8c6c8c31b 58 {
mridup 3:dfb8c6c8c31b 59 wait(1);
mridup 3:dfb8c6c8c31b 60 myled = !myled;
mridup 3:dfb8c6c8c31b 61 }
mridup 2:ba0531d896f0 62 }