Refactor BWM_WIFI command handling logic

Signed-off-by: Niel Nielsen <nieldk@gmail.com>
This commit is contained in:
Niel Nielsen authored and Philippe Teuwen committed 2026-08-28 13:10:24 +02:00
1 parent b3fc31f58f
commit e9688db826
1 file changed
+11 -5
+11 -5
View File
@@ -4316,12 +4316,18 @@ static void PacketReceived(PacketCommandNG *packet) {
}
case CMD_PM5_BWM_WIFI: {
#if defined(WITH_BWM_FORWARD)
uint16_t port = packet->data.asBytes[0] | (packet->data.asBytes[1] << 8);
char *ssid = (char *)&packet->data.asBytes[2];
char *pwd = ssid + strlen(ssid) + 1;
char *host = pwd + strlen(pwd) + 1;
uint8_t action = packet->data.asBytes[0];
uint32_t ip = 0;
int res = bwm_wifi_forward_up(ssid, pwd, host, port, &ip);
int res;
if (action == BWM_WIFI_ACTION_STOP) {
res = bwm_wifi_forward_down();
} else {
uint16_t port = packet->data.asBytes[1] | (packet->data.asBytes[2] << 8);
char *ssid = (char *)&packet->data.asBytes[3];
char *pwd = ssid + strlen(ssid) + 1;
char *host = pwd + strlen(pwd) + 1;
res = bwm_wifi_forward_up(ssid, pwd, host, port, &ip);
}
reply_ng (CMD_PM5_BWM_WIFI, res, (uint8_t *)&ip, sizeof(ip));
#else
reply_ng(CMD_PM5_BWM_WIFI, PM3_ENOTIMPL, NULL, 0);