mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-10 23:14:20 +00:00
BLE: fix incorrect RSSI calculation. Firmware: don't mark system as tainted on test releases. (#567)
* BLE: correct RSSI calculation routine. * Firmware: only guard boot on production releases. * BLE: proper float formatting in cli * BLE: faster RSSI refresh
This commit is contained in:
parent
54114553c1
commit
607e873404
5 changed files with 18 additions and 8 deletions
8
applications/bt/bt_cli.c
Executable file → Normal file
8
applications/bt/bt_cli.c
Executable file → Normal file
|
@ -63,15 +63,15 @@ void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
|
||||||
}
|
}
|
||||||
printf("Receiving carrier at %hu channel\r\n", channel);
|
printf("Receiving carrier at %hu channel\r\n", channel);
|
||||||
printf("Press CTRL+C to stop\r\n");
|
printf("Press CTRL+C to stop\r\n");
|
||||||
|
|
||||||
api_hal_bt_start_packet_rx(channel, 1);
|
api_hal_bt_start_packet_rx(channel, 1);
|
||||||
|
|
||||||
float rssi_raw = 0;
|
|
||||||
while(!cli_cmd_interrupt_received(cli)) {
|
while(!cli_cmd_interrupt_received(cli)) {
|
||||||
osDelay(250);
|
osDelay(1024 / 4);
|
||||||
rssi_raw = api_hal_bt_get_rssi();
|
printf("RSSI: %6.1f dB\r", api_hal_bt_get_rssi());
|
||||||
printf("RSSI: %03.1f dB\r", rssi_raw);
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
api_hal_bt_stop_packet_test();
|
api_hal_bt_stop_packet_test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#define BOOT_REQUEST_DFU 0xDF00B000
|
#define BOOT_REQUEST_DFU 0xDF00B000
|
||||||
|
|
||||||
void api_hal_boot_init() {
|
void api_hal_boot_init() {
|
||||||
|
#ifndef DEBUG
|
||||||
LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED);
|
LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_hal_boot_set_mode(ApiHalBootMode mode) {
|
void api_hal_boot_set_mode(ApiHalBootMode mode) {
|
||||||
|
|
|
@ -112,11 +112,14 @@ void api_hal_bt_start_rx(uint8_t channel) {
|
||||||
float api_hal_bt_get_rssi() {
|
float api_hal_bt_get_rssi() {
|
||||||
float val;
|
float val;
|
||||||
uint8_t rssi_raw[3];
|
uint8_t rssi_raw[3];
|
||||||
aci_hal_read_raw_rssi(rssi_raw);
|
|
||||||
|
if (aci_hal_read_raw_rssi(rssi_raw) != BLE_STATUS_SUCCESS) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Some ST magic with rssi
|
// Some ST magic with rssi
|
||||||
uint8_t agc = rssi_raw[2] & 0xFF;
|
uint8_t agc = rssi_raw[2] & 0xFF;
|
||||||
int rssi = (rssi_raw[1] << 8 & 0xFF00) + (rssi_raw[1] & 0xFF);
|
int rssi = (((int)rssi_raw[1] << 8) & 0xFF00) + (rssi_raw[0] & 0xFF);
|
||||||
if(rssi == 0 || agc > 11) {
|
if(rssi == 0 || agc > 11) {
|
||||||
val = -127.0;
|
val = -127.0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#define BOOT_REQUEST_DFU 0xDF00B000
|
#define BOOT_REQUEST_DFU 0xDF00B000
|
||||||
|
|
||||||
void api_hal_boot_init() {
|
void api_hal_boot_init() {
|
||||||
|
#ifndef DEBUG
|
||||||
LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED);
|
LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_TAINTED);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_hal_boot_set_mode(ApiHalBootMode mode) {
|
void api_hal_boot_set_mode(ApiHalBootMode mode) {
|
||||||
|
|
|
@ -112,11 +112,14 @@ void api_hal_bt_start_rx(uint8_t channel) {
|
||||||
float api_hal_bt_get_rssi() {
|
float api_hal_bt_get_rssi() {
|
||||||
float val;
|
float val;
|
||||||
uint8_t rssi_raw[3];
|
uint8_t rssi_raw[3];
|
||||||
aci_hal_read_raw_rssi(rssi_raw);
|
|
||||||
|
if (aci_hal_read_raw_rssi(rssi_raw) != BLE_STATUS_SUCCESS) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Some ST magic with rssi
|
// Some ST magic with rssi
|
||||||
uint8_t agc = rssi_raw[2] & 0xFF;
|
uint8_t agc = rssi_raw[2] & 0xFF;
|
||||||
int rssi = (rssi_raw[1] << 8 & 0xFF00) + (rssi_raw[1] & 0xFF);
|
int rssi = (((int)rssi_raw[1] << 8) & 0xFF00) + (rssi_raw[0] & 0xFF);
|
||||||
if(rssi == 0 || agc > 11) {
|
if(rssi == 0 || agc > 11) {
|
||||||
val = -127.0;
|
val = -127.0;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue