mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-16 17:06:51 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07a95121fc | ||
|
|
59797127e7 | ||
|
|
27b5c7623e | ||
|
|
4508461fc1 | ||
|
|
b5f2fd655d | ||
|
|
c4e2ac4026 | ||
|
|
273c71774b | ||
|
|
135e79e4da | ||
|
|
debc21760b | ||
|
|
59fd3ec598 |
@@ -5,7 +5,7 @@
|
|||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-190494363728860458" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-176156747064280842" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-190493586662438402" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-176157551606184930" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|||||||
@@ -78,13 +78,13 @@ RFCOMMCONF = { "GatewayTestClient", // ClientId
|
|||||||
/*------------------------------------------------------
|
/*------------------------------------------------------
|
||||||
* Client Configuration (theMqcon)
|
* Client Configuration (theMqcon)
|
||||||
*------------------------------------------------------*/
|
*------------------------------------------------------*/
|
||||||
MQTTSNCONF = { 60, //KeepAlive [seconds]
|
MQTTSNCONF = { 60, //KeepAlive [seconds]
|
||||||
true, //Clean session
|
true, //Clean session
|
||||||
300, //Sleep duration [seconds]
|
300, //Sleep duration [seconds]
|
||||||
"willtopic", //WillTopic
|
"", //WillTopic
|
||||||
"willmsg", //WillMessage
|
"", //WillMessage
|
||||||
0, //WillQos
|
0, //WillQos
|
||||||
false //WillRetain
|
false //WillRetain
|
||||||
};
|
};
|
||||||
|
|
||||||
/*------------------------------------------------------
|
/*------------------------------------------------------
|
||||||
|
|||||||
@@ -69,17 +69,17 @@ BrokerSecurePortNo=8883
|
|||||||
**BrokerSecurePortNo** is a broker's port no of TLS connection.
|
**BrokerSecurePortNo** is a broker's port no of TLS connection.
|
||||||
```
|
```
|
||||||
#
|
#
|
||||||
# CertsKey for TLS connections to a broker
|
# CertKey for TLS connections to a broker
|
||||||
#
|
#
|
||||||
|
|
||||||
#RootCAfile=/etc/ssl/certs/ca-certificates.crt
|
#RootCAfile=/etc/ssl/certs/ca-certificates.crt
|
||||||
#RootCApath=/etc/ssl/certs/
|
#RootCApath=/etc/ssl/certs/
|
||||||
#CertsKey=/path/to/certKey.pem
|
#CertKey=/path/to/certKey.pem
|
||||||
#PrivateKey=/path/to/privateKey.pem
|
#PrivateKey=/path/to/privateKey.pem
|
||||||
```
|
```
|
||||||
**RootCAfile** is a CA file name.
|
**RootCAfile** is a CA file name.
|
||||||
**RootCApath** is a CA path. **SSL_CTX_load_verify_locations(ctx, CAfile, CApath)** function requires these parameters.
|
**RootCApath** is a CA path. **SSL_CTX_load_verify_locations(ctx, CAfile, CApath)** function requires these parameters.
|
||||||
**CertsKey** is a certificate pem file.
|
**CertKey** is a certificate pem file.
|
||||||
**PrivateKey** is a private key pem file.
|
**PrivateKey** is a private key pem file.
|
||||||
Clients can connect to the broker via TLS by setting '**Secure Connection**' for each client in the client conf file.
|
Clients can connect to the broker via TLS by setting '**Secure Connection**' for each client in the client conf file.
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
WORK_DIR=$(realpath $(dirname "$0")/..)
|
||||||
|
BDIR=build.gateway
|
||||||
|
ODIR=bin/
|
||||||
|
|
||||||
build () {
|
build () {
|
||||||
echo "Start building MQTT-SN Gateway $1"
|
echo "Start building MQTT-SN Gateway $1"
|
||||||
|
|
||||||
cd $SCRIPT_DIR/..
|
pushd "$WORK_DIR"
|
||||||
BDIR='build.gateway'
|
|
||||||
if [ ! -d ./$BDIR ]; then
|
if [ ! -d ./$BDIR ]; then
|
||||||
mkdir $BDIR
|
mkdir $BDIR
|
||||||
fi
|
fi
|
||||||
@@ -13,12 +16,10 @@ build () {
|
|||||||
make MQTTSNPacket
|
make MQTTSNPacket
|
||||||
make MQTT-SNGateway
|
make MQTT-SNGateway
|
||||||
make MQTT-SNLogmonitor
|
make MQTT-SNLogmonitor
|
||||||
cd ../MQTTSNGateway
|
popd
|
||||||
cp *.conf ./bin/
|
cp *.conf ./$ODIR
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_DIR=$(cd $(dirname $0); pwd)
|
|
||||||
|
|
||||||
if [ $1 == "udp" ] ; then
|
if [ $1 == "udp" ] ; then
|
||||||
build $1 $2 $3
|
build $1 $2 $3
|
||||||
elif [ $1 == "udp6" ] ; then
|
elif [ $1 == "udp6" ] ; then
|
||||||
@@ -34,7 +35,10 @@ elif [ $1 == "dtls" ] ; then
|
|||||||
elif [ $1 == "dtls6" ] ; then
|
elif [ $1 == "dtls6" ] ; then
|
||||||
build dtls "${2} ${3} -DDTLS6"
|
build dtls "${2} ${3} -DDTLS6"
|
||||||
elif [ $1 == "clean" ] ; then
|
elif [ $1 == "clean" ] ; then
|
||||||
rm -rf ../builg.gateway
|
pushd "$WORK_DIR"
|
||||||
|
rm -rf ./$BDIR
|
||||||
|
popd
|
||||||
|
rm -rf ./$ODIR
|
||||||
else
|
else
|
||||||
echo "Usage: build.sh [ udp | udp6 | xbee | loralink | rfcomm | dtls | dtls6 | clean]"
|
echo "Usage: build.sh [ udp | udp6 | xbee | loralink | rfcomm | dtls | dtls6 | clean]"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ BrokerSecurePortNo=8883
|
|||||||
|
|
||||||
#RootCAfile=/etc/ssl/certs/ca-certificates.crt
|
#RootCAfile=/etc/ssl/certs/ca-certificates.crt
|
||||||
#RootCApath=/etc/ssl/certs/
|
#RootCApath=/etc/ssl/certs/
|
||||||
#CertsKey=/path/to/certKey.pem
|
#CertKey=/path/to/certKey.pem
|
||||||
#PrivateKey=/path/to/privateKey.pem
|
#PrivateKey=/path/to/privateKey.pem
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ char* currentDateTime(void);
|
|||||||
static const char* theClientStatus[] = { "InPool", "Disconnected", "TryConnecting", "Connecting", "Active", "Asleep", "Awake",
|
static const char* theClientStatus[] = { "InPool", "Disconnected", "TryConnecting", "Connecting", "Active", "Asleep", "Awake",
|
||||||
"Lost" };
|
"Lost" };
|
||||||
|
|
||||||
Client::Client(bool secure)
|
Client::Client()
|
||||||
{
|
{
|
||||||
_packetId = 0;
|
_packetId = 0;
|
||||||
_snMsgId = 0;
|
_snMsgId = 0;
|
||||||
@@ -45,8 +45,7 @@ Client::Client(bool secure)
|
|||||||
_willTopic = nullptr;
|
_willTopic = nullptr;
|
||||||
_willMsg = nullptr;
|
_willMsg = nullptr;
|
||||||
_connectData = MQTTPacket_Connect_Initializer;
|
_connectData = MQTTPacket_Connect_Initializer;
|
||||||
_network = new Network(secure);
|
_network = new Network();
|
||||||
_secureNetwork = secure;
|
|
||||||
_sensorNetype = true;
|
_sensorNetype = true;
|
||||||
_connAck = nullptr;
|
_connAck = nullptr;
|
||||||
_waitWillMsgFlg = false;
|
_waitWillMsgFlg = false;
|
||||||
@@ -426,7 +425,7 @@ bool Client::isConnecting(void)
|
|||||||
|
|
||||||
bool Client::isSecureNetwork(void)
|
bool Client::isSecureNetwork(void)
|
||||||
{
|
{
|
||||||
return _secureNetwork;
|
return _network->isSecure();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::isSensorNetStable(void)
|
bool Client::isSensorNetStable(void)
|
||||||
|
|||||||
@@ -179,8 +179,7 @@ class Client
|
|||||||
friend class ClientList;
|
friend class ClientList;
|
||||||
friend class ClientsPool;
|
friend class ClientsPool;
|
||||||
public:
|
public:
|
||||||
Client(bool secure = false);
|
Client();
|
||||||
Client(uint8_t maxInflightMessages, bool secure);
|
|
||||||
~Client();
|
~Client();
|
||||||
|
|
||||||
Connect* getConnectData(void);
|
Connect* getConnectData(void);
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ void ClientRecvTask::run()
|
|||||||
{
|
{
|
||||||
log(client, packet, 0);
|
log(client, packet, 0);
|
||||||
|
|
||||||
if (client->isDisconnect() && packet->getType() != MQTTSN_CONNECT && packet->getType() != MQTTSN_WILLTOPIC && packet->getType() != MQTTSN_WILLMSG)
|
if (client->isDisconnect() && packet->getType() != MQTTSN_CONNECT)
|
||||||
{
|
{
|
||||||
WRITELOG("%s MQTTSNGWClientRecvTask %s is not connecting.%s\n",
|
WRITELOG("%s MQTTSNGWClientRecvTask %s is not connecting.%s\n",
|
||||||
ERRMSG_HEADER, client->getClientId(), ERRMSG_FOOTER);
|
ERRMSG_HEADER, client->getClientId(), ERRMSG_FOOTER);
|
||||||
|
|||||||
@@ -17,6 +17,6 @@
|
|||||||
#ifndef MQTTSNGWVERSION_H_IN_
|
#ifndef MQTTSNGWVERSION_H_IN_
|
||||||
#define MQTTSNGWVERSION_H_IN_
|
#define MQTTSNGWVERSION_H_IN_
|
||||||
|
|
||||||
#define PAHO_GATEWAY_VERSION "1.6.0"
|
#define PAHO_GATEWAY_VERSION "1.5.1"
|
||||||
|
|
||||||
#endif /* MQTTSNGWVERSION_H_IN_ */
|
#endif /* MQTTSNGWVERSION_H_IN_ */
|
||||||
|
|||||||
@@ -238,11 +238,11 @@ int Network::_numOfInstance = 0;
|
|||||||
SSL_CTX* Network::_ctx = 0;
|
SSL_CTX* Network::_ctx = 0;
|
||||||
SSL_SESSION* Network::_session = 0;
|
SSL_SESSION* Network::_session = 0;
|
||||||
|
|
||||||
Network::Network(bool secure) :
|
Network::Network() :
|
||||||
TCPStack()
|
TCPStack()
|
||||||
{
|
{
|
||||||
_ssl = 0;
|
_ssl = 0;
|
||||||
_secureFlg = secure;
|
_secureFlg = false;
|
||||||
_busy = false;
|
_busy = false;
|
||||||
_sslValid = false;
|
_sslValid = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ private:
|
|||||||
class Network: public TCPStack
|
class Network: public TCPStack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Network(bool secure);
|
Network();
|
||||||
virtual ~Network();
|
virtual ~Network();
|
||||||
|
|
||||||
bool connect(const char* host, const char* port, const char* caPath, const char* caFile, const char* cert, const char* prvkey);
|
bool connect(const char* host, const char* port, const char* caPath, const char* caFile, const char* cert, const char* prvkey);
|
||||||
|
|||||||
@@ -416,12 +416,24 @@ int UDPPort6::unicast(const uint8_t* buf, uint32_t length, SensorNetAddress* add
|
|||||||
|
|
||||||
int UDPPort6::broadcast(const uint8_t* buf, uint32_t length)
|
int UDPPort6::broadcast(const uint8_t* buf, uint32_t length)
|
||||||
{
|
{
|
||||||
int err = unicast(buf, length, &_grpAddr);
|
sockaddr_in6 dest;
|
||||||
|
memset(&dest, 0, sizeof(dest));
|
||||||
|
dest.sin6_family = AF_INET6;
|
||||||
|
dest.sin6_port = _grpAddr.getPortNo();
|
||||||
|
memcpy(dest.sin6_addr.s6_addr, (const void*) &_grpAddr.getIpAddress()->sin6_addr, sizeof(in6_addr));
|
||||||
|
|
||||||
if (err < 0)
|
#ifdef DEBUG_NW
|
||||||
|
char addrBuf[INET6_ADDRSTRLEN];
|
||||||
|
addr->sprint(addrBuf);
|
||||||
|
D_NWSTACK("sendto %s\n", addrBuf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int status = ::sendto(_pollfds[1].fd, buf, length, 0, (const sockaddr*) &dest, sizeof(dest));
|
||||||
|
|
||||||
|
if (status < 0)
|
||||||
{
|
{
|
||||||
D_NWSTACK("UDP6::broadcast - sendto: %s", strerror(errno));
|
D_NWSTACK("UDP6::broadcast - sendto: %s", strerror(errno));
|
||||||
return err;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user