mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-15 16:36:52 +01:00
Improve documentation #145
Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -1,35 +1,35 @@
|
|||||||
# MQTT-SN Transparent / Aggrigating Gateway
|
# MQTT-SN Transparent / Aggregating Gateway
|
||||||
|
|
||||||
**MQTT-SN** requires a MQTT-SN Gateway which acts as a protocol converter to convert **MQTT-SN messages to MQTT messages**. MQTT-SN client over SensorNetwork can not communicate directly with MQTT broker(TCP/IP).
|
**MQTT-SN** requires a MQTT-SN Gateway which acts as a protocol converter to convert **MQTT-SN messages to MQTT messages**. MQTT-SN client over SensorNetwork can not communicate directly with MQTT broker (TCP/IP).
|
||||||
This Gateway can run as a transparent or aggrigating Gateway by specifying the gateway.conf.
|
This Gateway can be configured to run as a transparent or aggregating gateway in the file *gateway.conf*.
|
||||||
|
|
||||||
### **step1. Build the gateway**
|
### **Step 1: Build the gateway**
|
||||||
````
|
````
|
||||||
$ git clone -b experiment https://github.com/eclipse/paho.mqtt-sn.embedded-c
|
$ git clone https://github.com/eclipse/paho.mqtt-sn.embedded-c
|
||||||
$ cd paho.mqtt-sn.embedded-c/MQTTSNGateway
|
$ cd paho.mqtt-sn.embedded-c/MQTTSNGateway
|
||||||
$ make
|
$ make
|
||||||
$ make install
|
$ make install
|
||||||
$ make clean
|
$ make clean
|
||||||
````
|
````
|
||||||
MQTT-SNGateway, MQTT-SNLogmonitor and *.conf files are copied into ../ directory.
|
MQTT-SNGateway, MQTT-SNLogmonitor and *.conf files are copied into **../** directory.
|
||||||
If you want to install the gateway into specific directories, enter a command line as follows:
|
If you want to install the gateway into specific directories, enter a command line as follows:
|
||||||
````
|
````
|
||||||
$ make install INSTALL_DIR=/path/to/your_directory CONFIG_DIR=/path/to/your_directory
|
$ make install INSTALL_DIR=/path/to/your_directory CONFIG_DIR=/path/to/your_directory
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|
||||||
### **step2. Execute the Gateway.**
|
|
||||||
|
|
||||||
````
|
### **Step 2: Execute the Gateway.**
|
||||||
$ cd ../
|
|
||||||
|
````
|
||||||
|
$ cd ../
|
||||||
$ ./MQTT-SNGateway [-f Config file name]
|
$ ./MQTT-SNGateway [-f Config file name]
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|
||||||
### **How to Change the configuration of the gateway**
|
### How to change the configuration of the gateway
|
||||||
**../gateway.conf** Contents are follows:
|
Example for **gateway.conf**:
|
||||||
|
|
||||||
<pre><dev>
|
<pre><dev>
|
||||||
|
|
||||||
# config file of MQTT-SN Gateway
|
# config file of MQTT-SN Gateway
|
||||||
#
|
#
|
||||||
@@ -40,7 +40,7 @@ BrokerSecurePortNo=8883
|
|||||||
|
|
||||||
#
|
#
|
||||||
# When AggregatingGateway=YES or ClientAuthentication=YES,
|
# When AggregatingGateway=YES or ClientAuthentication=YES,
|
||||||
# All clients must be specified by the ClientList File
|
# All clients must be specified by the ClientList File
|
||||||
#
|
#
|
||||||
|
|
||||||
ClientAuthentication=NO
|
ClientAuthentication=NO
|
||||||
@@ -78,35 +78,48 @@ ApiMode=2
|
|||||||
# LOG
|
# LOG
|
||||||
ShearedMemory=NO;
|
ShearedMemory=NO;
|
||||||
|
|
||||||
</dev></pre>
|
</dev></pre>
|
||||||
|
|
||||||
**BrokerName** to specify a domain name of the Broker, and **BrokerPortNo** is a port No of the Broker. **BrokerSecurePortNo** is for TLS connection.
|
**Broker config**
|
||||||
**MulticastIP** and **MulticastPortNo** is a multicast address for GWSEARCH messages. Gateway is waiting GWSEARCH and when receiving it send GWINFO message via MulticastIP address. Clients can get the gateway address (Gateway IP address and **GatewayPortNo**) from GWINFO message by means of std::recvfrom().
|
* *BrokerName* - Domain name/ IP address of the MQTT broker
|
||||||
Client should know the MulticastIP and MulticastPortNo to send a SEARCHGW message.
|
* *BrokerPortNo* - Port of the MQTT broker
|
||||||
**GatewayId** is used by GWINFO message.
|
* *LoginID* - Username for login at the broker
|
||||||
**KeepAlive** is a duration of ADVERTISE message in seconds.
|
* *Password* - Password for login at the broker
|
||||||
when **AggregatingGateway** or **ClientAuthentication** is **YES**, All clients which connect to the gateway must be declared by a **ClientsList** file.
|
|
||||||
Format of the file is ClientId and SensorNetwork Address. e.g. IP address and Port No etc, in CSV. more detail see clients.conf.
|
|
||||||
When **QoS-1** is **YES**, QoS-1 PUBLISH is available. All clients which send QoS-1 PUBLISH must be specified by Client.conf file.
|
|
||||||
When **PredefinedTopic** is **YES**, **Pre-definedTopicId**s specified by **PredefinedTopicList** are effective. This file defines Pre-definedTopics of the clients. In this file, ClientID,TopicName and TopicID are declared in CSV format.
|
|
||||||
When **Forwarder** is **YES**, Forwarder Encapsulation Message is available. Connectable Forwarders must be declared by a **ClientsList** file.
|
|
||||||
|
|
||||||
|
|
||||||
### ** How to monitor the gateway from remote. **
|
**Broker config for TLS**
|
||||||
|
* *BrokerSecurePortNo* - TLS Port of the MQTT broker
|
||||||
|
* *RootCAfile* - Path to the root CA file
|
||||||
|
* *RootCApath* - Path to the CA certificates
|
||||||
|
* *CertsFile* - Path to the certificate
|
||||||
|
* *PrivateKey* - Path to the private key
|
||||||
|
|
||||||
Uncomment line32 in MQTTSNGWDefined.h.
|
**Gateway config**
|
||||||
|
* *MulticastIP* - UDP multicast IP address of the gateway
|
||||||
|
* *MulticastPortNo* - UDP multicast port of the gateway
|
||||||
|
* *GatewayId* - ID of the gateway (for advertising)
|
||||||
|
* *GatewayName* - Name of the gateway (for advertising)
|
||||||
|
* *KeepAlive* - Connection timeout
|
||||||
|
* *AggregatingGateway* - If 'YES', all clients which want to connect to the gateway must be declared inside of *clients.conf*
|
||||||
|
* *ClientAuthentication* - If 'YES', all clients which want to connect to the gateway must be declared inside of *clients.conf*
|
||||||
|
* *ClientsList* - path/to/your/custom_clients.conf
|
||||||
|
* *PredefinedTopic* - If 'YES', then predefined topics specified by *predefinedTopic.conf* are effective
|
||||||
|
* *PredefinedTopicList* - path/to/your/custom_predefinedTopic.conf
|
||||||
|
* *QoS-1* - If 'YES', QoS-1 PUBLISH is available. All clients which send QoS-1 PUBLISH must be declared inside of *clients.conf*
|
||||||
|
* *Forwarder* - If 'YES', then Forwarder Encapsulation Message is available. Connectable forwarders must be declared in *clients.conf*.
|
||||||
|
|
||||||
`//#define RINGBUFFER // print out Packets log into shared memory./"`
|
Multicast address is used for GWSEARCH messages. The Gateway is waiting GWSEARCH and when receiving it,
|
||||||
````
|
it sends GWINFO message via MulticastIP address. Clients can get the gateway address (Gateway IP address
|
||||||
$ make
|
and GatewayPortNo) from GWINFO message by means of std::recvfrom(). Client should know the MulticastIP and
|
||||||
$ make install
|
MulticastPortNo to send a SEARCHGW message.
|
||||||
$ make clean
|
|
||||||
````
|
|
||||||
restart the gateway.
|
|
||||||
open ssh terminal and execute LogMonitor.
|
|
||||||
|
|
||||||
`$ ./MQTT-SNLogmonitor`
|
### How to monitor the gateway from remote
|
||||||
|
|
||||||
Now you can get the Log on your terminal.
|
Uncomment line32 in MQTTSNGWDefined.h:
|
||||||
|
|
||||||
|
`//#define RINGBUFFER // print out Packets log into shared memory./"`
|
||||||
|
|
||||||
|
and rebuild the gateway as shown above. Start the gateway, open a ssh terminal and execute LogMonitor with
|
||||||
|
|
||||||
|
`$ ./MQTT-SNLogmonitor`
|
||||||
|
|
||||||
|
Now you can get the log on your terminal.
|
||||||
|
|||||||
Reference in New Issue
Block a user