Skip to content

Commit 0fea36b

Browse files
author
ybzhao
committed
[int][new][ble] add find my library and bluetooh part
Project: Bluetooth redmine: #6834, REDMINE-6834 ext-redmine: bug|feat#id [Description in detail] Affected branch: [master] Change-Id: Iad744fcc116fba1be45a34ca39c06d9529c00471
1 parent 1318ec3 commit 0fea36b

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

include/bf0_sibles_nvds.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,19 @@ enum app_nvds_tag
129129
#define SIFLI_NVDS_TYPE_CM 3
130130
#define SIFLI_NVDS_TYPE_BT_HOST 4
131131
#define SIFLI_NVDS_TYPE_BT_CM 5
132+
#ifdef PKG_USING_FMNA
133+
#define SIFLI_NVDS_TYPE_FIND_MY 6
134+
#endif
132135
typedef uint8_t sifli_nvds_type_t;
133136

134137

135138
#define SIFLI_NVDS_KEY_LEN_APP 512
136139
#define SIFLI_NVDS_KEY_LEN_STACK 512
137140
#define SIFLI_NVDS_KEY_LEN_CM 3072
138141
#define SIFLI_NVDS_KEY_LEN_BT_CM 512
142+
#ifdef PKG_USING_FMNA
143+
#define SIFLI_NVDS_KEY_LEN_FIND_MY 2048
144+
#endif
139145

140146

141147
typedef uint8_t nvds_tag_len_t;

lib/lib_find_my_rvds.a

529 KB
Binary file not shown.

lib/lib_find_my_rvds.lib

338 KB
Binary file not shown.

service/ble/ble_connection_manager.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#include "bt_gatt_api.h"
2424
#endif
2525

26+
#ifdef PKG_USING_FMNA
27+
#include "fmna_connection_platform.h"
28+
#endif
29+
2630

2731
//#if defined(SOC_SF32LB58X) && defined(BT_FINSH)
2832
#ifdef BT_FINSH
@@ -2143,7 +2147,27 @@ int ble_connection_manager_handler(uint16_t event_id, uint8_t *data, uint16_t le
21432147
{
21442148
cfm->found = true;
21452149
cfm->key_size = 16;
2150+
#ifdef PKG_USING_FMNA
2151+
extern bool fmna_connection_is_fmna_paired(void);
2152+
if (fmna_connection_is_fmna_paired())
2153+
{
2154+
bd_addr_t fmna_addr = fmna_get_paired_addr();
2155+
2156+
if (memcmp(fmna_addr.addr, g_bond_info.peer_addr[g_conn_manager[manager_index].bond_index].addr.addr, BD_ADDR_LEN) == 0)
2157+
{
2158+
LOG_I("USING NEW LTK");
2159+
2160+
extern uint8_t *fmna_connection_get_active_ltk(void);
2161+
rt_memcpy(&cfm->ltk, fmna_connection_get_active_ltk(), sizeof(ble_gap_sec_key_t));
2162+
}
2163+
}
2164+
else
2165+
{
2166+
rt_memcpy(&cfm->ltk, &ltk.ltk, sizeof(ble_gap_sec_key_t));
2167+
}
2168+
#else
21462169
rt_memcpy(&cfm->ltk, &ltk.ltk, sizeof(ble_gap_sec_key_t));
2170+
#endif
21472171
}
21482172
}
21492173
}

service/common/bf0_bt_nvds.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
#define SIFLI_NVDS_KEY_CM "SIF_CM"
6666
#define SIFLI_NVDS_KEY_BT_HOST "SIF_BT"
6767
#define SIFLI_NVDS_KEY_BT_CM "SIF_BT_CM"
68+
#ifdef PKG_USING_FMNA
69+
#define SIFLI_NVDS_KEY_FIND_MY "SIF_FIND_MY"
70+
#endif
6871
#define BLE_DEFAULT_BDADDR {{0x12, 0x34, 0x56, 0x78, 0xab, 0xcd}}
6972

7073

@@ -624,6 +627,19 @@ static uint8_t *sifli_nvds_read_int(sifli_nvds_type_t type, uint16_t *len)
624627

625628
break;
626629
}
630+
#ifdef PKG_USING_FMNA
631+
case SIFLI_NVDS_TYPE_FIND_MY:
632+
{
633+
ptr = bt_mem_alloc(SIFLI_NVDS_KEY_LEN_FIND_MY);
634+
if (ptr == NULL)
635+
break;
636+
637+
memset(ptr, 0, SIFLI_NVDS_KEY_LEN_FIND_MY);
638+
read_len = sifli_nvds_flash_read(SIFLI_NVDS_KEY_FIND_MY, ptr, SIFLI_NVDS_KEY_LEN_FIND_MY);
639+
OS_ASSERT(read_len <= SIFLI_NVDS_KEY_LEN_FIND_MY);
640+
break;
641+
}
642+
#endif
627643
default:
628644
break;
629645
}
@@ -752,6 +768,18 @@ uint8_t sifli_nvds_write(sifli_nvds_type_t type, uint16_t len, uint8_t *ptr)
752768
ret = sifli_nvds_flash_write(SIFLI_NVDS_KEY_BT_CM, ptr, len);
753769
break;
754770
}
771+
#ifdef PKG_USING_FMNA
772+
case SIFLI_NVDS_TYPE_FIND_MY:
773+
{
774+
if (len > SIFLI_NVDS_KEY_LEN_FIND_MY)
775+
{
776+
ret = NVDS_FAIL;
777+
break;
778+
}
779+
ret = sifli_nvds_flash_write(SIFLI_NVDS_KEY_FIND_MY, ptr, len);
780+
break;
781+
}
782+
#endif
755783
case SIFLI_NVDS_TYPE_BT_HOST:
756784
{
757785
ret = sifli_nvds_flash_write(SIFLI_NVDS_KEY_BT_HOST, ptr, len);

0 commit comments

Comments
 (0)