IBM IoT Client WiFi example using Murata Type-YD WiFi module

Dependencies:   C12832_fix LM75B MMA7660 MQTT PowerControl SNICInterface mbed-rtos mbed

Fork of IBMIoTClientEthernetExample by Toyomasa Watarai

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MQTTWiFi_SNIC.h Source File

MQTTWiFi_SNIC.h

00001 
00002 #if !defined(MQTTWIFI_H)
00003 #define MQTTWIFI_H
00004 
00005 #include "MQTTmbed.h"
00006 #include "SNIC_WifiInterface.h"
00007 #include "MQTTSocket.h"
00008 #include "WiFi_Config.h"
00009 
00010 class MQTTWifi : public MQTTSocket
00011 {
00012 public:
00013     MQTTWifi()
00014     {
00015         wifi.create(WIFI_TX, WIFI_RX, WIFI_CTS, WIFI_RTS, WIFI_RESET);
00016         wifi.init();
00017         wait(0.5);
00018         wifi.disconnect();
00019         wait(0.3);
00020         wifi.connect( DEMO_AP_SSID
00021                     , strlen(DEMO_AP_SSID)
00022                     , DEMO_AP_SECURITY_TYPE
00023                     , DEMO_AP_SECUTIRY_KEY
00024                     , strlen(DEMO_AP_SECUTIRY_KEY) );
00025         wait(0.5);
00026         wifi.setIPConfig(true);
00027     }
00028     
00029     C_SNIC_WifiInterface& getEth()
00030     {
00031         return wifi;
00032     }
00033     
00034     void reconnect()
00035     {
00036         wifi.init();
00037         wait(0.5);
00038         wifi.disconnect();
00039         wait(0.3);
00040         wifi.connect( DEMO_AP_SSID
00041                     , strlen(DEMO_AP_SSID)
00042                     , DEMO_AP_SECURITY_TYPE
00043                     , DEMO_AP_SECUTIRY_KEY
00044                     , strlen(DEMO_AP_SECUTIRY_KEY) );
00045         wait(0.5);
00046         wifi.setIPConfig(true);
00047     }
00048 
00049 private:
00050     C_SNIC_WifiInterface wifi;
00051 };
00052 
00053 #endif