Skip to content

Commit

Permalink
wifi cmds by mqtt; bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
ves011 committed Apr 20, 2023
1 parent a539e2d commit 6fa8ab6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmds/cmd_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static void event_handler(void* arg, esp_event_base_t event_base,
static void scan_done_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
{
ESP_LOGI(WIFITAG, "SCAN DONE event");
//ESP_LOGI(WIFITAG, "SCAN DONE event");
scan_done = 1;
}

Expand Down Expand Up @@ -459,3 +459,13 @@ void register_wifi(void)
ESP_ERROR_CHECK( esp_console_cmd_register(&wifi_scan_cmd));
ESP_ERROR_CHECK( esp_console_cmd_register(&wifi_disconnect_cmd));
}

void do_wifi_cmd(int argc, char **argv)
{
if(!strcmp(argv[0], "wifiscan"))
wifi_scan(argc, argv);
else if(!strcmp(argv[0], "disconnect"))
wifi_disconnect(argc, argv);
else if(!strcmp(argv[0], "connect"))
wifi_connect(argc, argv);
}
1 change: 1 addition & 0 deletions cmds/cmd_wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ void register_wifi(void);
bool isConnected(void);
int wifi_connect(int argc, char **argv);
bool wifi_join(const char *ssid, const char *pass, int timeout_ms);
void do_wifi_cmd(int argc, char **argv);

#endif
2 changes: 2 additions & 0 deletions tcp/mqtt_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "external_defs.h"
#include "utils.h"
#include "cmd_system.h"
#include "cmd_wifi.h"
#include "mqtt_ctrl.h"
#if ACTIVE_CONTROLLER == PUMP_CONTROLLER
#include "adc_op.h"
Expand Down Expand Up @@ -189,6 +190,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
strcpy(argv[i], argv[i + 1]);
argc--;
do_system_cmd(argc, argv);
do_wifi_cmd(argc, argv);
}
else if(strcmp(topic, DEVICE_TOPIC_Q) == 0)
{
Expand Down

0 comments on commit 6fa8ab6

Please sign in to comment.