LORA MOSQUITTO的简单使用

LORA MOSQUITTO

最近在学习lorasever的搭建,随便学习一下mqtt,脑子记不住就写下来

在终端运行mosquitto_sub --help 或 mosquitto_pub --help

-A : bind the outgoing socket to this host/ip address. Use to control which interface
the client communicates over.
-c : disable ‘clean session’ (store subscription and pending messages when client disconnects).
-C : disconnect and exit after receiving the ‘msg_count’ messages.
-d : enable debug messages.
-D : Define MQTT v5 properties. See the documentation for more details.
-E : Exit once all subscriptions have been acknowledged by the broker.
-F : output format.
-h : mqtt host to connect to. Defaults to localhost.
-i : id to use for this client. Defaults to mosquitto_sub_ appended with the process id.
-I : define the client id as id_prefix appended with the process id. Useful for when the
broker is using the clientid_prefixes option.
-k : keep alive in seconds for this client. Defaults to 60.
-L : specify user, password, hostname, port and topic as a URL in the form:
mqtt(s)?/[username[:password]@]host[:port]/topic
-N : do not add an end of line character when printing the payload.
-p : network port to connect to. Defaults to 1883 for plain MQTT and 8883 for MQTT over TLS.
-P : provide a password
-q : quality of service level to use for the subscription. Defaults to 0.
-R : do not print stale messages (those with retain set).
-t : mqtt topic to subscribe to. May be repeated multiple times.
-T : topic string to filter out of results. May be repeated.
-u : provide a username
-U : unsubscribe from a topic. May be repeated.
-v : print published messages verbosely.
-V : specify the version of the MQTT protocol to use when connecting.
Can be mqttv5, mqttv311 or mqttv31. Defaults to mqttv311.
-W : Specifies a timeout in seconds how long to process incoming MQTT messages.
–help : display this message.
–quiet : don’t print error messages.
–retained-only : only handle messages with the retained flag set, and exit when the
first non-retained message is received.
–remove-retained : send a message to the server to clear any received retained messages
Use -T to filter out messages you do not want to be cleared.
–will-payload : payload for the client Will, which is sent by the broker in case of
unexpected disconnection. If not given and will-topic is set, a zero
length message will be sent.
–will-qos : QoS level for the client Will.
–will-retain : if given, make the client Will retained.
–will-topic : the topic on which to publish the client Will.
–cafile : path to a file containing trusted CA certificates to enable encrypted
certificate based communication.
–capath : path to a directory containing trusted CA certificates to enable encrypted
communication.
–cert : client certificate for authentication, if required by server.
–key : client private key for authentication, if required by server.
–keyform : keyfile type, can be either “pem” or “engine”.
–ciphers : openssl compatible list of TLS ciphers to support.
–tls-version : TLS protocol version, can be one of tlsv1.3 tlsv1.2 or tlsv1.1.
Defaults to tlsv1.2 if available.
–insecure : do not check that the server certificate hostname matches the remote
hostname. Using this option means that you cannot be sure that the
remote host is the server you wish to connect to and so is insecure.
Do not use this option in a production environment.
–tls-engine : If set, enables the use of a SSL engine device.
–tls-engine-kpass-sha1 : SHA1 of the key password to be used with the selected SSL engine.
–psk : pre-shared-key in hexadecimal (no leading 0x) to enable TLS-PSK mode.
–psk-identity : client identity string for TLS-PSK mode.
–proxy : SOCKS5 proxy URL of the form:
socks5h://[username[:password]@]hostname[:port]
Only “none” and “username” authentication is supported.

See https://mosquitto.org/ for more information.

-A : bind the outgoing socket to this host/ip address. Use to control which interface
the client communicates over.
-d : enable debug messages.
-D : Define MQTT v5 properties. See the documentation for more details.
-f : send the contents of a file as the message.
-h : mqtt host to connect to. Defaults to localhost.
-i : id to use for this client. Defaults to mosquitto_pub_ appended with the process id.
-I : define the client id as id_prefix appended with the process id. Useful for when the
broker is using the clientid_prefixes option.
-k : keep alive in seconds for this client. Defaults to 60.
-L : specify user, password, hostname, port and topic as a URL in the form:
mqtt(s)?/[username[:password]@]host[:port]/topic
-l : read messages from stdin, sending a separate message for each line.
-m : message payload to send.
-M : the maximum inflight messages for QoS 1/2…
-n : send a null (zero length) message.
-p : network port to connect to. Defaults to 1883 for plain MQTT and 8883 for MQTT over TLS.
-P : provide a password
-q : quality of service level to use for all messages. Defaults to 0.
-r : message should be retained.
-s : read message from stdin, sending the entire input as a message.
-t : mqtt topic to publish to.
-u : provide a username
-V : specify the version of the MQTT protocol to use when connecting.
Can be mqttv5, mqttv311 or mqttv31. Defaults to mqttv311.
–help : display this message.
–repeat : if publish mode is -f, -m, or -s, then repeat the publish N times.
–repeat-delay : if using --repeat, wait time seconds between publishes. Defaults to 0.
–quiet : don’t print error messages.
–will-payload : payload for the client Will, which is sent by the broker in case of
unexpected disconnection. If not given and will-topic is set, a zero
length message will be sent.
–will-qos : QoS level for the client Will.
–will-retain : if given, make the client Will retained.
–will-topic : the topic on which to publish the client Will.
–cafile : path to a file containing trusted CA certificates to enable encrypted
communication.
–capath : path to a directory containing trusted CA certificates to enable encrypted
communication.
–cert : client certificate for authentication, if required by server.
–key : client private key for authentication, if required by server.
–keyform : keyfile type, can be either “pem” or “engine”.
–ciphers : openssl compatible list of TLS ciphers to support.
–tls-version : TLS protocol version, can be one of tlsv1.3 tlsv1.2 or tlsv1.1.
Defaults to tlsv1.2 if available.
–insecure : do not check that the server certificate hostname matches the remote
hostname. Using this option means that you cannot be sure that the
remote host is the server you wish to connect to and so is insecure.
Do not use this option in a production environment.
–tls-engine : If set, enables the use of a TLS engine device.
–tls-engine-kpass-sha1 : SHA1 of the key password to be used with the selected SSL engine.
–psk : pre-shared-key in hexadecimal (no leading 0x) to enable TLS-PSK mode.
–psk-identity : client identity string for TLS-PSK mode.
–proxy : SOCKS5 proxy URL of the form:
socks5h://[username[:password]@]hostname[:port]
Only “none” and “username” authentication is supported.

See https://mosquitto.org/ for more information.

一个简单的例程

mosquitto_sub -t mqtt -u test -P t123456

-t 指定的topic -u 用户名 -P 密码

mosquitto_pub -h localhost -t mqtt -m “hello world” -u test -P t123456

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值