例程定义了3种report的句柄,分别为:
// Service and Characteristic discovery variables. static uint16 mouseCharHandle= GATT_INVALID_HANDLE; static uint16 keyCharHandle= GATT_INVALID_HANDLE; static uint16 consumerCtrlCharHandle = GATT_INVALID_HANDLE;
这三个句柄的值从哪里获取的呢?
是调用GATT_DiscPrimaryServiceByUUID函数后返回的ATT_FIND_BY_TYPE_VALUE_RSP消息里包含了吗?
如果包含在返回消息里面,又是怎么取出来,并存储到上面3个句柄中的呢?
Alvin Chen:
case GAPBOND_PAIRING_STATE_BONDED:if ( status == SUCCESS ){// Enter a GAP Bond manager Paired stategapBondMgrState = PAIRED_BONDED_STATE;//Check if this is the same address as a previous connectionif ( osal_memcmp( remoteHandles.lastRemoteAddr, remoteAddr, B_ADDR_LEN ) == TRUE){serviceChangeHandle = remoteHandles.svcChangeHandle;// Check if there has been a service change or if this is a newly connected deviceif ( ( remoteHandles.mouseCharHandle == GATT_INVALID_HANDLE )||( remoteHandles.keyCharHandle == GATT_INVALID_HANDLE )||( remoteHandles.consumerCtrlCharHandle == GATT_INVALID_HANDLE ) ||( serviceChange == CHANGE_OCCURED ) ){// Do we know the service change handle yet?if (serviceChangeHandle == GATT_INVALID_HANDLE ){// Begin dicovery of GATT Service Changed characteristicserviceToDiscover = GATT_SERVICE_UUID;}else{// Begin discovery of HID serviceserviceToDiscover = HID_SERV_UUID;}// We must perform service discovery again, something might have changed.// Begin Service DiscoveryhidappDiscoverService( connHandle, serviceToDiscover );serviceDiscComplete = FALSE;}else{// No change, restore handle info.// bonding indicates that we probably already enabled all these characteristics. easy fix if not.serviceDiscComplete= TRUE;mouseCharHandle= remoteHandles.mouseCharHandle;keyCharHandle= remoteHandles.keyCharHandle;consumerCtrlCharHandle = remoteHandles.consumerCtrlCharHandle;mouseCCCHandle= remoteHandles.mouseCCCHandle;keyCCCHandle= remoteHandles.keyCCCHandle;consumerCtrlCCCHandle= remoteHandles.consumerCtrlCCCHandle;}}else if ( osal_isbufset( remoteHandles.lastRemoteAddr, 0x00, B_ADDR_LEN ) == TRUE ){// lastRemoteAddr is all 0's, which means the device was bonded before// it was power-cycled, and that we probably already enabled all CCCDs.// So, we only need to find out attribute report handles.enableCCCDs = FALSE;// Begin Service Discovery of HID Service to find out report handlesserviceToDiscover = HID_SERV_UUID;hidappDiscoverService( connHandle, HID_SERV_UUID );
cuter:
回复 Alvin Chen:
这段我看过,意思是从remoteHandles过来的吗?那remoteHandles又是从哪获取的?
不会是从这里吧?
/********************************************************************** @fnhidappSaveHandles** @briefsave handle information in case next connection is to the*same bonded device.** @paramnone.** @returnnone.*/ static void hidappSaveHandles( void ) {// Service and Characteristic discovery variables.remoteHandles.mouseCharHandle= mouseCharHandle;remoteHandles.keyCharHandle= keyCharHandle;remoteHandles.consumerCtrlCharHandle = consumerCtrlCharHandle;// CCC's of the notificationsremoteHandles.mouseCCCHandle= mouseCCCHandle;remoteHandles.keyCCCHandle= keyCCCHandle;remoteHandles.consumerCtrlCCCHandle= consumerCtrlCCCHandle;remoteHandles.svcChangeHandle= serviceChangeHandle; }如果是这样,变成循环赋值了,那第一次赋值是在哪里呢?
cuter:
回复 Alvin Chen:
谢谢你回答这么迅速! 刚刚找到是在哪里赋值的了,用指针赋值的,没那么明显