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
MxmppClient Class Reference
XMPPClient class. More...
#include <MXmppClient.hpp>
Public Member Functions | |
| MxmppClient () | |
| Create XMPPClient instance. | |
| MxmppClient (const char *userName, const char *domain, const char *pwd, const int port=5222) | |
| Create XMPPClient instance. | |
| void | setUserName (const char *name) |
| Set user name which is for login XMPP server. | |
| void | setDomain (const char *domain) |
| Set domain which is server domain. | |
| void | setPassword (const char *pwd) |
| Set password which is for XMPP server login. | |
| void | setPort (const int num) |
| Set port which is for server connection. | |
| const char * | getUserName () |
| Get user name. | |
| const char * | getDomain () |
| Get domain. | |
| const char * | getPassword () |
| Get password. | |
| const int | getPort () |
| Get port. | |
| bool | haveUserName () |
| have fill user name? | |
| bool | haveDomain () |
| have fill domain? | |
| bool | havePassword () |
| have fill password? | |
| bool | havePort () |
| have fill port? | |
| bool | haveConnectData () |
| have connect data which include username, domain, password and connect port? | |
| bool | isLogin () |
| Is login to XMPP server? | |
| void | login () |
| login XMPP server, module will connect to XMPP server and execute login processes. | |
| void | logout () |
| logout XMPP server, module will connect to XMPP server and execute logout processes. | |
| void | sendMessageToClient (char *client, char *chatMsg) |
| send message to other client | |
| void | setMessageTracker (void(*onGetMessage)(const char *msg)) |
| set chat message listener | |
Detailed Description
XMPPClient class.
used for linking XMPP server(above Openfire3.9.3).
Example:
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;
}
}
Definition at line 43 of file MXmppClient.hpp.
Constructor & Destructor Documentation
| MxmppClient | ( | ) |
Create XMPPClient instance.
| MxmppClient | ( | const char * | userName, |
| const char * | domain, | ||
| const char * | pwd, | ||
| const int | port = 5222 |
||
| ) |
Create XMPPClient instance.
- Parameters:
-
user_name The username is for login XMPP server. domain The domain is for server domain. pwd The password is for login XMPP server. port The port is XMPP server listen port.
Member Function Documentation
| const char* getDomain | ( | ) |
Get domain.
- Returns:
- domain
| const char* getPassword | ( | ) |
Get password.
- Returns:
- password
| const int getPort | ( | ) |
Get port.
- Returns:
- connection port
| const char* getUserName | ( | ) |
Get user name.
- Returns:
- user name
| bool haveConnectData | ( | ) |
have connect data which include username, domain, password and connect port?
- Returns:
- true, have connection data; false, no connection data
| bool haveDomain | ( | ) |
have fill domain?
- Returns:
- true, have domain; false, no domain
| bool havePassword | ( | ) |
have fill password?
- Returns:
- true, have password; false, no password
| bool havePort | ( | ) |
have fill port?
- Returns:
- true, have connection port; false, no connection port
| bool haveUserName | ( | ) |
have fill user name?
- Returns:
- true, have use name, false, no use name
| bool isLogin | ( | ) |
Is login to XMPP server?
- Returns:
- true, is already logged XMPP server; false, is not yet logged XMPP server.
| void login | ( | ) |
login XMPP server, module will connect to XMPP server and execute login processes.
| void logout | ( | ) |
logout XMPP server, module will connect to XMPP server and execute logout processes.
| void sendMessageToClient | ( | char * | client, |
| char * | chatMsg | ||
| ) |
send message to other client
- Parameters:
-
client client name, chat_msg the sent message.
| void setDomain | ( | const char * | domain ) |
Set domain which is server domain.
- Parameters:
-
domain The domain is XMPP server domain.
| void setMessageTracker | ( | void(*)(const char *msg) | onGetMessage ) |
set chat message listener
- Parameters:
-
on_get_mesage callback function.
| void setPassword | ( | const char * | pwd ) |
Set password which is for XMPP server login.
- Parameters:
-
pwd The password is for XMPP server account.
| void setPort | ( | const int | num ) |
Set port which is for server connection.
- Parameters:
-
port The port is XMPP server listen port.
| void setUserName | ( | const char * | name ) |
Set user name which is for login XMPP server.
- Parameters:
-
name The name is XMPP server account name.
Generated on Tue Jul 12 2022 22:56:04 by
1.7.2