static int nm_ble_out(struct nmgr_transport *nt, struct os_mbuf *om) { struct ble_gatt_attr attr; uint16_t conn_handle; int rc; assert(OS_MBUF_USRHDR_LEN(om) == 2); memcpy(&conn_handle, OS_MBUF_USRHDR(om), 2); assert(OS_MBUF_PKTLEN(om) <= sizeof nm_buf); rc = os_mbuf_copydata(om, 0, OS_MBUF_PKTLEN(om), nm_buf); assert(rc == 0); attr.handle = nm_attr_val_handle; attr.offset = 0; attr.value_len = OS_MBUF_PKTLEN(om); attr.value = nm_buf; rc = ble_gattc_notify_custom(conn_handle, &attr); console_printf("nm_ble_out(); conn_handle = %d notify-rc=%d\n", conn_handle, rc); return rc; }
static void nmgr_ble_event_data_in(struct os_event *ev) { struct os_mbuf *m_resp; uint16_t conn_handle; while ((m_resp = os_mqueue_get(&nmgr_ble_mq)) != NULL) { assert(OS_MBUF_USRHDR_LEN(m_resp) >= sizeof (conn_handle)); memcpy(&conn_handle, OS_MBUF_USRHDR(m_resp), sizeof (conn_handle)); ble_gattc_notify_custom(conn_handle, g_ble_nmgr_attr_handle, m_resp); } }