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:
- 48:d3663434128d
- Parent:
- 36:210f3956038c
- Child:
- 69:090e16acccb7
diff -r 081874a5d049 -r d3663434128d MQTTTransport.cpp
--- a/MQTTTransport.cpp Sat Mar 01 17:16:17 2014 +0000
+++ b/MQTTTransport.cpp Sat Mar 01 19:23:50 2014 +0000
@@ -67,26 +67,29 @@
// pull the endpoint name from the MQTT topic
char *MQTTTransport::getEndpointNameFromTopic(char *topic) {
- memset(this->m_endpoint_name,0,LIGHT_NAME_LEN+1);
- splitstring *tmp = new splitstring(topic);
- vector<string> data = tmp->split('/');
- if (data.size() > 0) {
- char *ep = (char *)data[data.size()-1].c_str();
- if (ep != NULL) {
- if (strcmp(ep,MQTT_IOC_ALL_ENDPOINT) != 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;
+ if (topic != NULL) {
+ memset(this->m_endpoint_name,0,LIGHT_NAME_LEN+1);
+ splitstring *tmp = new splitstring(topic);
+ vector<string> data = tmp->split('/');
+ if (data.size() > 0) {
+ char *ep = (char *)data[data.size()-1].c_str();
+ if (ep != NULL) {
+ if (strcmp(ep,MQTT_IOC_ALL_ENDPOINT) != 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;
+ }
+ return NULL;
}
// process a MQTT Message