mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-23 13:21:44 +03:00
API for BLE Beacon app
thanks to Willy-JL
This commit is contained in:
parent
b3cce2351a
commit
d40f664342
firmware/targets
@ -1079,6 +1079,7 @@ Function,+,furi_hal_bt_serial_set_rpc_status,void,FuriHalBtSerialRpcStatus
|
|||||||
Function,+,furi_hal_bt_serial_start,void,
|
Function,+,furi_hal_bt_serial_start,void,
|
||||||
Function,+,furi_hal_bt_serial_stop,void,
|
Function,+,furi_hal_bt_serial_stop,void,
|
||||||
Function,+,furi_hal_bt_serial_tx,_Bool,"uint8_t*, uint16_t"
|
Function,+,furi_hal_bt_serial_tx,_Bool,"uint8_t*, uint16_t"
|
||||||
|
Function,+,furi_hal_bt_set_custom_adv_data,void,"const uint8_t*, size_t"
|
||||||
Function,+,furi_hal_bt_set_key_storage_change_callback,void,"BleGlueKeyStorageChangedCallback, void*"
|
Function,+,furi_hal_bt_set_key_storage_change_callback,void,"BleGlueKeyStorageChangedCallback, void*"
|
||||||
Function,+,furi_hal_bt_set_profile_adv_name,void,"FuriHalBtProfile, const char[( ( 1 + 8 + ( 8 + 1 ) ) + 1 )]"
|
Function,+,furi_hal_bt_set_profile_adv_name,void,"FuriHalBtProfile, const char[( ( 1 + 8 + ( 8 + 1 ) ) + 1 )]"
|
||||||
Function,+,furi_hal_bt_set_profile_mac_addr,void,"FuriHalBtProfile, const uint8_t[( 6 )]"
|
Function,+,furi_hal_bt_set_profile_mac_addr,void,"FuriHalBtProfile, const uint8_t[( 6 )]"
|
||||||
@ -1662,6 +1663,7 @@ Function,-,gammaf_r,float,"float, int*"
|
|||||||
Function,-,gap_get_remote_conn_rssi,uint32_t,int8_t*
|
Function,-,gap_get_remote_conn_rssi,uint32_t,int8_t*
|
||||||
Function,-,gap_get_state,GapState,
|
Function,-,gap_get_state,GapState,
|
||||||
Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*"
|
Function,-,gap_init,_Bool,"GapConfig*, GapEventCallback, void*"
|
||||||
|
Function,-,gap_set_custom_adv_data,void,"size_t, const uint8_t*"
|
||||||
Function,-,gap_start_advertising,void,
|
Function,-,gap_start_advertising,void,
|
||||||
Function,-,gap_stop_advertising,void,
|
Function,-,gap_stop_advertising,void,
|
||||||
Function,-,gap_thread_stop,void,
|
Function,-,gap_thread_stop,void,
|
||||||
|
|
@ -37,6 +37,9 @@ typedef struct {
|
|||||||
FuriThread* thread;
|
FuriThread* thread;
|
||||||
FuriMessageQueue* command_queue;
|
FuriMessageQueue* command_queue;
|
||||||
bool enable_adv;
|
bool enable_adv;
|
||||||
|
// API for BLE beacon plugin
|
||||||
|
size_t custom_adv_len;
|
||||||
|
const uint8_t* custom_adv_data;
|
||||||
} Gap;
|
} Gap;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -430,18 +433,36 @@ static void gap_advertise_start(GapState new_state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Configure advertising
|
// Configure advertising
|
||||||
status = aci_gap_set_discoverable(
|
// API For BLE beacon plugin
|
||||||
ADV_IND,
|
if(gap->custom_adv_data) {
|
||||||
min_interval,
|
// Custom adv logic from https://techryptic.github.io/2023/09/01/Annoying-Apple-Fans/
|
||||||
max_interval,
|
static const uint16_t gap_appearance = 0x0000; //GAP_APPEARANCE_UNKNOWN
|
||||||
CFG_IDENTITY_ADDRESS,
|
status = aci_gatt_update_char_value(
|
||||||
0,
|
gap->service.gap_svc_handle,
|
||||||
strlen(gap->service.adv_name),
|
gap->service.gap_svc_handle,
|
||||||
(uint8_t*)gap->service.adv_name,
|
0,
|
||||||
gap->service.adv_svc_uuid_len,
|
sizeof(gap_appearance),
|
||||||
gap->service.adv_svc_uuid,
|
(uint8_t*)&gap_appearance);
|
||||||
0,
|
status = aci_gap_set_discoverable(
|
||||||
0);
|
ADV_IND, min_interval, max_interval, CFG_IDENTITY_ADDRESS, 0, 0, NULL, 0, NULL, 0, 0);
|
||||||
|
status = aci_gap_delete_ad_type(AD_TYPE_FLAGS);
|
||||||
|
status = aci_gap_delete_ad_type(AD_TYPE_TX_POWER_LEVEL);
|
||||||
|
status = aci_gap_update_adv_data(gap->custom_adv_len, gap->custom_adv_data);
|
||||||
|
} else {
|
||||||
|
// Default adv logic
|
||||||
|
status = aci_gap_set_discoverable(
|
||||||
|
ADV_IND,
|
||||||
|
min_interval,
|
||||||
|
max_interval,
|
||||||
|
CFG_IDENTITY_ADDRESS,
|
||||||
|
0,
|
||||||
|
strlen(gap->service.adv_name),
|
||||||
|
(uint8_t*)gap->service.adv_name,
|
||||||
|
gap->service.adv_svc_uuid_len,
|
||||||
|
gap->service.adv_svc_uuid,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
}
|
||||||
if(status) {
|
if(status) {
|
||||||
FURI_LOG_E(TAG, "set_discoverable failed %d", status);
|
FURI_LOG_E(TAG, "set_discoverable failed %d", status);
|
||||||
}
|
}
|
||||||
@ -559,6 +580,13 @@ uint32_t gap_get_remote_conn_rssi(int8_t* rssi) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// API For BLE beacon plugin
|
||||||
|
|
||||||
|
void gap_set_custom_adv_data(size_t adv_len, const uint8_t* adv_data) {
|
||||||
|
gap->custom_adv_len = adv_len;
|
||||||
|
gap->custom_adv_data = adv_data;
|
||||||
|
}
|
||||||
|
|
||||||
GapState gap_get_state() {
|
GapState gap_get_state() {
|
||||||
GapState state;
|
GapState state;
|
||||||
if(gap) {
|
if(gap) {
|
||||||
|
@ -83,6 +83,8 @@ void gap_thread_stop();
|
|||||||
|
|
||||||
uint32_t gap_get_remote_conn_rssi(int8_t* rssi);
|
uint32_t gap_get_remote_conn_rssi(int8_t* rssi);
|
||||||
|
|
||||||
|
void gap_set_custom_adv_data(size_t adv_len, const uint8_t* adv_data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -483,6 +483,13 @@ uint32_t furi_hal_bt_get_conn_rssi(uint8_t* rssi) {
|
|||||||
return since;
|
return since;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// API for BLE beacon plugin
|
||||||
|
void furi_hal_bt_set_custom_adv_data(const uint8_t* adv_data, size_t adv_len) {
|
||||||
|
gap_set_custom_adv_data(adv_len, adv_data);
|
||||||
|
furi_hal_bt_stop_advertising();
|
||||||
|
furi_hal_bt_start_advertising();
|
||||||
|
}
|
||||||
|
|
||||||
void furi_hal_bt_reverse_mac_addr(uint8_t mac_addr[GAP_MAC_ADDR_SIZE]) {
|
void furi_hal_bt_reverse_mac_addr(uint8_t mac_addr[GAP_MAC_ADDR_SIZE]) {
|
||||||
uint8_t tmp;
|
uint8_t tmp;
|
||||||
for(size_t i = 0; i < GAP_MAC_ADDR_SIZE / 2; i++) {
|
for(size_t i = 0; i < GAP_MAC_ADDR_SIZE / 2; i++) {
|
||||||
|
@ -252,6 +252,9 @@ const uint8_t* furi_hal_bt_get_profile_mac_addr(FuriHalBtProfile profile);
|
|||||||
|
|
||||||
uint32_t furi_hal_bt_get_conn_rssi(uint8_t* rssi);
|
uint32_t furi_hal_bt_get_conn_rssi(uint8_t* rssi);
|
||||||
|
|
||||||
|
// API for BLE Beacon plugin
|
||||||
|
void furi_hal_bt_set_custom_adv_data(const uint8_t* adv_data, size_t adv_len);
|
||||||
|
|
||||||
void furi_hal_bt_set_profile_pairing_method(FuriHalBtProfile profile, GapPairing pairing_method);
|
void furi_hal_bt_set_profile_pairing_method(FuriHalBtProfile profile, GapPairing pairing_method);
|
||||||
|
|
||||||
GapPairing furi_hal_bt_get_profile_pairing_method(FuriHalBtProfile profile);
|
GapPairing furi_hal_bt_get_profile_pairing_method(FuriHalBtProfile profile);
|
||||||
|
Loading…
Reference in New Issue
Block a user