aboutsummaryrefslogtreecommitdiff
path: root/src/WifiAP.cpp
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2024-04-12 17:28:51 +0200
committerArisotura <thetotalworm@gmail.com>2024-04-12 17:28:51 +0200
commit111dc7a563dc0050939f794445574a342836bdde (patch)
treec27b0dfb0870780309f381e864ba579fc8e0bee8 /src/WifiAP.cpp
parent0b87dd5fa6aa70277d07a2af301db843be9e9a01 (diff)
wifi improvements:
* implement channels * rework power-down support, fixing bugs * fix bug when W_BeaconInterval is zero * fix potential missing IRQs when writing to W_IE
Diffstat (limited to 'src/WifiAP.cpp')
-rw-r--r--src/WifiAP.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/WifiAP.cpp b/src/WifiAP.cpp
index 4c64520..855dc24 100644
--- a/src/WifiAP.cpp
+++ b/src/WifiAP.cpp
@@ -35,6 +35,7 @@ using Platform::LogLevel;
const char* WifiAP::APName = "melonAP";
const u8 WifiAP::APMac[6] = {0x00, 0xF0, 0x77, 0x77, 0x77, 0x77};
+const u8 WifiAP::APChannel = 6;
#define PWRITE_8(p, v) *p++ = v;
#define PWRITE_16(p, v) *(u16*)p = v; p += 2;
@@ -55,7 +56,7 @@ const u8 WifiAP::APMac[6] = {0x00, 0xF0, 0x77, 0x77, 0x77, 0x77};
PWRITE_16(p, 0); \
PWRITE_16(p, 0); \
PWRITE_8(p, rate); \
- PWRITE_8(p, 0); \
+ PWRITE_8(p, APChannel); \
PWRITE_16(p, len);
//#define PALIGN_4(p, base) p += ((4 - ((ptrdiff_t)(p-base) & 0x3)) & 0x3);
@@ -174,7 +175,7 @@ int WifiAP::HandleManagementFrame(const u8* data, int len)
PWRITE_16(p, 128); // beacon interval
PWRITE_16(p, 0x0021); // capability
PWRITE_8(p, 0x01); PWRITE_8(p, 0x02); PWRITE_8(p, 0x82); PWRITE_8(p, 0x84); // rates
- PWRITE_8(p, 0x03); PWRITE_8(p, 0x01); PWRITE_8(p, 0x06); // current channel
+ PWRITE_8(p, 0x03); PWRITE_8(p, 0x01); PWRITE_8(p, APChannel); // current channel
PWRITE_8(p, 0x00); PWRITE_8(p, strlen(APName));
memcpy(p, APName, strlen(APName)); p += strlen(APName);
@@ -260,6 +261,9 @@ int WifiAP::HandleManagementFrame(const u8* data, int len)
int WifiAP::SendPacket(const u8* data, int len)
{
+ if (data[9] != APChannel)
+ return 0;
+
data += 12;
u16 framectl = *(u16*)&data[0];
@@ -327,7 +331,7 @@ int WifiAP::RecvPacket(u8* data)
PWRITE_16(p, 128); // beacon interval
PWRITE_16(p, 0x0021); // capability
PWRITE_8(p, 0x01); PWRITE_8(p, 0x02); PWRITE_8(p, 0x82); PWRITE_8(p, 0x84); // rates
- PWRITE_8(p, 0x03); PWRITE_8(p, 0x01); PWRITE_8(p, 0x06); // current channel
+ PWRITE_8(p, 0x03); PWRITE_8(p, 0x01); PWRITE_8(p, APChannel); // current channel
PWRITE_8(p, 0x05); PWRITE_8(p, 0x04); PWRITE_8(p, 0); PWRITE_8(p, 0); PWRITE_8(p, 0); PWRITE_8(p, 0); // TIM
PWRITE_8(p, 0x00); PWRITE_8(p, strlen(APName));
memcpy(p, APName, strlen(APName)); p += strlen(APName);