Skip to content

Commit 6fa8ab6

Browse files
committed
wifi cmds by mqtt; bug fixing
1 parent a539e2d commit 6fa8ab6

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

cmds/cmd_wifi.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static void event_handler(void* arg, esp_event_base_t event_base,
141141
static void scan_done_handler(void* arg, esp_event_base_t event_base,
142142
int32_t event_id, void* event_data)
143143
{
144-
ESP_LOGI(WIFITAG, "SCAN DONE event");
144+
//ESP_LOGI(WIFITAG, "SCAN DONE event");
145145
scan_done = 1;
146146
}
147147

@@ -459,3 +459,13 @@ void register_wifi(void)
459459
ESP_ERROR_CHECK( esp_console_cmd_register(&wifi_scan_cmd));
460460
ESP_ERROR_CHECK( esp_console_cmd_register(&wifi_disconnect_cmd));
461461
}
462+
463+
void do_wifi_cmd(int argc, char **argv)
464+
{
465+
if(!strcmp(argv[0], "wifiscan"))
466+
wifi_scan(argc, argv);
467+
else if(!strcmp(argv[0], "disconnect"))
468+
wifi_disconnect(argc, argv);
469+
else if(!strcmp(argv[0], "connect"))
470+
wifi_connect(argc, argv);
471+
}

cmds/cmd_wifi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ void register_wifi(void);
1717
bool isConnected(void);
1818
int wifi_connect(int argc, char **argv);
1919
bool wifi_join(const char *ssid, const char *pass, int timeout_ms);
20+
void do_wifi_cmd(int argc, char **argv);
2021

2122
#endif

tcp/mqtt_ctrl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "external_defs.h"
3131
#include "utils.h"
3232
#include "cmd_system.h"
33+
#include "cmd_wifi.h"
3334
#include "mqtt_ctrl.h"
3435
#if ACTIVE_CONTROLLER == PUMP_CONTROLLER
3536
#include "adc_op.h"
@@ -189,6 +190,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
189190
strcpy(argv[i], argv[i + 1]);
190191
argc--;
191192
do_system_cmd(argc, argv);
193+
do_wifi_cmd(argc, argv);
192194
}
193195
else if(strcmp(topic, DEVICE_TOPIC_Q) == 0)
194196
{

0 commit comments

Comments
 (0)