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: C027 C12832 EthernetInterface StatusReporter LM75B MQTT-ansond endpoint_core endpoint_mqtt mbed-rtos mbed
Diff: MQTTTransport.cpp
- Revision:
- 23:793b2898522e
- Parent:
- 22:f1002e5993c5
- Child:
- 30:5c670ec5d203
--- a/MQTTTransport.cpp Thu Feb 27 23:33:24 2014 +0000
+++ b/MQTTTransport.cpp Fri Feb 28 02:52:04 2014 +0000
@@ -72,7 +72,18 @@
vector<string> data = tmp->split('/');
if (data.size() > 0) {
char *ep = (char *)data[data.size()-1].c_str();
- if (ep != NULL) strncpy(this->m_endpoint_name,ep,strlen(ep));
+ if (ep != NULL) {
+ if (strcmp(ep,"control") != 0) {
+ // just insert the name and let the parser determine if its for us or not...
+ strncpy(this->m_endpoint_name,ep,strlen(ep));
+ }
+ else {
+ // this is a broadcast message - so we need to process it
+ MBEDEndpoint *endpoint = (MBEDEndpoint *)this->getEndpoint();
+ char *endpoint_name = endpoint->getEndpointName();
+ strcpy(this->m_endpoint_name,endpoint_name);
+ }
+ }
}
if (tmp != NULL) delete tmp;
return this->m_endpoint_name;
@@ -83,8 +94,7 @@
char *message_type = "";
char *message_verb = "";
char *message_value = "";
- //char *message_opt = "";
-
+
// get our endpoint
MBEDEndpoint *endpoint = (MBEDEndpoint *)this->getEndpoint();
char *endpoint_name = endpoint->getEndpointName();
@@ -100,7 +110,6 @@
if (data.size() > 0) message_type = (char *)data[0].c_str();
if (data.size() > 1) message_verb = (char *)data[1].c_str();
if (data.size() > 2) message_value = (char *)data[2].c_str();
- //if (data.size() > 3) message_opt = (char *)data[3].c_str();
// DEBUG
//this->logger()->log("Raw Payload: %s",payload);
@@ -111,7 +120,6 @@
if (message_verb != NULL && strcmp(message_verb,IOC_REQUEST_LOAD_ALL_VERB) == 0) { // load
if (message_value != NULL && strcmp(message_value,IOC_ENDPOINT_ALL_VERB) == 0) { // all
// load up our endpoints
- this->logger()->log("would load all endpoints...");
endpoint->loadEndpoints();
}
}
@@ -119,8 +127,7 @@
else if (message_verb != NULL && strcmp(message_verb,IOC_REQUEST_UPDATE_ALL_VERB) == 0) { // update
if (message_value != NULL && strcmp(message_value,IOC_ENDPOINT_ALL_VERB) == 0) { // all
// update our endpoints
- this->logger()->log("would update all endpoints...");
- //endpoint->updateEndpoints();
+ endpoint->updateEndpoints();
}
else {
// update just our endpoint
@@ -130,8 +137,7 @@
if (index >= 0) {
if (message_verb != NULL && strcmp(message_verb,IOC_REQUEST_UPDATE_ALL_VERB) == 0) {
// update our endpoint
- this->logger()->log("would update just our endpoint...");
- //endpoint->updateEndpoints(index);
+ endpoint->updateEndpoints(index);
}
}
}