[FL-2580] FuriHal: add more supported radio stacks (#1301)

* FuriHal: add more supported radio stacks
* Bt: correct ble stack enum value
* Bt: update cli testing commands implementation
* Scripts: always emitting ob data to update manifest; added ob_custradio.data for non-light radio stacks
* Scripts: added stack type whitelist & disclaimer message
* ble: remove scanner
* ble: remove HCI and advances ble stacks support
* bt: correctly close RPC session before bt reinit
* Scripts: update bundler: estimating flash layout & refusing to build dangerous packages; app frame: not adding redundant log handlers
* Docs: additional details on bundling updates; fixed updater error codes
* Docs: wording fixes for OTA.md

Co-authored-by: hedger <hedger@nanode.su>
Co-authored-by: gornekich <n.gorbadey@gmail.com>
Co-authored-by: SG <who.just.the.doctor@gmail.com>
This commit is contained in:
あく
2022-06-09 18:07:42 +09:00
committed by GitHub
parent 2bd4efd044
commit 936a2f64b2
18 changed files with 280 additions and 192 deletions

View File

@@ -43,11 +43,6 @@ typedef enum {
GapCommandKillThread,
} GapCommand;
typedef struct {
GapScanCallback callback;
void* context;
} GapScan;
// Identity root key
static const uint8_t gap_irk[16] =
{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0};
@@ -56,7 +51,6 @@ static const uint8_t gap_erk[16] =
{0xfe, 0xdc, 0xba, 0x09, 0x87, 0x65, 0x43, 0x21, 0xfe, 0xdc, 0xba, 0x09, 0x87, 0x65, 0x43, 0x21};
static Gap* gap = NULL;
static GapScan* gap_scan = NULL;
static void gap_advertise_start(GapState new_state);
static int32_t gap_app(void* context);
@@ -169,23 +163,6 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification(void* pckt) {
aci_gap_slave_security_req(event->Connection_Handle);
} break;
case EVT_LE_ADVERTISING_REPORT: {
if(gap_scan) {
GapAddress address;
hci_le_advertising_report_event_rp0* evt =
(hci_le_advertising_report_event_rp0*)meta_evt->data;
for(uint8_t i = 0; i < evt->Num_Reports; i++) {
Advertising_Report_t* rep = &evt->Advertising_Report[i];
address.type = rep->Address_Type;
// Original MAC addres is in inverted order
for(uint8_t j = 0; j < sizeof(address.mac); j++) {
address.mac[j] = rep->Address[sizeof(address.mac) - j - 1];
}
gap_scan->callback(address, gap_scan->context);
}
}
} break;
default:
break;
}
@@ -550,23 +527,6 @@ GapState gap_get_state() {
return state;
}
void gap_start_scan(GapScanCallback callback, void* context) {
furi_assert(callback);
gap_scan = malloc(sizeof(GapScan));
gap_scan->callback = callback;
gap_scan->context = context;
// Scan interval 250 ms
hci_le_set_scan_parameters(1, 4000, 200, 0, 0);
hci_le_set_scan_enable(1, 1);
}
void gap_stop_scan() {
furi_assert(gap_scan);
hci_le_set_scan_enable(0, 1);
free(gap_scan);
gap_scan = NULL;
}
void gap_thread_stop() {
if(gap) {
osMutexAcquire(gap->state_mutex, osWaitForever);

View File

@@ -33,13 +33,6 @@ typedef struct {
typedef bool (*GapEventCallback)(GapEvent event, void* context);
typedef struct {
uint8_t type;
uint8_t mac[6];
} GapAddress;
typedef void (*GapScanCallback)(GapAddress address, void* context);
typedef enum {
GapStateUninitialized,
GapStateIdle,
@@ -88,10 +81,6 @@ GapState gap_get_state();
void gap_thread_stop();
void gap_start_scan(GapScanCallback callback, void* context);
void gap_stop_scan();
#ifdef __cplusplus
}
#endif

45
firmware/targets/f7/furi_hal/furi_hal_bt.c Executable file → Normal file
View File

@@ -104,15 +104,18 @@ void furi_hal_bt_unlock_core2() {
static bool furi_hal_bt_radio_stack_is_supported(const BleGlueC2Info* info) {
bool supported = false;
if(info->StackType == INFO_STACK_TYPE_BLE_HCI) {
furi_hal_bt_stack = FuriHalBtStackHciLayer;
supported = true;
} else if(info->StackType == INFO_STACK_TYPE_BLE_LIGHT) {
if(info->StackType == INFO_STACK_TYPE_BLE_LIGHT) {
if(info->VersionMajor >= FURI_HAL_BT_STACK_VERSION_MAJOR &&
info->VersionMinor >= FURI_HAL_BT_STACK_VERSION_MINOR) {
furi_hal_bt_stack = FuriHalBtStackLight;
supported = true;
}
} else if(info->StackType == INFO_STACK_TYPE_BLE_FULL) {
if(info->VersionMajor >= FURI_HAL_BT_STACK_VERSION_MAJOR &&
info->VersionMinor >= FURI_HAL_BT_STACK_VERSION_MINOR) {
furi_hal_bt_stack = FuriHalBtStackFull;
supported = true;
}
} else {
furi_hal_bt_stack = FuriHalBtStackUnknown;
}
@@ -168,6 +171,22 @@ FuriHalBtStack furi_hal_bt_get_radio_stack() {
return furi_hal_bt_stack;
}
bool furi_hal_bt_is_ble_gatt_gap_supported() {
if(furi_hal_bt_stack == FuriHalBtStackLight || furi_hal_bt_stack == FuriHalBtStackFull) {
return true;
} else {
return false;
}
}
bool furi_hal_bt_is_testing_supported() {
if(furi_hal_bt_stack == FuriHalBtStackFull) {
return true;
} else {
return false;
}
}
bool furi_hal_bt_start_app(FuriHalBtProfile profile, GapEventCallback event_cb, void* context) {
furi_assert(event_cb);
furi_assert(profile < FuriHalBtProfileNumber);
@@ -178,7 +197,7 @@ bool furi_hal_bt_start_app(FuriHalBtProfile profile, GapEventCallback event_cb,
FURI_LOG_E(TAG, "Can't start BLE App - radio stack did not start");
break;
}
if(furi_hal_bt_stack != FuriHalBtStackLight) {
if(!furi_hal_bt_is_ble_gatt_gap_supported()) {
FURI_LOG_E(TAG, "Can't start Ble App - unsupported radio stack");
break;
}
@@ -209,7 +228,7 @@ bool furi_hal_bt_start_app(FuriHalBtProfile profile, GapEventCallback event_cb,
break;
}
// Start selected profile services
if(furi_hal_bt_stack == FuriHalBtStackLight) {
if(furi_hal_bt_is_ble_gatt_gap_supported()) {
profile_config[profile].start();
}
ret = true;
@@ -411,20 +430,6 @@ void furi_hal_bt_stop_rx() {
aci_hal_rx_stop();
}
bool furi_hal_bt_start_scan(GapScanCallback callback, void* context) {
if(furi_hal_bt_stack != FuriHalBtStackHciLayer) {
return false;
}
gap_start_scan(callback, context);
return true;
}
void furi_hal_bt_stop_scan() {
if(furi_hal_bt_stack == FuriHalBtStackHciLayer) {
gap_stop_scan();
}
}
bool furi_hal_bt_ensure_c2_mode(BleGlueC2Mode mode) {
BleGlueCommandResult fw_start_res = ble_glue_force_c2_mode(mode);
if(fw_start_res == BleGlueCommandResultOK) {