所以我正在研究一些BLE 实现的教程代码,我遇到了这种我以前从未见过的语法。
&p_ble_evt->evt.gatts_evt.params.write;
这是我不确定的 &foo;bar-&baz 部分。
我尝试“搜索”代码部分,然后尝试通过https://cdecl.org/运行它。但是没有了解这段代码的作用/是什么。
/**@brief Function for handling the Write event.
*
* @param[in] p_midi_service LED Button Service structure.
* @param[in] p_ble_evt Event received from the BLE stack.
*/
static void on_write(ble_midi_service_t * p_midi_service, ble_evt_t const * p_ble_evt)
{
ble_gatts_evt_write_t * p_evt_write = (ble_gatts_evt_write_t *) &p_ble_evt->evt.gatts_evt.params.write;
if ((p_evt_write->handle == p_midi_service->data_io_char_handles.value_handle) &&
(p_evt_write->len == 1) &&
(p_midi_service->evt_handler != NULL))
{
// Handle what happens on a write event to the characteristic value
}
// Check if the Custom value CCCD is written to and that the value is the appropriate length, i.e 2 bytes.
if ((p_evt_write->handle == p_midi_service->data_io_char_handles.cccd_handle)
&& (p_evt_write->len == 2)
)
{
// CCCD written, call application event handler
if (p_midi_service->evt_handler != NULL)
{
ble_midi_evt_t evt;
if (ble_srv_is_notification_enabled(p_evt_write->data))
{
evt.evt_type = BLE_DATA_IO_EVT_NOTIFICATION_ENABLED;
}
else
{
evt.evt_type = BLE_DATA_IO_EVT_NOTIFICATION_DISABLED;
}
p_midi_service->evt_handler(p_midi_service, &evt);
}
}
}
因此,如果某个善良的灵魂能帮助启发我,那将不胜感激。
谢谢你。