AudioGATTprofile.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. /**************************************************************************************************
  2. Phyplus Microelectronics Limited confidential and proprietary.
  3. All rights reserved.
  4. IMPORTANT: All rights of this software belong to Phyplus Microelectronics
  5. Limited ("Phyplus"). Your use of this Software is limited to those
  6. specific rights granted under the terms of the business contract, the
  7. confidential agreement, the non-disclosure agreement and any other forms
  8. of agreements as a customer or a partner of Phyplus. You may not use this
  9. Software unless you agree to abide by the terms of these agreements.
  10. You acknowledge that the Software may not be modified, copied,
  11. distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
  12. (BLE) integrated circuit, either as a product or is integrated into your
  13. products. Other than for the aforementioned purposes, you may not use,
  14. reproduce, copy, prepare derivative works of, modify, distribute, perform,
  15. display or sell this Software and/or its documentation for any purposes.
  16. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  17. PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  18. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  19. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  20. PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
  21. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  22. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  23. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  24. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  25. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  26. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  27. **************************************************************************************************/
  28. /**************************************************************************************************
  29. Filename: AudioGATTprofile.c
  30. Revised:
  31. Revision:
  32. Description: This file contains the Simple GATT profile sample GATT service
  33. profile for use with the BLE sample application.
  34. **************************************************************************************************/
  35. /*********************************************************************
  36. * INCLUDES
  37. */
  38. #include "bcomdef.h"
  39. #include "OSAL.h"
  40. #include "linkdb.h"
  41. #include "att.h"
  42. #include "gatt.h"
  43. #include "gatt_uuid.h"
  44. #include "gattservapp.h"
  45. #include "gapbondmgr.h"
  46. #include "AudioGATTprofile.h"
  47. #include "log.h"
  48. #include "common.h"
  49. #include "peripheral.h"
  50. #include "hidkbd.h"
  51. /*********************************************************************
  52. * MACROS
  53. */
  54. /*********************************************************************
  55. * CONSTANTS
  56. */
  57. #define SERVAPP_NUM_ATTR_SUPPORTED 8
  58. /*********************************************************************
  59. * TYPEDEFS
  60. */
  61. #define AUDIO_BASE_UUID_128( uuid ) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, \
  62. 0x00, 0x40, 0x51, 0x04, LO_UINT16( uuid ), HI_UINT16( uuid ), 0x00, 0xF0
  63. /*********************************************************************
  64. * GLOBAL VARIABLES
  65. */
  66. uint8 char1Tx_length=0;
  67. uint8 char2Tx_length=0;
  68. // Audio GATT Profile Service UUID: 0xFF01
  69. CONST uint8 AudioProfileServUUID[ATT_UUID_SIZE] =
  70. {
  71. AUDIO_BASE_UUID_128(AUDIOPROFILE_SERV_UUID)
  72. };
  73. // Characteristic 1 UUID: 0xFFF1
  74. CONST uint8 AudioProfilechar1UUID[ATT_UUID_SIZE] =
  75. {
  76. AUDIO_BASE_UUID_128(AUDIOPROFILE_CHAR1_UUID)
  77. };
  78. // Characteristic 2 UUID: 0xFFF2
  79. CONST uint8 AudioProfilechar2UUID[ATT_UUID_SIZE] =
  80. {
  81. AUDIO_BASE_UUID_128(AUDIOPROFILE_CHAR2_UUID)
  82. };
  83. /*********************************************************************
  84. * EXTERNAL VARIABLES
  85. */
  86. /*********************************************************************
  87. * EXTERNAL FUNCTIONS
  88. */
  89. /*********************************************************************
  90. * LOCAL VARIABLES
  91. */
  92. static AudioProfileCBs_t *AudioProfile_AppCBs = NULL;
  93. /*********************************************************************
  94. * Profile Attributes - variables
  95. */
  96. // Simple Profile Service attribute
  97. static CONST gattAttrType_t AudioProfileService = { ATT_UUID_SIZE, AudioProfileServUUID };
  98. // Audio Profile Characteristic 1 Properties
  99. static uint8 AudioProfileChar1Props = GATT_PROP_NOTIFY|GATT_PROP_READ;
  100. // Characteristic 1 Value
  101. uint8 AudioProfileChar1[AUDIOPROFILE_CHAR1_LEN];
  102. // Audio Profile Characteristic 1 Configuration Each client has its own
  103. // instantiation of the Client Characteristic Configuration. Reads of the
  104. // Client Characteristic Configuration only shows the configuration for
  105. // that client and writes only affect the configuration of that client.
  106. static gattCharCfg_t AudioProfileChar1Config[GATT_MAX_NUM_CONN];
  107. // Audio Profile Characteristic 2 User Description
  108. //static uint8 AudioProfileChar1UserDesp[] = "RX CHAR\0";
  109. // Audio Profile Characteristic 1 Properties
  110. static uint8 AudioProfileChar2Props = GATT_PROP_NOTIFY|GATT_PROP_READ;
  111. // Characteristic 1 Value
  112. uint8 AudioProfileChar2[AUDIOPROFILE_CHAR2_LEN];
  113. // Audio Profile Characteristic 1 User Description
  114. //static uint8 AudioProfileChar2UserDesp[] = "TX CHAR\0";
  115. // Audio Profile Characteristic 1 Configuration Each client has its own
  116. // instantiation of the Client Characteristic Configuration. Reads of the
  117. // Client Characteristic Configuration only shows the configuration for
  118. // that client and writes only affect the configuration of that client.
  119. static gattCharCfg_t AudioProfileChar2Config[GATT_MAX_NUM_CONN];
  120. /*********************************************************************
  121. * Profile Attributes - Table
  122. */
  123. static gattAttribute_t AudioProfileAttrTbl[] =
  124. {
  125. // =========== Simple Profile Service
  126. {
  127. { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
  128. GATT_PERMIT_READ, /* permissions */
  129. 0, /* handle */
  130. (uint8 *)&AudioProfileService /* pValue */
  131. },
  132. // ----------------------------------------------------------------------
  133. // Characteristic 1 Declaration,
  134. {
  135. { ATT_BT_UUID_SIZE, characterUUID },
  136. GATT_PERMIT_READ,
  137. 0,
  138. &AudioProfileChar1Props
  139. },
  140. // Characteristic Value 1
  141. {
  142. { ATT_UUID_SIZE, AudioProfilechar1UUID },
  143. GATT_PERMIT_READ | GATT_PERMIT_WRITE,
  144. 0,
  145. (uint8 *)&AudioProfileChar1
  146. },
  147. // Characteristic 1 User Description, this field is optional
  148. // {
  149. // { ATT_BT_UUID_SIZE, charUserDescUUID },
  150. // GATT_PERMIT_READ,
  151. // 0,
  152. // AudioProfileChar1UserDesp
  153. // },
  154. // Characteristic 1 configuration
  155. {
  156. { ATT_BT_UUID_SIZE, clientCharCfgUUID },
  157. GATT_PERMIT_READ | GATT_PERMIT_WRITE,
  158. 0,
  159. (uint8 *)AudioProfileChar1Config
  160. },
  161. // ----------------------------------------------------------------------
  162. // Characteristic 2 Declaration,
  163. {
  164. { ATT_BT_UUID_SIZE, characterUUID },
  165. GATT_PERMIT_READ,
  166. 0,
  167. &AudioProfileChar2Props
  168. },
  169. // Characteristic Value 2
  170. {
  171. { ATT_UUID_SIZE, AudioProfilechar2UUID },
  172. GATT_PERMIT_READ,
  173. 0,
  174. AudioProfileChar2
  175. },
  176. // Characteristic 2 configuration
  177. {
  178. { ATT_BT_UUID_SIZE, clientCharCfgUUID },
  179. GATT_PERMIT_READ | GATT_PERMIT_WRITE,
  180. 0,
  181. (uint8 *)AudioProfileChar2Config
  182. },
  183. // Characteristic 2 User Description
  184. // {
  185. // { ATT_BT_UUID_SIZE, charUserDescUUID },
  186. // GATT_PERMIT_READ,
  187. // 0,
  188. // AudioProfileChar2UserDesp
  189. // },
  190. };
  191. /*********************************************************************
  192. * LOCAL FUNCTIONS
  193. */
  194. static uint8 AudioProfile_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
  195. uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen );
  196. static bStatus_t AudioProfile_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
  197. uint8 *pValue, uint8 len, uint16 offset );
  198. static void AudioProfile_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
  199. /*********************************************************************
  200. * PROFILE CALLBACKS
  201. */
  202. // Audio Profile Service Callbacks
  203. CONST gattServiceCBs_t AudioProfileCBs =
  204. {
  205. AudioProfile_ReadAttrCB, // Read callback function pointer
  206. AudioProfile_WriteAttrCB, // Write callback function pointer
  207. NULL // Authorization callback function pointer
  208. };
  209. /*********************************************************************
  210. * PUBLIC FUNCTIONS
  211. */
  212. /*********************************************************************
  213. * @fn AudioProfile_AddService
  214. *
  215. * @brief Initializes the Simple Profile service by registering
  216. * GATT attributes with the GATT server.
  217. *
  218. * @param services - services to add. This is a bit map and can
  219. * contain more than one service.
  220. *
  221. * @return Success or Failure
  222. */
  223. bStatus_t AudioProfile_AddService( uint32 services )
  224. {
  225. uint8 status = SUCCESS;
  226. // Initialize Client Characteristic Configuration attributes
  227. GATTServApp_InitCharCfg( INVALID_CONNHANDLE, AudioProfileChar1Config );
  228. GATTServApp_InitCharCfg( INVALID_CONNHANDLE, AudioProfileChar2Config );
  229. // Register with Link DB to receive link status change callback
  230. VOID linkDB_Register(AudioProfile_HandleConnStatusCB );
  231. if ( services & AUDIOPROFILE_SERVICE )
  232. {
  233. // Register GATT attribute list and CBs with GATT Server App
  234. status = GATTServApp_RegisterService( AudioProfileAttrTbl,
  235. GATT_NUM_ATTRS( AudioProfileAttrTbl ),
  236. &AudioProfileCBs );
  237. }
  238. return ( status );
  239. }
  240. /*********************************************************************
  241. * @fn AudioProfile_RegisterAppCBs
  242. *
  243. * @brief Registers the application callback function. Only call
  244. * this function once.
  245. *
  246. * @param callbacks - pointer to application callbacks.
  247. *
  248. * @return SUCCESS or bleAlreadyInRequestedMode
  249. */
  250. bStatus_t AudioProfile_RegisterAppCBs( AudioProfileCBs_t *appCallbacks )
  251. {
  252. if ( appCallbacks )
  253. {
  254. AudioProfile_AppCBs = appCallbacks;
  255. return ( SUCCESS );
  256. }
  257. else
  258. {
  259. return ( bleAlreadyInRequestedMode );
  260. }
  261. }
  262. /*********************************************************************
  263. * @fn AudioProfile_SetParameter
  264. *
  265. * @brief Set a Simple Profile parameter.
  266. *
  267. * @param param - Profile parameter ID
  268. * @param len - length of data to right
  269. * @param value - pointer to data to write. This is dependent on
  270. * the parameter ID and WILL be cast to the appropriate
  271. * data type (example: data type of uint16 will be cast to
  272. * uint16 pointer).
  273. *
  274. * @return bStatus_t
  275. */
  276. bStatus_t AudioProfile_SetParameter( uint8 param, uint8 len, void *value )
  277. {
  278. bStatus_t ret = SUCCESS;
  279. switch ( param )
  280. {
  281. case AUDIOPROFILE_CHAR1:
  282. if ( len >0)
  283. {
  284. VOID osal_memcpy( AudioProfileChar1, value, len );
  285. char1Tx_length=len;
  286. ret=GATTServApp_ProcessCharCfg( AudioProfileChar1Config, AudioProfileChar1, FALSE,
  287. AudioProfileAttrTbl, GATT_NUM_ATTRS( AudioProfileAttrTbl ),
  288. INVALID_TASK_ID );
  289. if(ret!=SUCCESS)
  290. {
  291. // LOG("Notify_error:%d\n\r",ret);
  292. }
  293. }
  294. else
  295. {
  296. ret = bleInvalidRange;
  297. }
  298. break;
  299. case AUDIOPROFILE_CHAR2:
  300. if ( len >0)
  301. {
  302. VOID osal_memcpy( AudioProfileChar2, value, len );
  303. char2Tx_length=len;
  304. ret=GATTServApp_ProcessCharCfg( AudioProfileChar2Config, AudioProfileChar2, FALSE,
  305. AudioProfileAttrTbl, GATT_NUM_ATTRS( AudioProfileAttrTbl ),
  306. INVALID_TASK_ID );
  307. if(ret!=SUCCESS)
  308. {
  309. // LOG("Notify_error:%d\nr",ret);
  310. }
  311. }
  312. else
  313. {
  314. ret = bleInvalidRange;
  315. }
  316. break;
  317. default:
  318. ret = INVALIDPARAMETER;
  319. break;
  320. }
  321. return ( ret );
  322. }
  323. /*********************************************************************
  324. * @fn AudioProfile_GetParameter
  325. *
  326. * @brief Get a Audio Profile parameter.
  327. *
  328. * @param param - Profile parameter ID
  329. * @param value - pointer to data to put. This is dependent on
  330. * the parameter ID and WILL be cast to the appropriate
  331. * data type (example: data type of uint16 will be cast to
  332. * uint16 pointer).
  333. *
  334. * @return bStatus_t
  335. */
  336. bStatus_t AudioProfile_GetParameter( uint8 param, void *value )
  337. {
  338. bStatus_t ret = SUCCESS;
  339. switch ( param )
  340. {
  341. default:
  342. ret = INVALIDPARAMETER;
  343. break;
  344. }
  345. return ( ret );
  346. }
  347. /*********************************************************************
  348. * @fn AudioProfile_ReadAttrCB
  349. *
  350. * @brief Read an attribute.
  351. *
  352. * @param connHandle - connection message was received on
  353. * @param pAttr - pointer to attribute
  354. * @param pValue - pointer to data to be read
  355. * @param pLen - length of data to be read
  356. * @param offset - offset of the first octet to be read
  357. * @param maxLen - maximum length of data to be read
  358. *
  359. * @return Success or Failure
  360. */
  361. static uint8 AudioProfile_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
  362. uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
  363. {
  364. bStatus_t status = SUCCESS;
  365. // If attribute permissions require authorization to read, return error
  366. if ( gattPermitAuthorRead( pAttr->permissions ) )
  367. {
  368. // Insufficient authorization
  369. return ( ATT_ERR_INSUFFICIENT_AUTHOR );
  370. }
  371. // Make sure it's not a blob operation (no attributes in the profile are long)
  372. if ( offset > 0 )
  373. {
  374. return ( ATT_ERR_ATTR_NOT_LONG );
  375. }
  376. if ( pAttr->type.len == ATT_BT_UUID_SIZE||pAttr->type.len == ATT_UUID_SIZE )
  377. {
  378. AudioProfile_Read(connHandle,pAttr,pValue,pLen,offset,maxLen);
  379. }
  380. return ( status );
  381. }
  382. /*********************************************************************
  383. * @fn AudioProfile_WriteAttrCB
  384. *
  385. * @brief Validate attribute data prior to a write operation
  386. *
  387. * @param connHandle - connection message was received on
  388. * @param pAttr - pointer to attribute
  389. * @param pValue - pointer to data to be written
  390. * @param len - length of data
  391. * @param offset - offset of the first octet to be written
  392. *
  393. * @return Success or Failure
  394. */
  395. static bStatus_t AudioProfile_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
  396. uint8 *pValue, uint8 len, uint16 offset )
  397. {
  398. bStatus_t status = SUCCESS;
  399. uint8 notifyApp = 0xFF;
  400. // If attribute permissions require authorization to write, return error
  401. if ( gattPermitAuthorWrite( pAttr->permissions ) )
  402. {
  403. // Insufficient authorization
  404. return ( ATT_ERR_INSUFFICIENT_AUTHOR );
  405. }
  406. if ( pAttr->type.len == ATT_BT_UUID_SIZE )
  407. {
  408. // 16-bit UUID
  409. uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
  410. switch ( uuid )
  411. {
  412. case GATT_CLIENT_CHAR_CFG_UUID:
  413. status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
  414. offset, GATT_CLIENT_CFG_NOTIFY );
  415. if ( status == SUCCESS )
  416. {
  417. // uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );
  418. if(pAttr->handle==AudioProfileAttrTbl[3].handle)
  419. {
  420. LOG("audio start cmd enable\n\r");
  421. }
  422. else if(pAttr->handle==AudioProfileAttrTbl[6].handle)
  423. {
  424. LOG("audio data transf enable\n\r");
  425. // if(charCfg==0x0001)
  426. //osal_start_timerEx(hidKbdTaskId, HID_KEY_TEST_EVT, 8000);
  427. }
  428. }
  429. break;
  430. default:
  431. // Should never get here! (characteristics 2 and 4 do not have write permissions)
  432. status = ATT_ERR_ATTR_NOT_FOUND;
  433. break;
  434. }
  435. }
  436. else
  437. {
  438. // 128-bit UUID
  439. status = ATT_ERR_INVALID_HANDLE;
  440. }
  441. // If a charactersitic value changed then callback function to notify application of change
  442. if ( (notifyApp != 0xFF ) && AudioProfile_AppCBs && AudioProfile_AppCBs->pfnAudioProfileChange )
  443. {
  444. AudioProfile_AppCBs->pfnAudioProfileChange( notifyApp );
  445. }
  446. return ( status );
  447. }
  448. /*********************************************************************
  449. * @fn AudioProfile_HandleConnStatusCB
  450. *
  451. * @brief Audio Profile link status change handler function.
  452. *
  453. * @param connHandle - connection handle
  454. * @param changeType - type of change
  455. *
  456. * @return none
  457. */
  458. static void AudioProfile_HandleConnStatusCB( uint16 connHandle, uint8 changeType )
  459. {
  460. // Make sure this is not loopback connection
  461. if ( connHandle != LOOPBACK_CONNHANDLE )
  462. {
  463. // Reset Client Char Config if connection has dropped
  464. if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) ||
  465. ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) &&
  466. ( !linkDB_Up( connHandle ) ) ) )
  467. {
  468. GATTServApp_InitCharCfg( connHandle, AudioProfileChar1Config );
  469. GATTServApp_InitCharCfg( connHandle, AudioProfileChar2Config );
  470. }
  471. }
  472. }
  473. bStatus_t AudioProfile_Notify( uint8 param, uint8 len, void *value )
  474. {
  475. bStatus_t ret = SUCCESS;
  476. switch ( param )
  477. {
  478. case AUDIOPROFILE_CHAR2:
  479. VOID osal_memcpy( AudioProfileChar2, value, len );
  480. GATTServApp_ProcessCharCfg( AudioProfileChar2Config, AudioProfileChar2, FALSE,
  481. AudioProfileAttrTbl, GATT_NUM_ATTRS( AudioProfileAttrTbl ),
  482. INVALID_TASK_ID );
  483. break;
  484. default:
  485. ret = INVALIDPARAMETER;
  486. break;
  487. }
  488. return ( ret );
  489. }
  490. bStatus_t AudioProfile_Write( uint16 connHandle, gattAttribute_t *pAttr,
  491. uint8 *pValue, uint8 len, uint16 offset )
  492. {
  493. bStatus_t status = SUCCESS;
  494. // 16-bit UUID
  495. uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
  496. switch(uuid){
  497. case AUDIOPROFILE_CHAR1_UUID:
  498. if ( offset != 0 )
  499. {
  500. status = ATT_ERR_ATTR_NOT_LONG;
  501. }
  502. if ( status == SUCCESS ){
  503. uint8 *pCurValue = (uint8 *)pAttr->pValue;
  504. VOID osal_memcpy( pCurValue, pValue, len );
  505. //rxdata_process(pCurValue,len);
  506. }
  507. break;
  508. case GATT_CLIENT_CHAR_CFG_UUID:
  509. status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
  510. offset, GATT_CLIENT_CFG_NOTIFY );
  511. break;
  512. default:
  513. status = ATT_ERR_ATTR_NOT_FOUND;
  514. break;
  515. }
  516. return status;
  517. }
  518. bStatus_t AudioProfile_Read( uint16 connHandle, gattAttribute_t *pAttr,
  519. uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen )
  520. {
  521. bStatus_t status = SUCCESS;
  522. if(pAttr->type.len == ATT_BT_UUID_SIZE)
  523. {
  524. // 16-bit UUID
  525. uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
  526. LOG("16 uuid:%X\n\r",uuid);
  527. switch ( uuid )
  528. {
  529. case AUDIOPROFILE_CHAR1_UUID:
  530. *pLen = char1Tx_length;
  531. VOID osal_memcpy( pValue, pAttr->pValue, *pLen );
  532. break;
  533. case AUDIOPROFILE_CHAR2_UUID:
  534. *pLen=char2Tx_length;
  535. VOID osal_memcpy( pValue, pAttr->pValue, *pLen );
  536. break;
  537. default:
  538. // Should never get here! (characteristics 3 and 4 do not have read permissions)
  539. *pLen = 0;
  540. status = ATT_ERR_ATTR_NOT_FOUND;
  541. LOG("uuid not find\n\r");
  542. break;
  543. }
  544. }
  545. else
  546. {
  547. uint16 uuid = BUILD_UINT16( pAttr->type.uuid[12], pAttr->type.uuid[13]);
  548. //LOG("128 uuid:%X\n\r",uuid);
  549. switch ( uuid )
  550. {
  551. case AUDIOPROFILE_CHAR1_UUID:
  552. *pLen = char1Tx_length;
  553. VOID osal_memcpy( pValue, pAttr->pValue, *pLen );
  554. break;
  555. case AUDIOPROFILE_CHAR2_UUID:
  556. *pLen=char2Tx_length;
  557. VOID osal_memcpy( pValue, pAttr->pValue, *pLen );
  558. break;
  559. default:
  560. // Should never get here! (characteristics 3 and 4 do not have read permissions)
  561. *pLen = 0;
  562. status = ATT_ERR_ATTR_NOT_FOUND;
  563. LOG("uuid not find\n\r");
  564. break;
  565. }
  566. }
  567. return status;
  568. }
  569. /*********************************************************************
  570. *********************************************************************/