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
Revision 0:464110a4a6f1, committed 2015-09-15
- Comitter:
- lester0507
- Date:
- Tue Sep 15 01:26:54 2015 +0000
- Child:
- 1:1571d6a1cb27
- Commit message:
- first commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MXmppClient/MXmppClient.hpp Tue Sep 15 01:26:54 2015 +0000
@@ -0,0 +1,198 @@
+/* Copyright (c) Cyntec Inc. All Rights Reserved.*/
+
+#ifndef XMPPCLIENT_H
+#define XMPPCLIENT_H
+
+#include <string>
+#include "EthernetInterface.h"
+
+/** XMPPClient class.
+ used for linking XMPP server(above Openfire3.9.3).
+
+ Example:
+ @code
+
+ WIFIDevice wifi;
+ XMPPClient xmppClient("delta_nnn40_mod1","85.93.10.5","lester",5222);
+ void on_get_mesage(const char*);
+ DigitalOut led1(p0);
+
+ int main(void)
+ {
+ wifi.setNetwork("delta_ap", "password", 0); // set given SSID and PW as the highest priority
+ xmppClient.login();
+ while(true) {
+ xmppClient.set_message_tracker(on_get_mesage);
+ }
+ }
+
+ void on_get_mesage(const char *msg)
+ {
+ if(strcmp(msg,"turn on")==0) {
+ xmppClient.send_message_to_client("delta_nnn40_android1","the led1 is already turned on");
+ led1=1;
+ } else if(strcmp(msg,"turn off")==0) {
+ xmppClient.send_message_to_client("delta_nnn40_android1","the led1 is already turned off");
+ led1=0;
+ }
+ }
+
+ @endcode
+*/
+
+class MxmppClient
+{
+
+private:
+
+ EthernetInterface eth;
+ TCPSocketConnection socket;
+
+ char *userName;
+ char *domain;
+ char *resource;
+ char *password;
+ int port;
+ char serverName[128];
+
+ bool bLogin;
+
+public:
+
+ /** Create XMPPClient instance*/
+
+ MxmppClient();
+
+ /** Create XMPPClient instance
+ * @param user_name The username is for login XMPP server.
+ * @param domain The domain is for server domain.
+ * @param pwd The password is for login XMPP server.
+ * @param port The port is XMPP server listen port.
+ */
+
+ MxmppClient(const char *userName,const char *domain,const char *pwd,const int port=5222);
+
+ /** Set user name which is for login XMPP server.
+ * @param name The name is XMPP server account name.
+ */
+
+ void setUserName(const char *name);
+
+ /** Set domain which is server domain.
+ * @param domain The domain is XMPP server domain.
+ */
+
+ void setDomain(const char *domain);
+
+ /** Set password which is for XMPP server login.
+ * @param pwd The password is for XMPP server account.
+ */
+
+ void setPassword(const char *pwd);
+
+ /** Set port which is for server connection.
+ * @param port The port is XMPP server listen port.
+ */
+
+ void setPort(const int num);
+
+ /** Get user name.
+ * @returns
+ * user name
+ */
+
+ const char *getUserName();
+
+ /** Get domain.
+ * @returns
+ * domain
+ */
+
+ const char *getDomain();
+
+ /** Get password.
+ * @returns
+ * password
+ */
+
+ const char *getPassword();
+
+ /** Get port.
+ * @returns
+ * connection port
+ */
+
+ const int getPort();
+
+ /** have fill user name?
+ * @returns
+ * true, have use name,
+ * false, no use name
+ */
+
+ bool haveUserName();
+
+ /** have fill domain?
+ * @returns
+ * true, have domain;
+ * false, no domain
+ */
+
+ bool haveDomain();
+
+ /** have fill password?
+ * @returns
+ * true, have password;
+ * false, no password
+ */
+
+ bool havePassword();
+
+ /** have fill port?
+ * @returns
+ * true, have connection port;
+ * false, no connection port
+ */
+
+ bool havePort();
+
+ /** have connect data which include username, domain, password and connect port?
+ * @returns
+ * true, have connection data;
+ * false, no connection data
+ */
+
+ bool haveConnectData();
+
+ /** Is login to XMPP server?
+ * @returns
+ * true, is already logged XMPP server;
+ * false, is not yet logged XMPP server.
+ */
+
+ bool isLogin();
+
+ /** login XMPP server, module will connect to XMPP server and execute login processes.*/
+
+ void login();
+
+ /** logout XMPP server, module will connect to XMPP server and execute logout processes.*/
+
+ void logout();
+
+ /** send message to other client
+ * @param client client name,
+ * @param chat_msg the sent message.
+ */
+
+ void sendMessageToClient(char *client,char* chatMsg);
+
+ /** set chat message listener
+ * @param on_get_mesage callback function.
+ */
+
+ void setMessageTracker(void (*onGetMessage)(const char *msg));
+
+};
+
+#endif // XMPPCLIENT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MXmppClient/base64codec.h Tue Sep 15 01:26:54 2015 +0000 @@ -0,0 +1,7 @@ +#ifndef BASE64CODEC_H +#define BASE64CODEC_H +#include <string.h> + +int base64_encode(unsigned char *source,size_t sourcelen, char *target, size_t targetlen); + +#endif // BASE64CODEC_H
Binary file MXmppClient/base64codec.o has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MXmppClient/mstring.h Tue Sep 15 01:26:54 2015 +0000 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2010 Hendrik Lipka +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#ifndef MSTRING_H +#define MSTRING_H + +char *strdup (const char *str); + +#endif
Binary file MXmppClient/mstring.o has changed
Binary file MXmppClient/mxmppclient.o has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WIFI_API_32kRAM.lib Tue Sep 15 01:26:54 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Delta/code/WIFI_API_32kRAM/#4672c7f4ef2a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Sep 15 01:26:54 2015 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "MXmppClient.hpp"
+#include "WIFIDevice.h"
+
+#define SSID "SSID"
+#define AP_PASSWORD "0123456789"
+
+#define USER_NAME1 "name1"
+#define DOMAIN "192.168.0.1"
+#define PASSWORD1 "password1"
+
+#define USER_NAME2 "name2"
+
+WIFIDevice wifi;
+MxmppClient mXmppClient(USER_NAME1,DOMAIN,PASSWORD1,5222);
+void onGetMessage(const char*);
+
+DigitalOut led1(p7);
+
+int main(void)
+{
+ //set given SSID and PW as the highest priority
+ wifi.setNetwork(SSID, AP_PASSWORD, 0);
+
+ mXmppClient.login();
+ if(mXmppClient.isLogin()) {
+ mXmppClient.sendMessageToClient(USER_NAME2,"Login to XMPP server");
+ }
+ while(true) {
+ mXmppClient.setMessageTracker(onGetMessage);
+ }
+}
+
+void onGetMessage(const char *msg)
+{
+ if(strcmp(msg,"turn on")==0) {
+ mXmppClient.sendMessageToClient(USER_NAME2,"The lights is on");
+ led1=1;
+ } else if(strcmp(msg,"turn off")==0) {
+ mXmppClient.sendMessageToClient(USER_NAME2,"The lights is off");
+ led1=0;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-src.lib Tue Sep 15 01:26:54 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-src/#9c82b0f79f3d