eclipse / paho.mqtt-sn.embedded-c

Paho C MQTT-SN gateway and libraries for embedded systems. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
315 stars 178 forks source link

NB-IoT - UDP -> MQTT-SN #153

Closed guydillen closed 5 years ago

guydillen commented 5 years ago

Hi,

I'm trying to use MQTT-SN gateway for my NB-IoT devices, although without success!

So, I first try with PacketSender sending UDP messages to the MQTT-SN gateway. I succeed, but the messages aren't forwarded to my (Mosquitto) MQTT broker. I already tried with different settings in the different config files (gateway, clients, ...).

Finally, however, as I mentioned I would like using the gateway for my NB-IoT devices.

Anyone maybe has some I'm missing or info on what to enter in the config files?

In the gateway.conf I have:

BrokerName=x.x.x.x
BrokerPortNo=1883
BrokerSecurePortNo=8883

#
# When AggregatingGateway=YES or ClientAuthentication=YES,
# All clients must be specified by the ClientList File  
#

#ClientAuthentication=NO
ClientAuthentication=YES
AggregatingGateway=NO
QoS-1=NO
Forwarder=NO

ClientsList=./clients.conf

PredefinedTopic=YES
PredefinedTopicList=./predefinedTopic.conf

#RootCAfile=/etc/ssl/certs/ca-certificates.crt
#RootCApath=/etc/ssl/certs/
#CertsFile=/path/to/certKey.pem
#PrivateKey=/path/to/privateKey.pem

GatewayID=1
GatewayName=PahoGateway-01
KeepAlive=900
#LoginID=your_ID
#Password=your_Password

# UDP
GatewayPortNo=10000
MulticastIP=225.1.1.1
MulticastPortNo=1883

# XBee
Baudrate=38400
SerialDevice=/dev/ttyUSB0
ApiMode=2

# LOG
ShearedMemory=NO;

clients.conf

device,x.x.x.x:65176

predefinedTopic.conf

*,ty4tw/predefinedTopic1, 1
GatewayTestClient,ty4tw/predefinedTopic2, 2
GatewayTestClient,ty4tw/predefinedTopic3, 3

device,ty4tw/predefinedTopic4, 4
#
#  pre-defined-topics for QoS-1 clients.
# 

QoS-1_Client03,ty4tw/proxy/predefTopic4, 1
QoS-1_Client03,ty4tw/proxy/predefTopic5, 2
QoS-1_Client03,ty4tw/proxy/predefTopic6, 3
ty4tw commented 5 years ago

Hi,

Could you attach the log of GW ? I can not understand what's going on. Thank you for your information.

guydillen commented 5 years ago

Hi, Since I can't find //#define RINGBUFFER // print out Packets log into shared memory./" nor the file MQTTSNGWDefined.h, how can I enable debugging?

Thanks.

ty4tw commented 5 years ago

Can you 'tee' the stdout to a file? ./MQTT-SNGateway [-f Config file name] | tee fileName

guydillen commented 5 years ago

directing standard output to a file with tee gives an empty file. I get this when sending packets from PacketSender:

20190530 111831.430   UNKNOWN           <---  Unknown Client !                    74 65 73 74
Error: Client(109.131.88.55:56896) is not connecting. message has been discarded.

20190530 111832.296   UNKNOWN           <---  Unknown Client !                    74 65 73 74
Error: Client(109.131.88.55:56896) is not connecting. message has been discarded.

20190530 111833.138   UNKNOWN           <---  Unknown Client !                    74 65 73 74
Error: Client(109.131.88.55:56896) is not connecting. message has been discarded.

If I send something from my NB-IoT device, nothing enters.

So an upfront question is: is it at all possible to send UDP messages originating from a NB-IoT device to the MQTT-SN gateway (I don't use any specific library on the micro-controller device), i just send out a packet)?

Thanks.

ty4tw commented 5 years ago

The portNo of the client is defined as 65176.

clients.conf
device,x.x.x.x:65176

but, portNo of the client is 56896. change the address in clients.conf to

device,109.131.88.55:56896
guydillen commented 5 years ago

Additionally I had to change/uncomment the following in the gateway.conf file:

ClientAuthentication=YES ClientsList=./clients.conf

Now I get, using PacketSender:

20190530 163956.509   UNKNOWN           <---  device                              74 65 73 74

20190530 163957.509   UNKNOWN           <---  device                              74 65 73 74

20190530 163957.758   UNKNOWN           <---  device                              74 65 73 74

20190530 163957.945   UNKNOWN           <---  device                              74 65 73 74
ty4tw commented 5 years ago

UNKOWN in the log means a message type is unkown.

74 65 73 74 is not a MQTT-SN message. what mesage do you try to send?

ty4tw commented 5 years ago

Close because it has not been discussed for a long time.

saumilsdk commented 4 years ago

hey @ty4tw i am also getting unknown client while client is added in clients.conf and having ClientAuthentication=YES. Also how to pretty print the messages received?

20200521 060619.341   PUBLISH     0008  <---  Unknown Client !                    29 0C 02 76 32 00 08 68 65 6C 6F 6F 6F 73 64 69 75 6E 65 6F 75 68 6A 65 6F 6A 63 6E 30 39 33 32 2D 65 33 30 2D 32 39 39 39
Error: Client(1.39.140.182:10989) is not connecting. message has been discarded.
recved from 1.39.140.182:10989 length = 41