Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: WIFI_API_32kRAM mbed
main.cpp
00001 #include "mbed.h" 00002 #include "MXmppClient.hpp" 00003 #include "WIFIDevice.h" 00004 00005 #define SSID "SSID" 00006 #define AP_PASSWORD "0123456789" 00007 00008 #define USER_NAME1 "nnn40b" 00009 #define DOMAIN "xmpp.koryo.com.tw" 00010 #define PASSWORD1 "123456" 00011 00012 #define USER_NAME2 "app2" 00013 00014 WIFIDevice wifi; 00015 MxmppClient mXmppClient(USER_NAME1,DOMAIN,PASSWORD1,5222); 00016 void onGetMessage(const char*); 00017 00018 DigitalOut led1(p7); 00019 DigitalOut led2(p13); 00020 00021 int main(void) 00022 { 00023 //set given SSID and PW as the highest priority 00024 wifi.setNetwork(SSID, AP_PASSWORD, 0); 00025 00026 mXmppClient.login(); 00027 if(mXmppClient.isLogin()) { 00028 mXmppClient.sendMessageToClient(USER_NAME2,"Login to XMPP server"); 00029 } 00030 while(true) { 00031 mXmppClient.setMessageTracker(onGetMessage); 00032 } 00033 } 00034 00035 void onGetMessage(const char *msg) 00036 { 00037 if(strcmp(msg,"turn on")==0) { 00038 mXmppClient.sendMessageToClient(USER_NAME2,"The lights is on"); 00039 led1=1; 00040 led2=1; 00041 } else if(strcmp(msg,"turn off")==0) { 00042 mXmppClient.sendMessageToClient(USER_NAME2,"The lights is off"); 00043 led1=0; 00044 led2=0; 00045 } 00046 }
Generated on Tue Jul 12 2022 22:56:04 by
1.7.2