Skip to content

Commit

Permalink
update v0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed May 18, 2021
1 parent 5d50ce9 commit f9d098a
Show file tree
Hide file tree
Showing 127 changed files with 3,277 additions and 114 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export SoC?=bd19
#export APP_CASE?=qcy_case
#export APP_CASE?=soundbox
#export APP_CASE?=dongle
export APP_CASE?=spp_and_le
#export APP_CASE?=hid
#export APP_CASE?=spp_and_le
export APP_CASE?=hid
#export APP_CASE?=mesh
#export APP_CASE?=watch
#export APP_CASE?=iot
Expand Down
5 changes: 5 additions & 0 deletions apps/common/include/bt_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ extern uint32_t little_endian_read_24(const uint8_t *buffer, int pos);
extern uint32_t little_endian_read_32(const uint8_t *buffer, int pos);
extern void swapX(const uint8_t *src, uint8_t *dst, int len);

extern void little_endian_store_16(uint8_t *buffer, uint16_t pos, uint16_t value);
extern void little_endian_store_32(uint8_t *buffer, uint16_t pos, uint32_t value);
extern void big_endian_store_16(uint8_t *buffer, uint16_t pos, uint16_t value);
extern void big_endian_store_32(uint8_t *buffer, uint16_t pos, uint32_t value);

