Skip to content

Commit

Permalink
add more size to username password and fix some annoyances
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Fadhlika committed Nov 25, 2018
1 parent 6c99895 commit 6c91a94
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion esp_sara_at.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ esp_err_t esp_sara_set_clean_session(bool session)

esp_err_t esp_sara_set_mqtt_auth(const char *username, const char *password)
{
char cmd[64];
char cmd[128];
int len = sprintf(cmd, "AT+UMQTT=4,\"%s\",\"%s\"\r\n", username, password);
return esp_sara_send_at_command(cmd, len, 1000);
}
Expand Down
20 changes: 14 additions & 6 deletions esp_sara_nbiot.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ typedef enum
typedef enum
{
SARA_MQTT_DISCONNECTED = 0,
SARA_MQTT_CONNECTED
SARA_MQTT_CONNECTED,
SARA_MQTT_CONNECTING
} esp_sara_mqtt_state_t;

typedef enum
Expand Down Expand Up @@ -346,9 +347,17 @@ static void esp_sara_event_task(void *param)

if (result == 0)
esp_sara_get_mqtt_error();

switch (op)
{
case SARA_UMQTTC_OP_LOGIN:
{
if (result)
{
client->mqtt_state = SARA_MQTT_CONNECTING;
}
}
break;
case SARA_UMQTTC_OP_PUBLISH:
{
if (result)
Expand All @@ -358,7 +367,6 @@ static void esp_sara_event_task(void *param)
else
{
event.event_id = SARA_EVENT_PUBLISH_FAILED;
esp_sara_get_mqtt_error();
}
should_callback = true;
}
Expand All @@ -381,8 +389,8 @@ static void esp_sara_event_task(void *param)
{
if (result == 0)
{
esp_sara_logout_mqtt(client);
esp_sara_login_mqtt(client);
//esp_sara_logout_mqtt(client);
//esp_sara_login_mqtt(client);
}
}
break;
Expand Down Expand Up @@ -451,7 +459,7 @@ static void esp_sara_event_task(void *param)
*(int *)(event.payload + 4) = supl_err;

event.payload_size = 2 * sizeof(int);

event.event_id = SARA_EVENT_MQTT_ERR;
should_callback = err != 0;
}
else if (strstr(ch, "+CME ERROR:") != NULL)
Expand Down
6 changes: 6 additions & 0 deletions include/esp_sara_mqtt_err.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef ESP_SARA_MQTT_ERR_H
#define ESP_SARA_MQTT_ERR_H



#endif

0 comments on commit 6c91a94

Please sign in to comment.