mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-13 07:26:52 +01:00
@@ -133,7 +133,7 @@
|
||||
|
||||
<sourceEntries>
|
||||
|
||||
<entry excluding="MQTTSNGateway/GatewayTester|MQTTSNClient|MQTTSNGateway/src/MQTTSNGWProxy.cpp|MQTTSNGateway/src/linux/udp6|MQTTSNPacket/test|MQTTSNPacket/samples|MQTTSNGateway/src/mainLogmonitor.cpp|MQTTSNGateway/src/linux/xbee|MQTTSNGateway/GatewayTester/samples/mainTemplate.cpp|MQTTSNGateway/src/tests|MQTTSNGateway/src/tests/mainTestProcessFramework.cpp|ClientPubQoS-1|MQTTSNGateway/GatewayTester/samples/mainOTA.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry excluding="MQTTSNGateway/src/linux/udp|MQTTSNGateway/GatewayTester|MQTTSNClient|MQTTSNGateway/src/MQTTSNGWProxy.cpp|MQTTSNPacket/test|MQTTSNPacket/samples|MQTTSNGateway/src/mainLogmonitor.cpp|MQTTSNGateway/src/linux/xbee|MQTTSNGateway/GatewayTester/samples/mainTemplate.cpp|MQTTSNGateway/src/tests|MQTTSNGateway/src/tests/mainTestProcessFramework.cpp|ClientPubQoS-1|MQTTSNGateway/GatewayTester/samples/mainOTA.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
|
||||
</sourceEntries>
|
||||
|
||||
@@ -277,7 +277,7 @@
|
||||
|
||||
<entry excluding="MQTTSNGWProxy.cpp|mainLogmonitor.cpp|tests|tests/mainTestProcessFramework.cpp|linux|linux/udp" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="MQTTSNGateway/src"/>
|
||||
|
||||
<entry excluding="xbee|udp6" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="MQTTSNGateway/src/linux"/>
|
||||
<entry excluding="udp|xbee" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="MQTTSNGateway/src/linux"/>
|
||||
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="MQTTSNPacket/src"/>
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#
|
||||
# Ex:
|
||||
# #Client List
|
||||
# ClientId1,192.168.10.10:11200@
|
||||
# ClientId1,192.168.10.10:11200
|
||||
# ClientID2,192.168.50.200:35000,unstableLine
|
||||
# ClientID3,192.168.200.50:40000,secureConnection
|
||||
# ClientID4,192.168.200.52:41000,unstableLine,secureConnection
|
||||
|
||||
@@ -65,24 +65,52 @@ void SensorNetAddress::setAddress(struct sockaddr_in6 *IpAddr, uint16_t port)
|
||||
|
||||
/**
|
||||
* convert Text data to SensorNetAddress
|
||||
* @param buf is pointer of IP_Address:PortNo format text
|
||||
* @param data is a IP_Address:PortNo format string
|
||||
* @return success = 0, Invalid format = -1
|
||||
*/
|
||||
int SensorNetAddress::setAddress(string* data)
|
||||
{
|
||||
const char *cstr = data->c_str();
|
||||
inet_pton(AF_INET6, cstr, &(_IpAddr.sin6_addr));
|
||||
return 0;
|
||||
|
||||
size_t pos = data->find_last_of(":");
|
||||
|
||||
if ( pos != string::npos)
|
||||
{
|
||||
int portNo = 0;
|
||||
string port = data->substr(pos + 1);
|
||||
|
||||
if ( ( portNo = atoi(port.c_str()) ) > 0 )
|
||||
{
|
||||
_portNo = htons(portNo);
|
||||
|
||||
string ip = data->substr(1,pos - 1);
|
||||
const char *cstr = ip.c_str();
|
||||
|
||||
if (inet_pton(AF_INET6, cstr, &(_IpAddr.sin6_addr)) == 1 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
_portNo = 0;
|
||||
memset((void *)&_IpAddr,0,sizeof(_IpAddr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert Text data to SensorNetAddress
|
||||
* @param buf is pointer of IP_Address:PortNo format text
|
||||
* @param data is pointer of IP_Address format text
|
||||
* @return success = 0, Invalid format = -1
|
||||
*/
|
||||
int SensorNetAddress::setAddress(const char* data)
|
||||
{
|
||||
inet_pton(AF_INET6, data, &(_IpAddr.sin6_addr));
|
||||
return 0;
|
||||
if ( inet_pton(AF_INET6, data, &(_IpAddr.sin6_addr)) == 1 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
char* SensorNetAddress::getAddress(void)
|
||||
|
||||
Reference in New Issue
Block a user