summaryrefslogtreecommitdiff
path: root/megawifi.c
diff options
context:
space:
mode:
authordoragasu <doragasu@hotmail.com>2020-05-03 12:39:05 -0700
committerdoragasu <doragasu@hotmail.com>2020-05-03 12:39:05 -0700
commit0a8715969afb5f9fe7e2cdc893b3f81c75c1c706 (patch)
tree96039b37c6bab10aa7596fc15d16ab0fa5a6939d /megawifi.c
parentaee9628009d0a4bc5b6b06cc201ef35b443cf51f (diff)
megawifi: stub common commands to get config.
* CMD_AP_CFG_GET * CMD_IP_CFG_GET * CMD_DEF_AP_CFG_GET * CMD_SERVER_URL_GET
Diffstat (limited to 'megawifi.c')
-rw-r--r--megawifi.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/megawifi.c b/megawifi.c
index ecff82b..33cb0d2 100644
--- a/megawifi.c
+++ b/megawifi.c
@@ -210,6 +210,35 @@ static void end_reply(megawifi *mw)
mw_putc(mw, ETX);
}
+static void cmd_ap_cfg_get(megawifi *mw)
+{
+ char ssid[32] = {0};
+ char pass[64] = {0};
+ uint8_t slot = mw->transmit_buffer[4];
+
+ sprintf(ssid, "BLASTEM! SSID %d", slot + 1);
+ sprintf(pass, "BLASTEM! PASS %d", slot + 1);
+ start_reply(mw, CMD_OK);
+ mw_putc(mw, slot);
+ mw_putc(mw, 7); /// 11bgn
+ mw_putraw(mw, ssid, 32);
+ mw_putraw(mw, pass, 64);
+ end_reply(mw);
+}
+
+static void cmd_ip_cfg_get(megawifi *mw)
+{
+ uint32_t ipv4s[5] = {0};
+
+ start_reply(mw, CMD_OK);
+ mw_putc(mw, mw->transmit_buffer[4]);
+ mw_putc(mw, 0);
+ mw_putc(mw, 0);
+ mw_putc(mw, 0);
+ mw_putraw(mw, (char*)ipv4s, sizeof(ipv4s));
+ end_reply(mw);
+}
+
static void process_command(megawifi *mw)
{
uint32_t command = mw->transmit_buffer[0] << 8 | mw->transmit_buffer[1];
@@ -232,6 +261,9 @@ static void process_command(megawifi *mw)
mw->receive_bytes = mw->transmit_bytes;
memcpy(mw->receive_buffer, mw->transmit_buffer, mw->transmit_bytes);
break;
+ case CMD_AP_CFG_GET:
+ cmd_ap_cfg_get(mw);
+ break;
case CMD_IP_CURRENT: {
iface_info i;
if (get_host_address(&i)) {
@@ -258,6 +290,14 @@ static void process_command(megawifi *mw)
end_reply(mw);
break;
}
+ case CMD_IP_CFG_GET:
+ cmd_ip_cfg_get(mw);
+ break;
+ case CMD_DEF_AP_CFG_GET:
+ start_reply(mw, CMD_OK);
+ mw_putc(mw, 0);
+ end_reply(mw);
+ break;
case CMD_AP_JOIN:
mw->module_state = STATE_READY;
start_reply(mw, CMD_OK);
@@ -338,6 +378,12 @@ static void process_command(megawifi *mw)
mw_putc(mw, mw->channel_flags);
end_reply(mw);
break;
+ case CMD_SERVER_URL_GET:
+ start_reply(mw, CMD_OK);
+ // FIXME: This should be get from config file
+ mw_puts(mw, "192.168.1.32");
+ end_reply(mw);
+ break;
default:
printf("Unhandled MegaWiFi command %s(%d) with length %X\n", cmd_names[command], command, size);
break;