Skip to content

Commit d2578cd

Browse files
Devourer Experimental TX implementation (#7)
* Devourer Experimental TX implementation * Windows compatibility fixes @floppyhammer --------- Co-authored-by: imagemlt <malingtao1019@163.com>
1 parent ec14031 commit d2578cd

15 files changed

Lines changed: 2703 additions & 125 deletions

CMakeLists.txt

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,68 @@
11
cmake_minimum_required(VERSION 3.15)
22

3-
# This should go before project declaration.
4-
if (WIN32)
3+
# Set the toolchain file for vcpkg on Windows.
4+
if(WIN32)
55
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
6-
endif ()
6+
endif()
77

88
project(Rtl8812auNet)
99

10-
# the `pkg_check_modules` function is created with this call
10+
# Find pkg-config and then use it to locate libusb.
1111
find_package(PkgConfig REQUIRED)
12-
13-
# this calls create special `PkgConfig::LIBUSB` variables
14-
pkg_check_modules(LIBUSB REQUIRED IMPORTED_TARGET libusb-1.0)
12+
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
1513

1614
add_library(WiFiDriver
17-
src/logger.h
15+
src/logger.h
1816

19-
hal/Hal8812PhyReg.h
20-
hal/Hal8812PwrSeq.c
21-
hal/Hal8812PwrSeq.h
22-
hal/basic_types.h
23-
hal/hal8812a_fw.c
24-
hal/hal8812a_fw.h
25-
hal/hal_com_reg.h
26-
hal/rtl8812a_hal.h
27-
hal/rtl8812a_recv.h
28-
hal/rtl8812a_spec.h
17+
hal/Hal8812PhyReg.h
18+
hal/Hal8812PwrSeq.c
19+
hal/Hal8812PwrSeq.h
20+
hal/basic_types.h
21+
hal/hal8812a_fw.c
22+
hal/hal8812a_fw.h
23+
hal/hal_com_reg.h
24+
hal/rtl8812a_hal.h
25+
hal/rtl8812a_recv.h
26+
hal/rtl8812a_spec.h
2927

30-
src/EepromManager.cpp
31-
src/EepromManager.h
32-
src/Firmware.h
33-
src/FirmwareManager.cpp
34-
src/FirmwareManager.h
35-
src/FrameParser.cpp
36-
src/FrameParser.h
37-
src/HalModule.cpp
38-
src/HalModule.h
39-
src/ParsedRadioPacket.cpp
40-
src/RadioManagementModule.cpp
41-
src/RadioManagementModule.h
42-
src/Rtl8812aDevice.cpp
43-
src/Rtl8812aDevice.h
44-
src/RtlUsbAdapter.cpp
45-
src/RtlUsbAdapter.h
46-
src/SelectedChannel.h
47-
src/WiFiDriver.cpp
48-
src/WiFiDriver.h
49-
src/registry_priv.h
28+
src/ieee80211_radiotap.h
29+
src/EepromManager.cpp
30+
src/EepromManager.h
31+
src/Firmware.h
32+
src/FirmwareManager.cpp
33+
src/FirmwareManager.h
34+
src/FrameParser.cpp
35+
src/FrameParser.h
36+
src/HalModule.cpp
37+
src/HalModule.h
38+
src/ParsedRadioPacket.cpp
39+
src/RadioManagementModule.cpp
40+
src/RadioManagementModule.h
41+
src/Radiotap.c
42+
src/Rtl8812aDevice.cpp
43+
src/Rtl8812aDevice.h
44+
src/RtlUsbAdapter.cpp
45+
src/RtlUsbAdapter.h
46+
src/SelectedChannel.h
47+
src/WiFiDriver.cpp
48+
src/WiFiDriver.h
49+
src/registry_priv.h
5050
)
5151

5252
target_compile_features(WiFiDriver PUBLIC cxx_std_20)
5353

54-
target_link_libraries(WiFiDriver PUBLIC
55-
PkgConfig::LIBUSB
56-
)
54+
# Link WiFiDriver with libusb as found via pkg-config.
55+
target_link_libraries(WiFiDriver PUBLIC PkgConfig::libusb)
5756

5857
target_include_directories(WiFiDriver PUBLIC hal)
5958
target_include_directories(WiFiDriver PUBLIC src)
6059

6160
add_executable(WiFiDriverDemo
62-
demo/main.cpp)
63-
61+
demo/main.cpp
62+
)
6463
target_link_libraries(WiFiDriverDemo PUBLIC WiFiDriver)
64+
65+
add_executable(WiFiDriverTxDemo
66+
txdemo/main.cpp
67+
)
68+
target_link_libraries(WiFiDriverTxDemo PUBLIC WiFiDriver PRIVATE PkgConfig::libusb)

