Topic: WOLFMQTT_NONBLOCK
Hi,
i'm in process to porting wolfMQTT + wolfSSL (aws) in a microcontroller,
i'm start from the example "awsiot.c" and in blocking mode the library work properly, but with WOLFMQTT_NONBLOCK there are some issue with the timeout of the read function
my porting of mqttnet.c
NetRead()
return MQTT_CODE_ERROR_NETWORK; //socket error
return 0 //Nothing to read
return data_len //num of byte read
return MQTT_CODE_ERROR_TIMEOUT //timeout_ms expired
if there are not activity between the client and the server, after DEFAULT_CMD_TIMEOUT_MS the function NetRead return MQTT_CODE_ERROR_TIMEOUT
src/mqtt_socket.c
51: if (rc == 0 || rc == MQTT_CODE_ERROR_TIMEOUT) {
52: rc = WOLFSSL_CBIO_ERR_WANT_READ;
53: }
54: else if (rc < 0) {
55: rc = WOLFSSL_CBIO_ERR_GENERAL;
56: }
but the library overwrite the result with WOLFSSL_CBIO_ERR_WANT_READ if there are a timeout and also for "no data available"
src/mqtt_socket.c
157: if (error == SSL_ERROR_WANT_READ) {
158: #ifdef WOLFMQTT_NONBLOCK
159: rc = MQTT_CODE_CONTINUE;
160: #else
161: rc = MQTT_CODE_ERROR_TIMEOUT;
162: #endif
163: }
in the next step of the code the result is set just checking the #define, so the initial information of timeout is lost and the code do the same path between "no data available" and timeout
i tried also to return MQTT_CODE_CONTINUE when the data is not available but the library set the result with WOLFSSL_CBIO_ERR_GENERAL and off course the code stop.
is a issue of the library or i misunderstood / or wrong implemented?
in any case, some suggestion how to solve the issue?