Commit 9a9548b0 authored by serg3295's avatar serg3295 Committed by J Mattsson
Browse files

fix(mqtt): select next parameter in connect()

parent 9633b03a
...@@ -368,14 +368,13 @@ static int mqtt_connect(lua_State* L) { ...@@ -368,14 +368,13 @@ static int mqtt_connect(lua_State* L) {
if (is_mqtt_uri || is_mqtts_uri) if (is_mqtt_uri || is_mqtts_uri)
return luaL_error(L, "port arg must be nil if giving full uri"); return luaL_error(L, "port arg must be nil if giving full uri");
port = luaL_checknumber(L, n); port = luaL_checknumber(L, n);
n++;
} }
n++;
if (lua_isnumber(L, n)) { if (lua_isnumber(L, n)) {
if (is_mqtt_uri || is_mqtts_uri) if (is_mqtt_uri || is_mqtts_uri)
return luaL_error(L, "secure on/off determined by uri"); return luaL_error(L, "secure on/off determined by uri");
secure = !!luaL_checkinteger(L, n); secure = !!luaL_checkinteger(L, n);
n++;
} else { } else {
if (lua_istable(L, n)) { if (lua_istable(L, n)) {
...@@ -397,10 +396,9 @@ static int mqtt_connect(lua_State* L) { ...@@ -397,10 +396,9 @@ static int mqtt_connect(lua_State* L) {
luaX_set_ref(L, -1, &mqtt_context->client_key_pem); luaX_set_ref(L, -1, &mqtt_context->client_key_pem);
} }
lua_pop(L, 1); lua_pop(L, 1);
//
n++;
} }
} }
n++;
if (lua_isnumber(L, n)) { if (lua_isnumber(L, n)) {
reconnect = !!luaL_checkinteger(L, n); reconnect = !!luaL_checkinteger(L, n);
......
...@@ -86,7 +86,7 @@ Closes connection to the broker. ...@@ -86,7 +86,7 @@ Closes connection to the broker.
none none
#### Returns #### Returns
`true` on success, `false` otherwise `nil`
## mqtt.client:connect() ## mqtt.client:connect()
...@@ -139,22 +139,6 @@ This is the description of how the `autoreconnect` functionality may (or may not ...@@ -139,22 +139,6 @@ This is the description of how the `autoreconnect` functionality may (or may not
> is considered a success if the client connects to a server and gets back a good response packet in response to its MQTT connection request. > is considered a success if the client connects to a server and gets back a good response packet in response to its MQTT connection request.
> This implies (for example) that the username and password are correct. > This implies (for example) that the username and password are correct.
#### Connection failure callback reason codes:
| Constant | Value | Description |
|----------|-------|-------------|
|`mqtt.CONN_FAIL_SERVER_NOT_FOUND`|-5|There is no broker listening at the specified IP Address and Port|
|`mqtt.CONN_FAIL_NOT_A_CONNACK_MSG`|-4|The response from the broker was not a CONNACK as required by the protocol|
|`mqtt.CONN_FAIL_DNS`|-3|DNS Lookup failed|
|`mqtt.CONN_FAIL_TIMEOUT_RECEIVING`|-2|Timeout waiting for a CONNACK from the broker|
|`mqtt.CONN_FAIL_TIMEOUT_SENDING`|-1|Timeout trying to send the Connect message|
|`mqtt.CONNACK_ACCEPTED`|0|No errors. _Note: This will not trigger a failure callback._|
|`mqtt.CONNACK_REFUSED_PROTOCOL_VER`|1|The broker is not a 3.1.1 MQTT broker.|
|`mqtt.CONNACK_REFUSED_ID_REJECTED`|2|The specified ClientID was rejected by the broker. (See `mqtt.Client()`)|
|`mqtt.CONNACK_REFUSED_SERVER_UNAVAILABLE`|3|The server is unavailable.|
|`mqtt.CONNACK_REFUSED_BAD_USER_OR_PASS`|4|The broker refused the specified username or password.|
|`mqtt.CONNACK_REFUSED_NOT_AUTHORIZED`|5|The username is not authorized.|
## mqtt.client:lwt() ## mqtt.client:lwt()
Setup [Last Will and Testament](http://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament) (optional). A broker will publish a message with qos = 0, retain = 0, data = "offline" to topic "/lwt" if client does not send keepalive packet. Setup [Last Will and Testament](http://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament) (optional). A broker will publish a message with qos = 0, retain = 0, data = "offline" to topic "/lwt" if client does not send keepalive packet.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment