[FL-580] Prepare BLE for certification (#376)

* api-hal-bt: separate bt init to core init and app start

* bt: add continuous TX and RX tests

* bt: finish rx test on Back button click

* api-hal-bt: check core 2 started, same f4 and f5 implementation

* bt: refactoring, move hopping test logic to main thread

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich
2021-03-11 12:31:07 +03:00
committed by GitHub
parent b920248693
commit 0af6c9882e
13 changed files with 601 additions and 9 deletions

View File

@@ -4,6 +4,7 @@
#include <stm32wbxx.h>
#include <shci.h>
#include <cmsis_os2.h>
#include <app_ble.h>
void api_hal_bt_init() {
// Explicitly tell that we are in charge of CLK48 domain
@@ -12,6 +13,10 @@ void api_hal_bt_init() {
APPE_Init();
}
bool api_hal_bt_start_app() {
return APP_BLE_Start();
}
void api_hal_bt_dump_state(string_t buffer) {
BleGlueStatus status = APPE_Status();
if (status == BleGlueStatusStarted) {
@@ -76,3 +81,29 @@ void api_hal_bt_unlock_flash() {
HAL_HSEM_Release(CFG_HW_FLASH_SEMID, HSEM_CPU1_COREID);
}
}
void api_hal_bt_start_tone_tx(uint8_t tx_channel, uint8_t power) {
aci_hal_set_tx_power_level(0, power);
aci_hal_tone_start(tx_channel, 0);
}
void api_hal_bt_stop_tone_tx() {
aci_hal_tone_stop();
}
void api_hal_bt_start_packet_tx(uint8_t frequency, uint8_t datarate) {
hci_le_enhanced_transmitter_test(frequency, 0x25, 2, datarate);
}
void api_hal_bt_stop_packet_tx() {
uint16_t num_of_packets;
hci_le_test_end(&num_of_packets);
}
void api_hal_bt_start_rx(uint8_t frequency) {
aci_hal_rx_start(frequency);
}
void api_hal_bt_stop_rx() {
aci_hal_rx_stop();
}

View File

@@ -1,5 +1,6 @@
#include "main.h"
#include "app_entry.h"
#include "app_common.h"
#include "dbg_trace.h"
#include "ble.h"
@@ -158,7 +159,11 @@ bool APP_BLE_Init() {
// Register the hci transport layer to handle BLE User Asynchronous Events
HciUserEvtProcessId = osThreadNew(HciUserEvtProcess, NULL, &HciUserEvtProcess_attr);
// Starts the BLE Stack on CPU2
if (SHCI_C2_BLE_Init( &ble_init_cmd_packet ) != SHCI_Success) {
return (SHCI_C2_BLE_Init( &ble_init_cmd_packet ) == SHCI_Success);
}
bool APP_BLE_Start() {
if (APPE_Status() != BleGlueStatusStarted) {
return false;
}
// Initialization of HCI & GATT & GAP layer

View File

@@ -18,6 +18,7 @@ typedef enum {
} APP_BLE_ConnStatus_t;
bool APP_BLE_Init();
bool APP_BLE_Start();
APP_BLE_ConnStatus_t APP_BLE_Get_Server_Connection_Status();