-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rtl872x] Implement WiFi.selectAntenna #2651
Conversation
hal/network/ncp/wifi/wlan_hal.cpp
Outdated
} | ||
|
||
WLanSelectAntenna_TypeDef wlan_get_antenna(void* reserved) { | ||
return ANT_AUTO; | ||
return current_antenna; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setting is already saved in DCT (DCT_RADIO_ANTENNA_OFFSET
). Just needs to be exposed in radio_common
stuff.
hal/src/rtl872x/radio_common.cpp
Outdated
} | ||
uint8_t dctAntenna = 0xff; | ||
CHECK(dct_read_app_data_copy(DCT_RADIO_ANTENNA_OFFSET, &dctAntenna, sizeof(dctAntenna))); | ||
if ((radio_antenna_type)dctAntenna <= RADIO_ANT_EXTERNAL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we validate the DCT data or just return it if its present?
hal/src/rtl872x/radio_common.h
Outdated
* @param antenna Currently configured Antenna type. | ||
* @return 0 on success or a negative result code in case of an error. | ||
*/ | ||
int getRadioAntenna(radio_antenna_type * antenna); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit/style: radio_antenna_type* antenna
, same above
hal/src/rtl872x/radio_common.cpp
Outdated
return SYSTEM_ERROR_INVALID_ARGUMENT; | ||
} | ||
uint8_t dctAntenna = 0xff; | ||
CHECK(dct_read_app_data_copy(DCT_RADIO_ANTENNA_OFFSET, &dctAntenna, sizeof(dctAntenna))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd do exactly the same thing as currently done in initRadioAntenna()
and return default normally unless dct read value is exactly INTERNAL or EXTERNAL and replace that block with getRadioAntenna() so that we don't have duplicate logic.
Problem
WiFi.selectAntenna()
is not implemented for P2Solution
On P2, BLE and WiFi share the same physical antenna, so use
selectAntenna()
fromradio_common.cpp
Steps to Test
Use test app below to verify antenna switches
Example App
Test output with no external antenna
Switching from Auto / Internal to external shows a drop in RSSI
Completeness