Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 47 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,64 +1,68 @@
cmake_minimum_required(VERSION 3.15)

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

project(Rtl8812auNet)

# the `pkg_check_modules` function is created with this call
# Find pkg-config and then use it to locate libusb.
find_package(PkgConfig REQUIRED)

# this calls create special `PkgConfig::LIBUSB` variables
pkg_check_modules(LIBUSB REQUIRED IMPORTED_TARGET libusb-1.0)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)

add_library(WiFiDriver
src/logger.h
src/logger.h

hal/Hal8812PhyReg.h
hal/Hal8812PwrSeq.c
hal/Hal8812PwrSeq.h
hal/basic_types.h
hal/hal8812a_fw.c
hal/hal8812a_fw.h
hal/hal_com_reg.h
hal/rtl8812a_hal.h
hal/rtl8812a_recv.h
hal/rtl8812a_spec.h
hal/Hal8812PhyReg.h
hal/Hal8812PwrSeq.c
hal/Hal8812PwrSeq.h
hal/basic_types.h
hal/hal8812a_fw.c
hal/hal8812a_fw.h
hal/hal_com_reg.h
hal/rtl8812a_hal.h
hal/rtl8812a_recv.h
hal/rtl8812a_spec.h

src/EepromManager.cpp
src/EepromManager.h
src/Firmware.h
src/FirmwareManager.cpp
src/FirmwareManager.h
src/FrameParser.cpp
src/FrameParser.h
src/HalModule.cpp
src/HalModule.h
src/ParsedRadioPacket.cpp
src/RadioManagementModule.cpp
src/RadioManagementModule.h
src/Rtl8812aDevice.cpp
src/Rtl8812aDevice.h
src/RtlUsbAdapter.cpp
src/RtlUsbAdapter.h
src/SelectedChannel.h
src/WiFiDriver.cpp
src/WiFiDriver.h
src/registry_priv.h
src/ieee80211_radiotap.h
src/EepromManager.cpp
src/EepromManager.h
src/Firmware.h
src/FirmwareManager.cpp
src/FirmwareManager.h
src/FrameParser.cpp
src/FrameParser.h
src/HalModule.cpp
src/HalModule.h
src/ParsedRadioPacket.cpp
src/RadioManagementModule.cpp
src/RadioManagementModule.h
src/Radiotap.c
src/Rtl8812aDevice.cpp
src/Rtl8812aDevice.h
src/RtlUsbAdapter.cpp
src/RtlUsbAdapter.h
src/SelectedChannel.h
src/WiFiDriver.cpp
src/WiFiDriver.h
src/registry_priv.h
)

target_compile_features(WiFiDriver PUBLIC cxx_std_20)

target_link_libraries(WiFiDriver PUBLIC
PkgConfig::LIBUSB
)
# Link WiFiDriver with libusb as found via pkg-config.
target_link_libraries(WiFiDriver PUBLIC PkgConfig::libusb)

target_include_directories(WiFiDriver PUBLIC hal)
target_include_directories(WiFiDriver PUBLIC src)

add_executable(WiFiDriverDemo
demo/main.cpp)

demo/main.cpp
)
target_link_libraries(WiFiDriverDemo PUBLIC WiFiDriver)

add_executable(WiFiDriverTxDemo
txdemo/main.cpp
)
target_link_libraries(WiFiDriverTxDemo PUBLIC WiFiDriver PRIVATE PkgConfig::libusb)
7 changes: 5 additions & 2 deletions hal/basic_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
#define _FALSE FALSE
#endif

#define le16_to_cpu(x) ((uint16_t)(x))
#define le32_to_cpu(x) ((uint32_t)(x))
#define cpu_to_le32(x) ((__u32)(x))
#define le32_to_cpu(x) ((__u32)(x))
#define cpu_to_le16(x) ((__u16)(x))
#define le16_to_cpu(x) ((__u16)(x))


#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
((LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset)) & \
Expand Down
2 changes: 2 additions & 0 deletions src/EepromManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "phydm_pre_define.h"
#include "rtl8812a_hal.h"

typedef unsigned short ushort;

class EepromManager {
RtlUsbAdapter _device;
Logger_t _logger;
Expand Down
58 changes: 56 additions & 2 deletions src/FrameParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ std::vector<Packet> FrameParser::recvbuf2recvframe(std::span<uint8_t> ptr) {
ret.push_back({pattrib, pbuf.subspan(pattrib.shift_sz +
pattrib.drvinfo_sz + RXDESC_SIZE,
pattrib.pkt_len)});
// pre_recv_entry(precvframe, pattrib.physt ? pbuf.Slice(RXDESC_OFFSET) :
// null);

ret.back().RxAtrib.rssi[0] = pbuf[RXDESC_SIZE];
ret.back().RxAtrib.rssi[1] = pbuf[RXDESC_SIZE + 1];
} else {
/* pkt_rpt_type == TX_REPORT1-CCX, TX_REPORT2-TX RTP,HIS_REPORT-USB HISR
* RTP */
Expand Down Expand Up @@ -149,3 +150,56 @@ std::vector<Packet> FrameParser::recvbuf2recvframe(std::span<uint8_t> ptr) {

return ret;
}

void rtl8812a_cal_txdesc_chksum(uint8_t *ptxdesc) {
u16 *usPtr;
u32 count;
u32 index;
u16 checksum = 0;

usPtr = (u16 *)ptxdesc;

/* checksum is always calculated by first 32 bytes, */
/* and it doesn't depend on TX DESC length. */
/* Thomas,Lucas@SD4,20130515 */
count = 16;

/* Clear first */
SET_TX_DESC_TX_DESC_CHECKSUM_8812(ptxdesc, 0);

for (index = 0; index < count; index++)
checksum = checksum ^ le16_to_cpu(*(usPtr + index));

SET_TX_DESC_TX_DESC_CHECKSUM_8812(ptxdesc, checksum);
}

int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category,
u8 *action) {
/*const u8 *frame_body = frame + sizeof(struct rtw_ieee80211_hdr_3addr);
u16 fc;
u8 c;
u8 a = ACT_PUBLIC_MAX;

fc = le16_to_cpu(((struct rtw_ieee80211_hdr_3addr *)frame)->frame_ctl);

if ((fc & (RTW_IEEE80211_FCTL_FTYPE | RTW_IEEE80211_FCTL_STYPE))
!= (RTW_IEEE80211_FTYPE_MGMT | RTW_IEEE80211_STYPE_ACTION)
)
return _FALSE;

c = frame_body[0];

switch (c) {
case RTW_WLAN_CATEGORY_P2P: // vendor-specific
break;
default:
a = frame_body[1];
}

if (category)
*category = c;
if (action)
*action = a;
*/
return _TRUE;
}
Loading