hal/basic_types.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
#define _FALSE FALSE
1919
#endif
2020

21-
#define le16_to_cpu(x) ((uint16_t)(x))
22-
#define le32_to_cpu(x) ((uint32_t)(x))
21+
#define cpu_to_le32(x) ((__u32)(x))
22+
#define le32_to_cpu(x) ((__u32)(x))
23+
#define cpu_to_le16(x) ((__u16)(x))
24+
#define le16_to_cpu(x) ((__u16)(x))
25+
2326

2427
#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
2528
((LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset)) & \

src/EepromManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "phydm_pre_define.h"
99
#include "rtl8812a_hal.h"
1010

11+
typedef unsigned short ushort;
12+
1113
class EepromManager {
1214
RtlUsbAdapter _device;
1315
Logger_t _logger;

src/FrameParser.cpp

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ std::vector<Packet> FrameParser::recvbuf2recvframe(std::span<uint8_t> ptr) {
118118
ret.push_back({pattrib, pbuf.subspan(pattrib.shift_sz +
119119
pattrib.drvinfo_sz + RXDESC_SIZE,
120120
pattrib.pkt_len)});
121-
// pre_recv_entry(precvframe, pattrib.physt ? pbuf.Slice(RXDESC_OFFSET) :
122-
// null);
121+
122+
ret.back().RxAtrib.rssi[0] = pbuf[RXDESC_SIZE];
123+
ret.back().RxAtrib.rssi[1] = pbuf[RXDESC_SIZE + 1];
123124
} else {
124125
/* pkt_rpt_type == TX_REPORT1-CCX, TX_REPORT2-TX RTP,HIS_REPORT-USB HISR
125126
* RTP */
@@ -149,3 +150,56 @@ std::vector<Packet> FrameParser::recvbuf2recvframe(std::span<uint8_t> ptr) {
149150

150151
return ret;
151152
}
153+
154+
void rtl8812a_cal_txdesc_chksum(uint8_t *ptxdesc) {
155+
u16 *usPtr;
156+
u32 count;
157+
u32 index;
158+
u16 checksum = 0;
159+
160+
usPtr = (u16 *)ptxdesc;
161+
162+
/* checksum is always calculated by first 32 bytes, */
163+
/* and it doesn't depend on TX DESC length. */
164+
/* Thomas,Lucas@SD4,20130515 */
165+
count = 16;
166+
167+
/* Clear first */
168+
SET_TX_DESC_TX_DESC_CHECKSUM_8812(ptxdesc, 0);
169+
170+
for (index = 0; index < count; index++)
171+
checksum = checksum ^ le16_to_cpu(*(usPtr + index));
172+
173+
SET_TX_DESC_TX_DESC_CHECKSUM_8812(ptxdesc, checksum);
174+
}
175+
176+
int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category,
177+
u8 *action) {
178+
/*const u8 *frame_body = frame + sizeof(struct rtw_ieee80211_hdr_3addr);
179+
u16 fc;
180+
u8 c;
181+
u8 a = ACT_PUBLIC_MAX;
182+
183+
fc = le16_to_cpu(((struct rtw_ieee80211_hdr_3addr *)frame)->frame_ctl);
184+
185+
if ((fc & (RTW_IEEE80211_FCTL_FTYPE | RTW_IEEE80211_FCTL_STYPE))
186+
!= (RTW_IEEE80211_FTYPE_MGMT | RTW_IEEE80211_STYPE_ACTION)
187+
)
188+
return _FALSE;
189+
190+
c = frame_body[0];
191+
192+
switch (c) {
193+
case RTW_WLAN_CATEGORY_P2P: // vendor-specific
194+
break;
195+
default:
196+
a = frame_body[1];
197+
}
198+
199+
if (category)
200+
*category = c;
201+
if (action)
202+
*action = a;
203+
*/
204+
return _TRUE;
205+
}

0 commit comments

Comments
 (0)