https://github.com/njh/mqtt-sn-tools
Command line tools written in C for the MQTT-SN (MQTT for Sensor Networks) protocol
https://github.com/njh/mqtt-sn-tools
c cli mqtt mqtt-sn
Last synced: 12 months ago
JSON representation
Command line tools written in C for the MQTT-SN (MQTT for Sensor Networks) protocol
- Host: GitHub
- URL: https://github.com/njh/mqtt-sn-tools
- Owner: njh
- License: mit
- Created: 2013-12-02T15:13:48.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2021-01-22T18:57:09.000Z (over 5 years ago)
- Last Synced: 2025-04-10T00:28:57.706Z (about 1 year ago)
- Topics: c, cli, mqtt, mqtt-sn
- Language: C
- Homepage:
- Size: 644 KB
- Stars: 196
- Watchers: 36
- Forks: 87
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- Agile-IoT-awesome-open-iot - mqtt-sn-tools - sn-tools.svg?style=social&label=Star&maxAge=2592000)]() | Command line tools written in C for the MQTT-SN (MQTT for Sensor Networks) protocol. | MIT | C | (Messaging / MQTT-SN)
- awesome-open-iot - mqtt-sn-tools - sn-tools.svg?style=social&label=Star&maxAge=2592000)]() | Command line tools written in C for the MQTT-SN (MQTT for Sensor Networks) protocol. | MIT | C | (Messaging / MQTT-SN)
README
MQTT-SN Tools
=============
[](https://travis-ci.org/njh/mqtt-sn-tools)
Command line tools written in C for the MQTT-SN (MQTT for Sensor Networks) protocol.
Supported Features
------------------
- QoS 0, 1 and -1
- Keep alive pings
- Publishing retained messages
- Publishing empty messages
- Subscribing to named topic
- Clean / unclean sessions
- Manual and automatic client ID generation
- Displaying topic name with wildcard subscriptions
- Pre-defined topic IDs and short topic names
- Forwarder encapsulation according to MQTT-SN Protocol Specification v1.2.
Limitations
-----------
- Packets must be 255 or less bytes long
- No Last Will and Testament
- No QoS 2
- No automatic re-sending of lost packets
- No Automatic gateway discovery
Building
--------
Just run 'make' on a POSIX system.
Publishing
----------
Usage: mqtt-sn-pub [opts] -t -m
-d Increase debug level by one. -d can occur multiple times.
-f A file to send as the message payload.
-h MQTT-SN host to connect to. Defaults to '127.0.0.1'.
-i ID to use for this client. Defaults to 'mqtt-sn-tools-' with process id.
-k keep alive in seconds for this client. Defaults to 10.
-e sleep duration in seconds when disconnecting. Defaults to 0.
-m Message payload to send.
-l Read from STDIN, one message per line.
-n Send a null (zero length) message.
-p Network port to connect to. Defaults to 1883.
-q Quality of Service value (0, 1 or -1). Defaults to 0.
-r Message should be retained.
-s Read one whole message from STDIN.
-t MQTT-SN topic name to publish to.
-T Pre-defined MQTT-SN topic ID to publish to.
--fe Enables Forwarder Encapsulation. Mqtt-sn packets are encapsulated according to MQTT-SN Protocol Specification v1.2, chapter 5.5 Forwarder Encapsulation.
--wlnid If Forwarder Encapsulation is enabled, wireless node ID for this client. Defaults to process id.
--cport Source port for outgoing packets. Uses port in ephemeral range if not specified or set to 0.
Subscribing
-----------
Usage: mqtt-sn-sub [opts] -t
-1 exit after receiving a single message.
-c disable 'clean session' (store subscription and pending messages when client disconnects).
-d Increase debug level by one. -d can occur multiple times.
-h MQTT-SN host to connect to. Defaults to '127.0.0.1'.
-i ID to use for this client. Defaults to 'mqtt-sn-tools-' with process id.
-k keep alive in seconds for this client. Defaults to 10.
-e sleep duration in seconds when disconnecting. Defaults to 0.
-p Network port to connect to. Defaults to 1883.
-q QoS level to subscribe with (0 or 1). Defaults to 0.
-t MQTT-SN topic name to subscribe to. It may repeat multiple times.
-T Pre-defined MQTT-SN topic ID to subscribe to. It may repeat multiple times.
--fe Enables Forwarder Encapsulation. Mqtt-sn packets are encapsulated according to MQTT-SN Protocol Specification v1.2, chapter 5.5 Forwarder Encapsulation.
--wlnid If Forwarder Encapsulation is enabled, wireless node ID for this client. Defaults to process id.
-v Print messages verbosely, showing the topic name.
-V Print messages verbosely, showing current time and the topic name.
--cport Source port for outgoing packets. Uses port in ephemeral range if not specified or set to 0.
Dumping
-------
Displays MQTT-SN packets sent to specified port.
Most useful for listening out for QoS -1 messages being published by a client.
Usage: mqtt-sn-dump [opts] -p
-a Dump all packet types.
-d Increase debug level by one. -d can occur multiple times.
-p Network port to listen on. Defaults to 1883.
-v Print messages verbosely, showing the topic name.
Serial Port Bridge
------------------
The Serial Port bridge can be used to relay packets from a remote device on the end of a
serial port and convert them into UDP packets, which are sent and received from a broker
or MQTT-SN gateway.
Usage: mqtt-sn-serial-bridge [opts]
-b Set the baud rate. Defaults to 9600.
-d Increase debug level by one. -d can occur multiple times.
-dd Enable extended debugging - display packets in hex.
-h MQTT-SN host to connect to. Defaults to '127.0.0.1'.
-p Network port to connect to. Defaults to 1883.
--fe Enables Forwarder Encapsulation. Mqtt-sn packets are encapsulated according to MQTT-SN Protocol Specification v1.2, chapter 5.5 Forwarder Encapsulation.
--cport Source port for outgoing packets. Uses port in ephemeral range if not specified or set to 0.
License
-------
MQTT-SN Tools is licensed under the [MIT License].
[MIT License]: http://opensource.org/licenses/MIT