void FMPL_QueryGattService(FmpChannel *channel) { BtStatus status; BtDeviceRecord record; OS_LockStack(); /* check service database first */ if (SEC_FindDeviceRecord(&channel->link->bdAddr, &record) == BT_STATUS_SUCCESS) // bonded device { if (FmpReadServiceDB(&channel->link->bdAddr, &channel->servicedb) == BT_STATUS_SUCCESS) { FmpAppCallback(channel, FMPEVENT_GATT_QUERY_CNF, BT_STATUS_SUCCESS, 0, 0); return; } } else { FmpRemoveServiceDB(&channel->link->bdAddr); } channel->servicedb = (FmpServiceDB *)fmp_malloc(sizeof(FmpServiceDB)); if (channel->servicedb == NULL) { FmpAppCallback(channel, FMPEVENT_GATT_QUERY_CNF, BT_STATUS_NO_RESOURCES, 0, 0); return; } OS_MemSet((U8 *)channel->servicedb, 0, sizeof(FmpServiceDB)); channel->servicedb->bt_addr = channel->link->bdAddr; kal_trace(BT_TRACE_BLE_PROFILES, FMP_QUEREYGATTSERVICE); /* search IAS service */ status = FmplFindPrimaryServicesByUuid(channel, BT_UUID_GATT_SERVICE_ALERT, 0x0001, 0xffff); if (status != BT_STATUS_PENDING && status != BT_STATUS_SUCCESS) { fmp_free(channel->servicedb); FmpAppCallback(channel, FMPEVENT_GATT_QUERY_CNF, status, 0, 0); } OS_UnlockStack(); }
void FmpClearConnection(FmpChannel *channel, BtStatus status) { kal_trace(BT_TRACE_BLE_PROFILES, FMP_CLEAR_CONNECTION_STATUS, status); /* Release all resources in packet pool */ /* Notify the application */ FmpAppCallback(channel, FMPEVENT_CLOSED, status, channel->link, sizeof(BtRemoteDevice)); CMGR_RemoveDataLink(&channel->cmgr_handler); CMGR_RemoveCmgrWithDevice(&channel->cmgr_handler); FmpFreeChannel(channel); }