Change GATT notify/indicate from gattc to gatts

This commit is contained in:
baohongde
2021-08-29 15:57:53 +08:00
committed by Szymon Janc
parent 336eff834e
commit ade6169bb2
15 changed files with 98 additions and 39 deletions
+2 -2
View File
@@ -264,7 +264,7 @@ gatt_svr_chr_access_sc_control_point(uint16_t conn_handle,
}
#endif
rc = ble_gattc_indicate_custom(conn_handle, csc_control_point_handle,
rc = ble_gatts_indicate_custom(conn_handle, csc_control_point_handle,
om_indication);
return rc;
@@ -321,7 +321,7 @@ gatt_svr_chr_notify_csc_measurement(uint16_t conn_handle)
om = ble_hs_mbuf_from_flat(data_buf, data_offset);
rc = ble_gattc_notify_custom(conn_handle, csc_measurement_handle, om);
rc = ble_gatts_notify_custom(conn_handle, csc_measurement_handle, om);
return rc;
}
+1 -1
View File
@@ -146,7 +146,7 @@ blehr_tx_hrate(struct os_event *ev)
om = ble_hs_mbuf_from_flat(hrm, sizeof(hrm));
rc = ble_gattc_notify_custom(conn_handle, hrs_hrm_handle, om);
rc = ble_gatts_notify_custom(conn_handle, hrs_hrm_handle, om);
assert(rc == 0);
blehr_tx_hrate_reset();
+4 -4
View File
@@ -1005,7 +1005,7 @@ rx_stress_12_gap_event(struct ble_gap_event *event, void *arg)
rx_stress_ctx->begin_us = os_get_uptime_usec();
om = os_msys_get_pkthdr(om_len, 0);
stress_fill_mbuf_with_pattern(om, om_len);
rc = ble_gattc_indicate_custom(rx_stress_ctx->conn_handle, hrs_hrm_handle,
rc = ble_gatts_indicate_custom(rx_stress_ctx->conn_handle, hrs_hrm_handle,
om);
assert(rc == 0);
return 0;
@@ -1020,7 +1020,7 @@ rx_stress_13_notify_ev_func(struct ble_npl_event *ev)
int rc;
om = ble_hs_mbuf_from_flat(test_6_pattern, 10);
rc = ble_gattc_notify_custom(rx_stress_ctx->conn_handle,
rc = ble_gatts_notify_custom(rx_stress_ctx->conn_handle,
hrs_hrm_handle, om);
assert(rc == 0);
@@ -1142,7 +1142,7 @@ rx_stress_14_gap_event(struct ble_gap_event *event, void *arg)
/* Notify data pattern */
om = ble_hs_mbuf_from_flat(test_6_pattern, bytes_num);
rc = ble_gattc_notify_custom(rx_stress_ctx->conn_handle,
rc = ble_gatts_notify_custom(rx_stress_ctx->conn_handle,
hrs_hrm_handle, om);
assert(rc == 0);
@@ -1459,7 +1459,7 @@ rx_stress_main_task_fn(void *arg)
if (i == 7 || i == 8 || i == 13) {
/* 7,8: PHY update tests cause that the device during the next test
* will stuck somewhere and will reset. Skip them for now.
* 13: Should work after fixing ble_gattc_notify_custom (nimble issue on GitHub)*/
* 13: Should work after fixing ble_gatts_notify_custom (nimble issue on GitHub)*/
continue;
}
/* Start test. */
+2 -2
View File
@@ -1978,12 +1978,12 @@ void notify_test(struct os_event *ev)
om = ble_hs_mbuf_from_flat(ntf, sizeof(ntf));
if (notify_state) {
rc = ble_gattc_notify_custom(myconn_handle, notify_handle, om);
rc = ble_gatts_notify_custom(myconn_handle, notify_handle, om);
assert(rc == 0);
}
if (indicate_state) {
rc = ble_gattc_indicate_custom(myconn_handle, notify_handle, om);
rc = ble_gatts_indicate_custom(myconn_handle, notify_handle, om);
assert(rc == 0);
}
}
+21
View File
@@ -470,6 +470,12 @@ int ble_gattc_write_reliable(uint16_t conn_handle,
*
* @return 0 on success; nonzero on failure.
*/
int ble_gatts_notify_custom(uint16_t conn_handle, uint16_t att_handle,
struct os_mbuf *om);
/**
* Deprecated. Should not be used. Use ble_gatts_notify_custom instead.
*/
int ble_gattc_notify_custom(uint16_t conn_handle, uint16_t att_handle,
struct os_mbuf *om);
@@ -485,6 +491,11 @@ int ble_gattc_notify_custom(uint16_t conn_handle, uint16_t att_handle,
*
* @return 0 on success; nonzero on failure.
*/
int ble_gatts_notify(uint16_t conn_handle, uint16_t chr_val_handle);
/**
* Deprecated. Should not be used. Use ble_gatts_notify instead.
*/
int ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle);
/**
@@ -501,6 +512,11 @@ int ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle);
*
* @return 0 on success; nonzero on failure.
*/
int ble_gatts_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
struct os_mbuf *txom);
/**
* Deprecated. Should not be used. Use ble_gatts_indicate_custom instead.
*/
int ble_gattc_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
struct os_mbuf *txom);
@@ -516,6 +532,11 @@ int ble_gattc_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
*
* @return 0 on success; nonzero on failure.
*/
int ble_gatts_indicate(uint16_t conn_handle, uint16_t chr_val_handle);
/**
* Deprecated. Should not be used. Use ble_gatts_indicate instead.
*/
int ble_gattc_indicate(uint16_t conn_handle, uint16_t chr_val_handle);
int ble_gattc_init(void);
+1 -1
View File
@@ -409,7 +409,7 @@ static int gatt_send(uint16_t conn_handle,
BT_DBG("%u bytes: %s", len, bt_hex(data, len));
om = ble_hs_mbuf_from_flat(data, len);
assert(om);
err = ble_gattc_notify_custom(conn_handle, svc_handles.prov_data_out_h, om);
err = ble_gatts_notify_custom(conn_handle, svc_handles.prov_data_out_h, om);
notify_complete();
if (!err) {
+1 -1
View File
@@ -875,7 +875,7 @@ static int proxy_send(uint16_t conn_handle,
om = ble_hs_mbuf_from_flat(data, len);
assert(om);
err = ble_gattc_notify_custom(conn_handle, svc_handles.proxy_data_out_h, om);
err = ble_gatts_notify_custom(conn_handle, svc_handles.proxy_data_out_h, om);
notify_complete();
if (!err) {
+2 -2
View File
@@ -390,7 +390,7 @@ ble_svc_ans_new_alert_notify(uint8_t cat_id, const char * info_str)
memcpy(&ble_svc_ans_new_alert_val[2], info_str, info_str_len);
}
}
return ble_gattc_notify(ble_svc_ans_conn_handle,
return ble_gatts_notify(ble_svc_ans_conn_handle,
ble_svc_ans_new_alert_val_handle);
}
@@ -407,7 +407,7 @@ ble_svc_ans_unr_alert_notify(uint8_t cat_id)
{
ble_svc_ans_unr_alert_stat[0] = cat_id;
ble_svc_ans_unr_alert_stat[1] = ble_svc_ans_unr_alert_cnt[cat_id];
return ble_gattc_notify(ble_svc_ans_conn_handle,
return ble_gatts_notify(ble_svc_ans_conn_handle,
ble_svc_ans_unr_alert_val_handle);
}
+1 -1
View File
@@ -165,7 +165,7 @@ bleuart_uart_read(void)
if (!om) {
return;
}
ble_gattc_notify_custom(g_console_conn_handle,
ble_gatts_notify_custom(g_console_conn_handle,
g_bleuart_attr_read_handle, om);
off = 0;
break;
+1 -1
View File
@@ -952,7 +952,7 @@ ble_att_clt_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom)
#endif
/* No payload. */
ble_gattc_rx_indicate_rsp(conn_handle);
ble_gatts_rx_indicate_rsp(conn_handle);
return 0;
}
+1 -1
View File
@@ -125,7 +125,7 @@ void ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
uint16_t handle, uint16_t offset,
struct os_mbuf **rxom);
void ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status);
void ble_gattc_rx_indicate_rsp(uint16_t conn_handle);
void ble_gatts_rx_indicate_rsp(uint16_t conn_handle);
void ble_gattc_rx_find_info_idata(uint16_t conn_handle,
struct ble_att_find_info_idata *idata);
void ble_gattc_rx_find_info_complete(uint16_t conn_handle, int status);
+52 -14
View File
@@ -233,7 +233,7 @@ static ble_gattc_err_fn ble_gattc_read_mult_err;
static ble_gattc_err_fn ble_gattc_write_err;
static ble_gattc_err_fn ble_gattc_write_long_err;
static ble_gattc_err_fn ble_gattc_write_reliable_err;
static ble_gattc_err_fn ble_gattc_indicate_err;
static ble_gattc_err_fn ble_gatts_indicate_err;
static ble_gattc_err_fn * const ble_gattc_err_dispatch[BLE_GATT_OP_CNT] = {
[BLE_GATT_OP_MTU] = ble_gattc_mtu_err,
@@ -250,7 +250,7 @@ static ble_gattc_err_fn * const ble_gattc_err_dispatch[BLE_GATT_OP_CNT] = {
[BLE_GATT_OP_WRITE] = ble_gattc_write_err,
[BLE_GATT_OP_WRITE_LONG] = ble_gattc_write_long_err,
[BLE_GATT_OP_WRITE_RELIABLE] = ble_gattc_write_reliable_err,
[BLE_GATT_OP_INDICATE] = ble_gattc_indicate_err,
[BLE_GATT_OP_INDICATE] = ble_gatts_indicate_err,
};
/**
@@ -308,7 +308,7 @@ static ble_gattc_tmo_fn ble_gattc_read_mult_tmo;
static ble_gattc_tmo_fn ble_gattc_write_tmo;
static ble_gattc_tmo_fn ble_gattc_write_long_tmo;
static ble_gattc_tmo_fn ble_gattc_write_reliable_tmo;
static ble_gattc_tmo_fn ble_gattc_indicate_tmo;
static ble_gattc_tmo_fn ble_gatts_indicate_tmo;
static ble_gattc_tmo_fn * const
ble_gattc_tmo_dispatch[BLE_GATT_OP_CNT] = {
@@ -326,7 +326,7 @@ ble_gattc_tmo_dispatch[BLE_GATT_OP_CNT] = {
[BLE_GATT_OP_WRITE] = ble_gattc_write_tmo,
[BLE_GATT_OP_WRITE_LONG] = ble_gattc_write_long_tmo,
[BLE_GATT_OP_WRITE_RELIABLE] = ble_gattc_write_reliable_tmo,
[BLE_GATT_OP_INDICATE] = ble_gattc_indicate_tmo,
[BLE_GATT_OP_INDICATE] = ble_gatts_indicate_tmo,
};
/**
@@ -4153,7 +4153,7 @@ done:
*****************************************************************************/
int
ble_gattc_notify_custom(uint16_t conn_handle, uint16_t chr_val_handle,
ble_gatts_notify_custom(uint16_t conn_handle, uint16_t chr_val_handle,
struct os_mbuf *txom)
{
#if !MYNEWT_VAL(BLE_GATT_NOTIFY)
@@ -4203,8 +4203,18 @@ done:
return rc;
}
/**
* Deprecated. Should not be used. Use ble_gatts_notify_custom instead.
*/
int
ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle)
ble_gattc_notify_custom(uint16_t conn_handle, uint16_t chr_val_handle,
struct os_mbuf *txom)
{
return ble_gatts_notify_custom(conn_handle, chr_val_handle, txom);
}
int
ble_gatts_notify(uint16_t conn_handle, uint16_t chr_val_handle)
{
#if !MYNEWT_VAL(BLE_GATT_NOTIFY)
return BLE_HS_ENOTSUP;
@@ -4212,11 +4222,20 @@ ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle)
int rc;
rc = ble_gattc_notify_custom(conn_handle, chr_val_handle, NULL);
rc = ble_gatts_notify_custom(conn_handle, chr_val_handle, NULL);
return rc;
}
/**
* Deprecated. Should not be used. Use ble_gatts_notify instead.
*/
int
ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle)
{
return ble_gatts_notify(conn_handle, chr_val_handle);
}
/*****************************************************************************
* $indicate *
*****************************************************************************/
@@ -4228,7 +4247,7 @@ ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle)
* error status to the application.
*/
static void
ble_gattc_indicate_err(struct ble_gattc_proc *proc, int status,
ble_gatts_indicate_err(struct ble_gattc_proc *proc, int status,
uint16_t att_handle)
{
int rc;
@@ -4252,7 +4271,7 @@ ble_gattc_indicate_err(struct ble_gattc_proc *proc, int status,
}
static void
ble_gattc_indicate_tmo(struct ble_gattc_proc *proc)
ble_gatts_indicate_tmo(struct ble_gattc_proc *proc)
{
BLE_HS_DBG_ASSERT(!ble_hs_locked_by_cur_task());
ble_gattc_dbg_assert_proc_not_inserted(proc);
@@ -4266,7 +4285,7 @@ ble_gattc_indicate_tmo(struct ble_gattc_proc *proc)
* proc.
*/
static void
ble_gattc_indicate_rx_rsp(struct ble_gattc_proc *proc)
ble_gatts_indicate_rx_rsp(struct ble_gattc_proc *proc)
{
int rc;
@@ -4297,7 +4316,7 @@ ble_gatts_indicate_fail_notconn(uint16_t conn_handle)
}
int
ble_gattc_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
ble_gatts_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
struct os_mbuf *txom)
{
#if !MYNEWT_VAL(BLE_GATT_INDICATE)
@@ -4369,10 +4388,29 @@ done:
return rc;
}
/**
* Deprecated. Should not be used. Use ble_gatts_indicate_custom instead.
*/
int
ble_gattc_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
struct os_mbuf *txom)
{
return ble_gatts_indicate_custom(conn_handle, chr_val_handle, txom);
}
int
ble_gatts_indicate(uint16_t conn_handle, uint16_t chr_val_handle)
{
return ble_gatts_indicate_custom(conn_handle, chr_val_handle, NULL);
}
/**
* Deprecated. Should not be used. Use ble_gatts_indicate instead.
*/
int
ble_gattc_indicate(uint16_t conn_handle, uint16_t chr_val_handle)
{
return ble_gattc_indicate_custom(conn_handle, chr_val_handle, NULL);
return ble_gatts_indicate(conn_handle, chr_val_handle);
}
/*****************************************************************************
@@ -4743,7 +4781,7 @@ ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status)
* active GATT procedure.
*/
void
ble_gattc_rx_indicate_rsp(uint16_t conn_handle)
ble_gatts_rx_indicate_rsp(uint16_t conn_handle)
{
#if !NIMBLE_BLE_ATT_CLT_INDICATE
return;
@@ -4754,7 +4792,7 @@ ble_gattc_rx_indicate_rsp(uint16_t conn_handle)
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
BLE_GATT_OP_INDICATE);
if (proc != NULL) {
ble_gattc_indicate_rx_rsp(proc);
ble_gatts_indicate_rx_rsp(proc);
ble_gattc_process_status(proc, BLE_HS_EDONE);
}
}
+5 -5
View File
@@ -1397,7 +1397,7 @@ ble_gatts_send_next_indicate(uint16_t conn_handle)
return BLE_HS_ENOENT;
}
rc = ble_gattc_indicate(conn_handle, chr_val_handle);
rc = ble_gatts_indicate(conn_handle, chr_val_handle);
if (rc != 0) {
return rc;
}
@@ -1635,11 +1635,11 @@ ble_gatts_tx_notifications_one_chr(uint16_t chr_val_handle)
break;
case BLE_ATT_OP_NOTIFY_REQ:
ble_gattc_notify(conn_handle, chr_val_handle);
ble_gatts_notify(conn_handle, chr_val_handle);
break;
case BLE_ATT_OP_INDICATE_REQ:
ble_gattc_indicate(conn_handle, chr_val_handle);
ble_gatts_indicate(conn_handle, chr_val_handle);
break;
default:
@@ -1782,7 +1782,7 @@ ble_gatts_bonding_restored(uint16_t conn_handle)
break;
case BLE_ATT_OP_NOTIFY_REQ:
rc = ble_gattc_notify(conn_handle, cccd_value.chr_val_handle);
rc = ble_gatts_notify(conn_handle, cccd_value.chr_val_handle);
if (rc == 0) {
cccd_value.value_changed = 0;
ble_store_write_cccd(&cccd_value);
@@ -1790,7 +1790,7 @@ ble_gatts_bonding_restored(uint16_t conn_handle)
break;
case BLE_ATT_OP_INDICATE_REQ:
ble_gattc_indicate(conn_handle, cccd_value.chr_val_handle);
ble_gatts_indicate(conn_handle, cccd_value.chr_val_handle);
break;
default:
+2 -2
View File
@@ -485,7 +485,7 @@ TEST_CASE_SELF(ble_gatt_conn_test_disconnect)
3, &attr, 1, ble_gatt_conn_test_write_rel_cb, &write_rel_arg);
TEST_ASSERT_FATAL(rc == 0);
rc = ble_gattc_indicate(3, attr_handle);
rc = ble_gatts_indicate(3, attr_handle);
TEST_ASSERT_FATAL(rc == 0);
/*** Start the procedures. */
@@ -732,7 +732,7 @@ TEST_CASE_SELF(ble_gatt_conn_test_timeout)
/*** Indication. */
ble_hs_test_util_create_conn(1, peer_addr, NULL, NULL);
rc = ble_gattc_indicate(1, attr_handle);
rc = ble_gatts_indicate(1, attr_handle);
TEST_ASSERT_FATAL(rc == 0);
ble_gatt_conn_test_util_timeout(1, NULL);
+2 -2
View File
@@ -586,7 +586,7 @@ TEST_CASE_SELF(ble_gatts_notify_test_n)
om = ble_hs_mbuf_from_flat(fourbytes, sizeof fourbytes);
TEST_ASSERT_FATAL(om != NULL);
rc = ble_gattc_notify_custom(conn_handle,
rc = ble_gatts_notify_custom(conn_handle,
ble_gatts_notify_test_chr_1_def_handle + 1,
om);
TEST_ASSERT_FATAL(rc == 0);
@@ -675,7 +675,7 @@ TEST_CASE_SELF(ble_gatts_notify_test_i)
om = ble_hs_mbuf_from_flat(fourbytes, sizeof fourbytes);
TEST_ASSERT_FATAL(om != NULL);
rc = ble_gattc_indicate_custom(conn_handle,
rc = ble_gatts_indicate_custom(conn_handle,
ble_gatts_notify_test_chr_1_def_handle + 1,
om);
TEST_ASSERT_FATAL(rc == 0);