标题: 求助各位大神! [打印本页] 作者: 施玮 时间: 2025-1-11 09:38 标题: 求助各位大神! 小弟最近在学习青风nRF52832,在蓝牙串口例程里面,有这样一个函数ret_code_t blcm_link_ctx_get(blcm_link_ctx_storage_t const * const p_link_ctx_storage, uint16_t const conn_handle, void** const pp_ctx_data)。出现在串口派发函数中的多个分支回调中,似乎是为了获取刷新p_client这个变量的值,并为它指定内存空间。追踪这个变量类型ble_nus_client_context_t,发现这个结构体只包含一个成员用来指示客户端主机是否开启通知使能。回过头对比按键通知历程,发现没有用到这个函数。进一步追查,发现LED按键服务结构体里似乎没有包含指向链接上下文指针的成员。
下面是这两个结构体(指向链接上下文指针的成员p_link_ctx_storage被粗体颜色标注):
//串口服务结构体struct ble_nus_s{ uint8_t uuid_type; /**< UUID type for Nordic UART Service Base UUID. */ uint16_t service_handle; /**< Handle of Nordic UART Service (as provided by the SoftDevice). */ ble_gatts_char_handles_t tx_handles; /**< Handles related to the TX characteristic (as provided by the SoftDevice). */ ble_gatts_char_handles_t rx_handles; /**< Handles related to the RX characteristic (as provided by the SoftDevice). */ blcm_link_ctx_storage_t * const p_link_ctx_storage; /**< Pointer to link context storage with handles of all current connections and its context. */ ble_nus_data_handler_t data_handler; /**< Event handler to be called for handling received data. */};
//LED按键服务结构体
struct ble_lbs_s
{
uint16_t service_handle; /**< Handle of LED Button Service (as provided by the BLE stack). */
ble_gatts_char_handles_t led_char_handles; /**< Handles related to the LED Characteristic. */
ble_gatts_char_handles_t button_char_handles; /**< Handles related to the Button Characteristic. */
uint8_t uuid_type; /**< UUID type for the LED Button Service. */
ble_lbs_led_write_handler_t led_write_handler; /**< Event handler to be called when the LED Characteristic is written. */
};