top中获取蓝牙地址
+extern const struct bd_addr co_null_bdaddr;
+/// Device BD address
+struct bd_addr dev_bdaddr_addr __attribute__((section("retention_mem_area0"), zero_init));
+void nvds_read_bdaddr_from_otp_addr()
+{
+ const uint16_t BDADDR_OFFSET = 0x7fd4;
+
+# ifndef APP_BOOT_FROM_OTP
+ int cnt = 100000;
+#define XPMC_MODE_MREAD 0x1
+ uint8_t *otp_bdaddr = (uint8_t *)0x40000 + BDADDR_OFFSET;
+
+ SetBits16(CLK_AMBA_REG, OTP_ENABLE, 1); // enable OTP clock
+ while ((GetWord16(ANA_STATUS_REG) & LDO_OTP_OK) != LDO_OTP_OK && cnt--)
+
+ SetWord32(OTPC_MODE_REG, XPMC_MODE_MREAD);
+# else
+ uint8_t *otp_bdaddr = (uint8_t *)0x20000000 + BDADDR_OFFSET; //where in OTP header is BDADDR
+# endif
+
+ memcpy(&dev_bdaddr_addr, otp_bdaddr, sizeof(dev_bdaddr_addr));
+ SetBits16(CLK_AMBA_REG, OTP_ENABLE, 0); //disable OTP clock
+}
修改广播
#endif //(NVDS_SUPPORT)
{
cmd->info.host.adv_data_len = APP_ADV_DATA_LEN;
- memcpy(&cmd->info.host.adv_data[0], APP_ADV_DATA, cmd->info.host.adv_data_len);
+ memcpy(&cmd->info.host.adv_data[0],APP_ADV_DATA, cmd->info.host.adv_data_len);
}
-
+
+ /**************************************************************/
+ // cmd->info.host.adv_data_len = 6;
+ //memcpy(&cmd->info.host.adv_data[1], (uint8_t *)nvds_read_bdaddr_from_otp_st(), cmd->info.host.adv_data_len);
+ /****************************************************************/
+ nvds_read_bdaddr_from_otp_addr();
// Scan Response Data
#if (NVDS_SUPPORT)
if(nvds_get(NVDS_TAG_APP_BLE_SCAN_RESP_DATA, &cmd->info.host.scan_rsp_data_len,
&cmd->info.host.scan_rsp_data[0]) != NVDS_OK)
#endif //(NVDS_SUPPORT)
{
- cmd->info.host.scan_rsp_data_len = APP_SCNRSP_DATA_LENGTH;
- memcpy(&cmd->info.host.scan_rsp_data[0], APP_SCNRSP_DATA, cmd->info.host.scan_rsp_data_len);
+ // cmd->info.host.scan_rsp_data_len = APP_SCNRSP_DATA_LENGTH;
+ // memcpy(&cmd->info.host.scan_rsp_data[0], APP_SCNRSP_DATA, cmd->info.host.scan_rsp_data_len);
+ uint8_t manufacture_info[8];
+ cmd->info.host.scan_rsp_data_len = 8;
+ manufacture_info[0]= 0x07;
+ manufacture_info[1]= GAP_AD_TYPE_MANU_SPECIFIC_DATA;
+
+ extern const struct nvds_data_struct nvds_data_storage;
+ int k;
+ for(k=0;k<6;k++){
+ manufacture_info[2+k] = dev_bdaddr_addr.addr[5-k];//nvds_data_storage.NVDS_TAG_BD_ADDRESS[5-k];
+ }
+ memcpy(&cmd->info.host.scan_rsp_data[0], manufacture_info, cmd->info.host.scan_rsp_data_len);
}