//common api
extern void bt_ble_init(void);
Expand Down Expand Up @@ -101,6 +105,7 @@ BR23: rang(0~9) {-15.7, -12.5, -10.0, -6.6, -4.4, -2.5, -0.1, +2.1, +4.6
BR25: rang(0~9) {-15.7, -12.5, -10.0, -6.6, -4.4, -2.5, -0.1, +2.1, +4.6, +6.4}
BR30: rang(0~8) {-17.48, -11.46, -7.96, -3.59, -0.79, +1.12, +3.8, +6.5, +8.44}
*/
//初始化配置蓝牙发射功率最大值范围,解析详见 btcontroller_modules.h
void bt_max_pwr_set(u8 pwr, u8 pg_pwr, u8 iq_pwr, u8 ble_pwr);

#endif
6 changes: 6 additions & 0 deletions apps/common/third_party_profile/jieli/le_client_demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define _LE_CLIENT_DEMO_H

#include <stdint.h>
#include "btstack/le/att.h"

//搜索匹配连接方式
typedef enum {
Expand All @@ -30,6 +31,9 @@ typedef struct {
u8 services_uuid128[16];
u8 characteristic_uuid128[16];
u16 opt_type; //属性
u8 read_long_enable: 1; //en
u8 read_report_reference: 1; //en
u8 res_bits: 6; //
} target_uuid_t;

//搜索操作记录的 handle
Expand Down Expand Up @@ -72,5 +76,7 @@ void client_clear_bonding_info(void);
void client_send_conn_param_update(void);
void ble_module_enable(u8 en);
struct ble_client_operation_t *ble_get_client_operation_table(void);
void bt_ble_init(void);
void bt_ble_adv_enable(u8 enable);

#endif
2 changes: 1 addition & 1 deletion apps/common/third_party_profile/jieli/le_hogp.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define _LE_HOGP_H

#include <stdint.h>
#include "board_config.h"
#include "app_config.h"

//
// gatt profile include file, generated by jieli gatt_inc_generator.exe
Expand Down
96 changes: 52 additions & 44 deletions apps/common/third_party_profile/jieli/multi_demo/le_multi_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,25 +175,38 @@ static bool check_device_is_match(u8 info_type, u8 *data, int size)
static void conn_pair_vm_do(struct pair_info_t *info, u8 rw_flag)
{
/* return; */

int ret;
int vm_len = sizeof(struct pair_info_t);
int unit_len = sizeof(struct pair_info_t);
int i;

log_info("-conn_pair_info vm_do:%d\n", rw_flag);

if (SUPPORT_MAX_CLIENT > 1) {
int i;
if (rw_flag == 0) {
if (unit_len * SUPPORT_MAX_CLIENT != syscfg_read(CFG_BLE_MODE_INFO, (u8 *)conn_pair_info_table, unit_len * SUPPORT_MAX_CLIENT)) {
log_info("-table null--\n");
memset(conn_pair_info_table, 0, sizeof(conn_pair_info_table));
}

if (rw_flag == 0) {
if (vm_len * SUPPORT_MAX_CLIENT != syscfg_read(CFG_BLE_MODE_INFO, (u8 *)conn_pair_info_table, vm_len * SUPPORT_MAX_CLIENT)) {
log_info("-table null--\n");
memset(&conn_pair_info_table, 0, sizeof(conn_pair_info_table));
} else {
memcpy(info, &conn_pair_info_table[0], vm_len);
for (i = 0; i < SUPPORT_MAX_CLIENT; i++) {
if (conn_pair_info_table[i].head_tag != BLE_VM_HEAD_TAG
|| conn_pair_info_table[i].tail_tag != BLE_VM_TAIL_TAG) {
//invail pair
memset(&conn_pair_info_table[i], 0, unit_len);
}
}

if (info) {
memcpy(info, &conn_pair_info_table[0], unit_len);
}
} else {
int fill_index = 0;

if (!info) {
log_info("-table clean--\n");
memset(conn_pair_info_table, 0, sizeof(conn_pair_info_table));
} else {
int fill_index = 0;
for (i = 0; i < SUPPORT_MAX_CLIENT; i++) {
if (0 == memcmp(info, &conn_pair_info_table[i], vm_len)) {
if (0 == memcmp(info, &conn_pair_info_table[i], unit_len)) {
return;
}
}
Expand All @@ -204,42 +217,23 @@ static void conn_pair_vm_do(struct pair_info_t *info, u8 rw_flag)
break;
}
}
memcpy(&conn_pair_info_table[fill_index], info, vm_len);
syscfg_write(CFG_BLE_MODE_INFO, (u8 *)conn_pair_info_table, vm_len * SUPPORT_MAX_CLIENT);
}
put_buf(conn_pair_info_table, vm_len * SUPPORT_MAX_CLIENT);
return;
}

if (rw_flag == 0) {
ret = syscfg_read(CFG_BLE_MODE_INFO, (u8 *)info, vm_len);
if (!ret) {
log_info("-null--\n");
memcpy(&conn_pair_info_table[fill_index], info, unit_len);
conn_pair_info_table[fill_index].head_tag = BLE_VM_HEAD_TAG;
conn_pair_info_table[fill_index].tail_tag = BLE_VM_TAIL_TAG;
}
if ((BLE_VM_HEAD_TAG == info->head_tag) && (BLE_VM_TAIL_TAG == info->tail_tag)) {
log_info("-exist--\n");
log_info_hexdump((u8 *)info, vm_len);
} else {
memset(info, 0, vm_len);
info->head_tag = BLE_VM_HEAD_TAG;
info->tail_tag = BLE_VM_TAIL_TAG;
}
memcpy(&conn_pair_info_table[0], info, vm_len);
} else {
syscfg_write(CFG_BLE_MODE_INFO, (u8 *)info, vm_len);
syscfg_write(CFG_BLE_MODE_INFO, (u8 *)conn_pair_info_table, unit_len * SUPPORT_MAX_CLIENT);
}
put_buf(conn_pair_info_table, unit_len * SUPPORT_MAX_CLIENT);
}

void client_clear_bonding_info(void)
{
log_info("client_clear_bonding_info\n");
conn_pair_vm_do(&conn_pair_info, 0);
if (conn_pair_info.pair_flag) {
//del pair bond
memset(&conn_pair_info, 0, sizeof(struct pair_info_t));
memset(&conn_pair_info_table, 0, sizeof(conn_pair_info_table));
conn_pair_vm_do(&conn_pair_info, 1);
}
//del pair bond
memset(&conn_pair_info, 0, sizeof(struct pair_info_t));
conn_pair_info.head_tag = BLE_VM_HEAD_TAG;
conn_pair_info.tail_tag = BLE_VM_TAIL_TAG;
conn_pair_vm_do(NULL, 1);
}

//------------------------------------------------------------
Expand Down Expand Up @@ -364,10 +358,11 @@ static void do_operate_search_handle(void)

for (i = 0; i < opt_handle_used_cnt; i++) {
opt_hdl_pt = &opt_handle_table[i];
log_info("do opt:service_uuid16:%04x,charactc_uuid16:%04x\n", opt_hdl_pt->search_uuid->services_uuid16, opt_hdl_pt->search_uuid->characteristic_uuid16);
cur_opt_type = opt_hdl_pt->search_uuid->opt_type;
switch ((u8)cur_opt_type) {
case ATT_PROPERTY_READ:
if (1) {
if (opt_hdl_pt->search_uuid->read_long_enable) {
tmp_16 = 0x55A2;//fixed
log_info("read_long:%04x\n", opt_hdl_pt->value_handle);
client_operation_send(opt_hdl_pt->value_handle, (u8 *)&tmp_16, 2, ATT_OP_READ_LONG);
Expand All @@ -382,6 +377,11 @@ static void do_operate_search_handle(void)
tmp_16 = 0x01;//fixed
log_info("write_ntf_ccc:%04x\n", opt_hdl_pt->value_handle);
client_operation_send(opt_hdl_pt->value_handle + 1, &tmp_16, 2, ATT_OP_WRITE);
if (opt_hdl_pt->search_uuid->read_report_reference) {
tmp_16 = 0x55A1;//fixed
log_info("read_report_reference:%04x\n", opt_hdl_pt->value_handle + 2);
client_operation_send(opt_hdl_pt->value_handle + 2, (u8 *)&tmp_16, 2, ATT_OP_READ);
}
break;

case ATT_PROPERTY_INDICATE:
Expand All @@ -408,6 +408,10 @@ int l2cap_connection_update_request_just(u8 *packet, hci_con_handle_t handle)
handle,
little_endian_read_16(packet, 0), little_endian_read_16(packet, 2),
little_endian_read_16(packet, 4), little_endian_read_16(packet, 6));

//change param
/* little_endian_store_16(packet, 4,0); */
/* little_endian_store_16(packet, 6,400); */
return 0;
/* return 1; */
}
Expand Down Expand Up @@ -1010,6 +1014,7 @@ void client_cbk_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p
client_event_report(CLI_EVENT_CONNECTED, packet, size);

if (pair_bond_enable) {
log_info("bond remoter\n");
conn_pair_info.pair_flag = 1;
memcpy(&conn_pair_info.peer_address_info, &packet[7], 7);
conn_pair_vm_do(&conn_pair_info, 1);
Expand Down Expand Up @@ -1073,7 +1078,7 @@ void client_cbk_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p
cur_dev_cid = tmp_index;

//auto to do
if (conn_pair_info.pair_flag && SUPPORT_MAX_CLIENT < 2) {
if (0) { //(conn_pair_info.pair_flag && SUPPORT_MAX_CLIENT < 2) {
client_create_connect_api(0, 0, 1);
} else {
bt_ble_scan_enable(0, 1);
Expand Down Expand Up @@ -1477,7 +1482,10 @@ void client_profile_init(void)
gatt_client_init();
gatt_client_register_packet_handler(client_cbk_packet_handler);
memset(&conn_pair_info, 0, sizeof(struct pair_info_t));
memset(&conn_pair_info_table, 0, sizeof(conn_pair_info_table));
memset(conn_pair_info_table, 0, sizeof(conn_pair_info_table));
conn_pair_info.head_tag = BLE_VM_HEAD_TAG;
conn_pair_info.tail_tag = BLE_VM_TAIL_TAG;

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ static u32 server_timer_handle = 0;
static u8 test_data_start;
#endif

/*
打开流控使能后,确定使能接口 att_server_flow_enable 被调用
然后使用过程 通过接口 att_server_flow_hold 来控制流控开关
注意:流控只能控制对方使用带响应READ/WRITE等命令方式
例如:ATT_WRITE_REQUEST = 0x12
*/
#define ATT_DATA_RECIEVT_FLOW 0//流控功能使能

//---------------
// 广播周期 (unit:0.625ms)
#define ADV_INTERVAL_MIN (160*5)
Expand Down Expand Up @@ -816,17 +824,34 @@ static int app_send_user_data(u16 handle, u8 *data, u16 len, u8 handle_type)
}

//------------------------------------------------------
#if RCSP_BTMATE_EN
static u8 tag_in_adv;
#endif

static int make_set_adv_data(void)
{
u8 offset = 0;
u8 *buf = adv_data;


/* offset += make_eir_packet_val(&buf[offset], offset, HCI_EIR_DATATYPE_FLAGS, 0x18, 1); */
/* offset += make_eir_packet_val(&buf[offset], offset, HCI_EIR_DATATYPE_FLAGS, 0x1A, 1); */
#if DOUBLE_BT_SAME_MAC
offset += make_eir_packet_val(&buf[offset], offset, HCI_EIR_DATATYPE_FLAGS, 0x0A, 1);
#else
offset += make_eir_packet_val(&buf[offset], offset, HCI_EIR_DATATYPE_FLAGS, 0x06, 1);
#endif

offset += make_eir_packet_val(&buf[offset], offset, HCI_EIR_DATATYPE_COMPLETE_16BIT_SERVICE_UUIDS, 0xAF30, 2);

#if RCSP_BTMATE_EN
u8 tag_len = sizeof(user_tag_string);
if (tag_len > ADV_RSP_PACKET_MAX - (offset + 2)) {
tag_in_adv = 0;
} else {
offset += make_eir_packet_data(&buf[offset], offset, HCI_EIR_DATATYPE_MANUFACTURER_SPECIFIC_DATA, (void *)user_tag_string, tag_len);
tag_in_adv = 1;
}
#endif

if (offset > ADV_RSP_PACKET_MAX) {
puts("***adv_data overflow!!!!!!\n");
return -1;
Expand All @@ -844,8 +869,10 @@ static int make_set_rsp_data(void)
u8 *buf = scan_rsp_data;

#if RCSP_BTMATE_EN
u8 tag_len = sizeof(user_tag_string);
offset += make_eir_packet_data(&buf[offset], offset, HCI_EIR_DATATYPE_MANUFACTURER_SPECIFIC_DATA, (void *)user_tag_string, tag_len);
if (!tag_in_adv) {
u8 tag_len = sizeof(user_tag_string);
offset += make_eir_packet_data(&buf[offset], offset, HCI_EIR_DATATYPE_MANUFACTURER_SPECIFIC_DATA, (void *)user_tag_string, tag_len);
}
#endif

u8 name_len = gap_device_name_len;
Expand Down Expand Up @@ -1218,27 +1245,66 @@ void ble_module_enable(u8 en)
}
}


//流控使能 EN: 1-停止收数 or 0-继续收数
int ble_trans_flow_enable(u8 en)
{
int ret = -1;
#if ATT_DATA_RECIEVT_FLOW
if (con_handle) {
att_server_flow_hold(con_handle, en);
ret = 0;
}
#endif
log_info("ble_trans_flow_enable:%d,%d\n", en, ret);
return ret;
}

//for test
static void timer_trans_flow_test(void)
{
static u8 sw = 0;
if (con_handle) {
sw = !sw;
ble_trans_flow_enable(sw);
}
}

static const char ble_ext_name[] = "(BLE)";

void bt_ble_init(void)
{
log_info("***** ble_init******\n");
const char *name_p;
char *name_p;

#if DOUBLE_BT_SAME_NAME
u8 ext_name_len = 0;
#else
u8 ext_name_len = sizeof(ble_ext_name) - 1;
#endif

name_p = bt_get_local_name();
gap_device_name_len = strlen(name_p);
if (gap_device_name_len > BT_NAME_LEN_MAX - ext_name_len) {
gap_device_name_len = BT_NAME_LEN_MAX - ext_name_len;
}

//增加后缀,区分名字
memcpy(gap_device_name, name_p, gap_device_name_len);

#if DOUBLE_BT_SAME_NAME == 0
//增加后缀,区分名字
memcpy(&gap_device_name[gap_device_name_len], "(BLE)", ext_name_len);
gap_device_name_len += ext_name_len;
#endif

log_info("ble name(%d): %s \n", gap_device_name_len, gap_device_name);

#if ATT_DATA_RECIEVT_FLOW
log_info("att_server_flow_enable\n");
att_server_flow_enable(1);
/* sys_timer_add(0, timer_trans_flow_test, 3000); */
#endif

set_ble_work_state(BLE_ST_INIT_OK);
ble_module_enable(1);

Expand Down
8 changes: 4 additions & 4 deletions apps/common/update/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ void updata_parm_set(UPDATA_TYPE up_type, void *priv, u32 len)
memcpy(p->file_path, updata_file_name, strlen(updata_file_name));
if (priv) {
if (support_norflash_update_en) {
printf("p->parm_priv:0x%x\n len:%d\n", (u32)p->parm_priv, len);
printf("p->parm_priv:0x%x\n len:%d\n", p->parm_priv, len);
memcpy(p->parm_priv + 12, priv, len);
} else {
printf("p->parm_priv:0x%x priv:0x%x len:%d\n", (u32)p->parm_priv, (u32)priv, len);
printf("p->parm_priv:0x%x priv:0x%x len:%d\n", p->parm_priv, priv, len);
memcpy(p->parm_priv, priv, len);
}
} else {
Expand Down Expand Up @@ -322,7 +322,7 @@ void updata_parm_set(UPDATA_TYPE up_type, void *priv, u32 len)
}

p->parm_crc = CRC16(((u8 *)p) + 2, sizeof(UPDATA_PARM) - 2); //2 : crc_val
printf("UPDATA_PARM_ADDR = 0x%x\n", (u32)p);
printf("UPDATA_PARM_ADDR = 0x%x\n", p);
printf_buf((void *)p, sizeof(UPDATA_PARM));
printf("exif_addr:0x%x\n", *(u32 *)(p->parm_priv));
}
Expand Down Expand Up @@ -573,7 +573,7 @@ void update_mode_api_v2(UPDATA_TYPE type, void (*priv_param_fill_hdl)(UPDATA_PAR
update_param_content_fill(type, p, priv_param_fill_hdl);

if (succ_report.update_param_write_hdl) {
succ_report.update_param_write_hdl(succ_report.priv_param, (u8*)p, update_param_len);
succ_report.update_param_write_hdl(succ_report.priv_param, p, update_param_len);
}

#ifdef UPDATE_LED_REMIND
Expand Down
Loading

0 comments on commit f9d098a

Please sign in to comment.