Skip to content

Commit 5d82c21

Browse files
committed
Ajout d'une commande de reset du module
1 parent 98a11f4 commit 5d82c21

File tree

5 files changed

+38
-19
lines changed

5 files changed

+38
-19
lines changed

lightkit/software/src/cmd/cmd.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
#include "flash/flash.hpp"
1010
#include "global.hpp"
1111
#include "relay/relay.hpp"
12+
#include "script/script.hpp"
1213
#include "status_led/status_led.hpp"
1314
#include "stripled/stripled.hpp"
15+
#include "wifi/wifi.hpp"
1416

1517
void cmd_print_help(void)
1618
{
1719
log_raw("=== " FIRMWARE_VERSION " ===\n");
1820
log_raw("H This help\n");
21+
log_raw("I Reset the module\n");
1922
log_raw("T Print board status\n");
2023
log_raw("F Reset flash setting to default\n");
2124
#ifdef MODULE_STATUS_LED
@@ -32,10 +35,17 @@ void cmd_print_help(void)
3235
#endif
3336
}
3437

38+
void cmd_reset_module(void)
39+
{
40+
// Resetting with new configuration
41+
script_delayed_reset(1000);
42+
}
43+
3544
void cmd_print_status(void)
3645
{
3746
log_raw("APPLI: 0x%02X\n", STATUS_APPLI);
3847
log_raw("WIFI: 0x%02X\n", STATUS_WIFI);
48+
wifi_print();
3949
}
4050

4151
#ifdef MODULE_STATUS_LED

lightkit/software/src/cmd/cmd.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <Arduino.h>
1212

1313
void cmd_print_help(void);
14+
void cmd_reset_module(void);
1415
void cmd_print_status(void);
1516
void cmd_set_status_led(uint8_t isEnabled);
1617
void cmd_set_brightness_auto(bool newValue);

lightkit/software/src/cmd/term.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ static void term_execute_command(void)
6060
case 'H':
6161
cmd_print_help();
6262
break;
63+
case 'I':
64+
cmd_reset_module();
65+
break;
6366
case 'T':
6467
cmd_print_status();
6568
break;

lightkit/software/src/wifi/wifi.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,6 @@ wifi_handle_t defaultWifiSettings = {
5656
// STATIC FUNCTIONS
5757
// =====================
5858

59-
static void wifi_print(void)
60-
{
61-
if (wifiHandle->mode == MODE_AP) {
62-
log_info("Wifi mode : Access Point");
63-
log_info("SSID : %s", wifiHandle->ap.ssid);
64-
log_info("Mac address: %s", WiFi.softAPmacAddress().c_str());
65-
log_info("IP : %s", WiFi.softAPIP().toString().c_str());
66-
} else if (wifiHandle->mode == MODE_CLIENT) {
67-
log_info("Wifi mode : Client");
68-
log_info("SSID : %s", wifiHandle->client.ssid);
69-
log_info("Mac address: %s", WiFi.macAddress().c_str());
70-
log_info("IP : %s", WiFi.localIP().toString().c_str());
71-
log_info("Channel : %d", WiFi.channel());
72-
}
73-
if (_isset(STATUS_WIFI, STATUS_WIFI_USING_FORCED_MODE)) {
74-
log_info("Wifi is using a FORCED MODE");
75-
}
76-
}
77-
7859
static void wifi_fallback_as_ap(void)
7960
{
8061
log_warn("Falling back to AP mode !");
@@ -265,6 +246,29 @@ static int32_t wifi_start_scan(void)
265246
return 0;
266247
}
267248

249+
// =====================
250+
// PUBLIC FUNCTIONS
251+
// =====================
252+
253+
void wifi_print(void)
254+
{
255+
if (wifiHandle->mode == MODE_AP) {
256+
log_info("Wifi mode : Access Point");
257+
log_info("SSID : %s", wifiHandle->ap.ssid);
258+
log_info("Mac address: %s", WiFi.softAPmacAddress().c_str());
259+
log_info("IP : %s", WiFi.softAPIP().toString().c_str());
260+
} else if (wifiHandle->mode == MODE_CLIENT) {
261+
log_info("Wifi mode : Client");
262+
log_info("SSID : %s", wifiHandle->client.ssid);
263+
log_info("Mac address: %s", WiFi.macAddress().c_str());
264+
log_info("IP : %s", WiFi.localIP().toString().c_str());
265+
log_info("Channel : %d", WiFi.channel());
266+
}
267+
if (_isset(STATUS_WIFI, STATUS_WIFI_USING_FORCED_MODE)) {
268+
log_info("Wifi is using a FORCED MODE");
269+
}
270+
}
271+
268272
/**
269273
* @brief Provide a pointer to handle for other modules
270274
*/

lightkit/software/src/wifi/wifi.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ typedef struct {
8686
} wifi_fast_reconnect_t;
8787

8888
// PROTOTYPES
89+
void wifi_print(void);
8990
wifi_handle_t * wifi_get_handle(void);
9091
int32_t wifi_use_new_settings(wifi_handle_t * pWifiHandle, String & reason);
9192
int32_t wifi_use_default_settings(void);

0 commit comments

Comments
 (0)