Use 128-bit UUID to find service
// BLE Base 128-bit UUID: 0000XXXX-0000-1000-8000-00805F9B34FB
// TI Base 128-bit UUID: F000XXXX-0451-4000-B000-000000000000
#define BLE_BASE_UUID_128( uuid ) 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, \
0x00, 0x10, 0x00, 0x00, LO_UINT16( uuid ), HI_UINT16( uuid ), 0x00, 0x00
uint8 uuid[ATT_UUID_SIZE] = { BLE_BASE_UUID_128( CURRENT_TIME_SERV_UUID ) };
GATT_DiscPrimaryServiceByUUID( timeAppConnHandle, uuid,
ATT_UUID_SIZE, timeAppTaskId );
reference:
CC2541连接ANCS服务
http://yangchong89.lofter.com/tag/cc2541
https://github.com/oroce/BLE-CC254x-1.4.0/blob/master/Projects/ble/OADManager/Source/oad_mgr_app.c
| * @fn oadManagerSvcDiscovery |
| * |
| * @brief OAD Service discovery. |
| * |
| * @return none |
| */ |
| static void oadManagerSvcDiscovery(void) |
| { |
| uint8 oadServUUID[ATT_UUID_SIZE] = { TI_BASE_UUID_128( OAD_SERVICE_UUID ) }; |
| |
| // Initialize service discovery variables |
| oadSvcStartHdl = oadSvcEndHdl = 0; |
| |
| if (GATT_DiscPrimaryServiceByUUID(oadManagerConnHandle, oadServUUID, |
| ATT_UUID_SIZE, oadManagerTaskId) != SUCCESS) |
| { |
| (void)osal_set_event(oadManagerTaskId, SVC_DISCOVERY_EVT); |
| } |
|
}
/**
* @brief This sub-procedure is used by a client to discover a specific
* primary service on a server when only the Service UUID is
* known. The primary specific service may exist multiple times
* on a server. The primary service being discovered is identified
* by the service UUID.
*
* The ATT Find By Type Value Request is used with the Attribute
* Type parameter set to the UUID for "Primary Service" and the
* Attribute Value set to the 16-bit Bluetooth UUID or 128-bit
* UUID for the specific primary service. The Starting Handle shall
* be set to 0x0001 and the Ending Handle shall be set to 0xFFFF.
*
* If the return status from this function is SUCCESS, the calling
* application task will receive multiple OSAL GATT_MSG_EVENT messages.
* The type of the messages will be either ATT_FIND_BY_TYPE_VALUE_RSP
* or ATT_ERROR_RSP (if an error occurred on the server).
*
* Note: This sub-procedure is complete when either ATT_FIND_BY_TYPE_VALUE_RSP
* (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
* (with SUCCESS status) is received by the calling application task.
*
* @param connHandle - connection to use
* @param pUUID - pointer to service UUID to look for
* @param len - length of value
* @param taskId - task to be notified of response
*
* @return SUCCESS: Request was sent successfully.<BR>
* INVALIDPARAMETER: Invalid connection handle or request field.<BR>
* MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
* bleNotConnected: Connection is down.<BR>
* blePending: A response is pending with this server.<BR>
* bleMemAllocError: Memory allocation error occurred.<BR>
* bleTimeout: Previous transaction timed out.<BR>
*/
extern bStatus_t GATT_DiscPrimaryServiceByUUID( uint16 connHandle, uint8 *pUUID,
uint8 len, uint8 taskId ); |
沒有留言:
張貼留言