• 易迪拓培训,专注于微波、射频、天线设计工程师的培养
首页 > 无线通信 > 技术讨论 > CC2541常用库函数代码

CC2541常用库函数代码

录入:edatop.com     点击:

   在用CC2541的开发过程中,很多时候我们都会需要用到各种各样的函数,如中断函数,读取地址,设置广播等。本篇把CC2541需要用到的函数作用和代码列了出来,方便各位找到自己要应用到的函数代码。


  1. hci.h
  2. //分配内存,应用程序不应该调用这个函数.
  3. void *HCI_bm_alloc( uint16 size );

  4. //检查连接时间参数和连接时间参数的组合是否有效
  5. uint8 HCI_ValidConnTimeParams( uint16 connIntervalMin,
  6.                                       uint16 connIntervalMax,
  7.                                       uint16 connLatency,
  8.                                       uint16 connTimeout );

  9. //HCI vendor specific registration for HCI Test Application
  10. void HCI_TestAppTaskRegister( uint8 taskID );

  11. // HCI vendor specific registration for Host GAP.
  12. void HCI_GAPTaskRegister( uint8 taskID );

  13. //HCI vendor specific registration for Host L2CAP.
  14. void HCI_L2CAPTaskRegister( uint8 taskID );

  15. //HCI vendor specific registration for Host SMP.
  16. void HCI_SMPTaskRegister( uint8 taskID );

  17. // HCI vendor specific registration for Host extended commands.
  18. void HCI_ExtTaskRegister( uint8 taskID );

  19. //发送一个ACL数据包
  20. hciStatus_t HCI_SendDataPkt( uint16 connHandle,
  21.                                     uint8  pbFlag,
  22.                                     uint16 pktLen,
  23.                                     uint8  *pData );

  24. //中断连接
  25. hciStatus_t HCI_DisconnectCmd( uint16 connHandle,
  26.                                       uint8  reason );
  27. //请求得到版本信息
  28. hciStatus_t HCI_ReadRemoteVersionInfoCmd( uint16 connHandle );

  29. //设置消息蒙版,确定支持哪些消息
  30. hciStatus_t HCI_SetEventMaskCmd( uint8 *pMask );

  31. //重置连接层
  32. hciStatus_t HCI_ResetCmd( void );

  33. //读取发射功率
  34. hciStatus_t HCI_ReadTransmitPowerLevelCmd( uint16 connHandle,
  35.                                                   uint8  txPwrType );

  36. //主机用来开关流量控制(控制器法向主机的)
  37. hciStatus_t HCI_SetControllerToHostFlowCtrlCmd( uint8 flowControlEnable );

  38. //This BT API is used by the Host to notify the Controller of the maximum size ACL buffer size the Controller can send to the Host.
  39. hciStatus_t HCI_HostBufferSizeCmd( uint16 hostAclPktLen,
  40.                                           uint8  hostSyncPktLen,
  41.                                           uint16 hostTotalNumAclPkts,
  42.                                           uint16 hostTotalNumSyncPkts );

  43. //This BT API is used by the Host to notify the Controller of the number of HCI data packets that have been completed for each connection handle since this command was previously sent to the controller.
  44. hciStatus_t HCI_HostNumCompletedPktCmd( uint8  numHandles,
  45.                                                uint16 *connHandles,
  46.                                                uint16 *numCompletedPkts );

  47. //读取本地版本信息
  48. hciStatus_t HCI_ReadLocalVersionInfoCmd( void );

  49. //读取本地支持的命令
  50. hciStatus_t HCI_ReadLocalSupportedCommandsCmd( void );

  51. //读取本地支持的特性
  52. hciStatus_t HCI_ReadLocalSupportedFeaturesCmd( void );

  53. //读取设备的BLE地址
  54. hciStatus_t HCI_ReadBDADDRCmd( void );

  55. //读取最后一个包的RSSI
  56. hciStatus_t HCI_ReadRssiCmd( uint16 connHandle );

  57. //设置HCI LE时间蒙版,确定支持哪些事件
  58. hciStatus_t HCI_LE_SetEventMaskCmd( uint8 *pEventMask );

  59. //取得最大ACL数据包大小
  60. hciStatus_t HCI_LE_ReadBufSizeCmd( void );

  61. //取得本地支持的特性
  62. hciStatus_t HCI_LE_ReadLocalSupportedFeaturesCmd( void );

  63. //设置设别随机地址
  64. hciStatus_t HCI_LE_SetRandomAddressCmd( uint8 *pRandAddr );

  65. //设置广播参数
  66. hciStatus_t HCI_LE_SetAdvParamCmd( uint16 advIntervalMin,
  67.                                           uint16 advIntervalMax,
  68.                                           uint8  advType,
  69.                                           uint8  ownAddrType,
  70.                                           uint8  directAddrType,
  71.                                           uint8  *directAddr,
  72.                                           uint8  advChannelMap,
  73.                                           uint8  advFilterPolicy );

  74. //设置广播数据
  75. hciStatus_t HCI_LE_SetAdvDataCmd( uint8 dataLen,
  76.                                          uint8 *pData );

  77. //设置广播搜索响应数据
  78. hciStatus_t HCI_LE_SetScanRspDataCmd( uint8 dataLen,
  79.                                              uint8 *pData );

  80. //开关广播
  81. hciStatus_t HCI_LE_SetAdvEnableCmd( uint8 advEnable );

  82. //读取广播时的发射功率
  83. hciStatus_t HCI_LE_ReadAdvChanTxPowerCmd( void );

  84. //设置搜索参数
  85. hciStatus_t HCI_LE_SetScanParamCmd( uint8  scanType,
  86.                                            uint16 scanInterval,
  87.                                            uint16 scanWindow,
  88.                                            uint8  ownAddrType,
  89.                                            uint8  filterPolicy );

  90. //开关搜索
  91. hciStatus_t HCI_LE_SetScanEnableCmd( uint8 scanEnable,
  92.                                             uint8 filterDuplicates );

  93. //建立连接
  94. hciStatus_t HCI_LE_CreateConnCmd( uint16 scanInterval,
  95.                                          uint16 scanWindow,
  96.                                          uint8  initFilterPolicy,
  97.                                          uint8  addrTypePeer,
  98.                                          uint8  *peerAddr,
  99.                                          uint8  ownAddrType,
  100.                                          uint16 connIntervalMin,
  101.                                          uint16 connIntervalMax,
  102.                                          uint16 connLatency,
  103.                                          uint16 connTimeout,
  104.                                          uint16 minLen,
  105.                                          uint16 maxLen );

  106. //取消创建连接
  107. hciStatus_t HCI_LE_CreateConnCancelCmd( void );

  108. //读取白名单
  109. hciStatus_t HCI_LE_ReadWhiteListSizeCmd( void );

  110. //清除白名单
  111. hciStatus_t HCI_LE_ClearWhiteListCmd( void );

  112. //添加一条白名单
  113. hciStatus_t HCI_LE_AddWhiteListCmd( uint8 addrType,
  114.                                            uint8 *devAddr );

  115. //移除一条白名单
  116. hciStatus_t HCI_LE_RemoveWhiteListCmd( uint8 addrType,
  117.                                               uint8 *devAddr );

  118. //更新连接参数
  119. hciStatus_t HCI_LE_ConnUpdateCmd( uint16 connHandle,
  120.                                          uint16 connIntervalMin,
  121.                                          uint16 connIntervalMax,
  122.                                          uint16 connLatency,
  123.                                          uint16 connTimeout,
  124.                                          uint16 minLen,
  125.                                          uint16 maxLen );

  126. //更新当前数据通道MAP
  127. hciStatus_t HCI_LE_SetHostChanClassificationCmd( uint8 *chanMap );

  128. //读取连接数据通道MAP
  129. hciStatus_t HCI_LE_ReadChannelMapCmd( uint16 connHandle );

  130. //读取远程设备用户特性
  131. hciStatus_t HCI_LE_ReadRemoteUsedFeaturesCmd( uint16 connHandle );

  132. //执行AES128加密
  133. hciStatus_t HCI_LE_EncryptCmd( uint8 *key,
  134.                                       uint8 *plainText );

  135. //产生随机数
  136. hciStatus_t HCI_LE_RandCmd( void );

  137. //连接中开始加密
  138. hciStatus_t HCI_LE_StartEncyptCmd( uint16 connHandle,
  139.                                           uint8  *random,
  140.                                           uint8  *encDiv,
  141.                                           uint8  *ltk );

  142. //主机向控制器发送一个LTK回应
  143. hciStatus_t HCI_LE_LtkReqReplyCmd( uint16 connHandle,
  144.                                           uint8  *ltk );

  145. //This LE API is used by the Host to send to the Controller a negative LTK reply.
  146. hciStatus_t HCI_LE_LtkReqNegReplyCmd( uint16 connHandle );

  147. //读取控制器支持的状态
  148. hciStatus_t HCI_LE_ReadSupportedStatesCmd( void );

  149. // This LE API is used to start the receiver Direct Test Mode test.
  150. hciStatus_t HCI_LE_ReceiverTestCmd( uint8 rxFreq );

  151. //This LE API is used to start the transmit Direct Test Mode test.
  152. hciStatus_t HCI_LE_TransmitterTestCmd( uint8 txFreq,
  153.                                               uint8 dataLen,
  154.                                               uint8 pktPayload );

  155. //This LE API is used to end the Direct Test Mode test.
  156. hciStatus_t HCI_LE_TestEndCmd( void );

  157. //This HCI Extension API is used to set the receiver gain.
  158. hciStatus_t HCI_EXT_SetRxGainCmd( uint8 rxGain );

  159. //设置发射功率
  160. hciStatus_t HCI_EXT_SetTxPowerCmd( uint8 txPower );

  161. //设置是否连接中一个消息只能包含一个包
  162. hciStatus_t HCI_EXT_OnePktPerEvtCmd( uint8 control );

  163. //This HCI Extension API is used to set whether the system clock will be divided when the MCU is halted.
  164. hciStatus_t HCI_EXT_ClkDivOnHaltCmd( uint8 control );

  165. //This HCI Extension API is used to indicate to the Controller whether or not the Host will be using the NV memory during BLE operations.
  166. hciStatus_t HCI_EXT_DeclareNvUsageCmd( uint8 mode );

  167. //使用AES128解密
  168. hciStatus_t HCI_EXT_DecryptCmd( uint8 *key,
  169.                                        uint8 *encText );

  170. //设置支持的特性
  171. hciStatus_t HCI_EXT_SetLocalSupportedFeaturesCmd( uint8 *localFeatures );

  172. //设置尽快发送数据
  173. hciStatus_t HCI_EXT_SetFastTxResponseTimeCmd( uint8 control );

  174. //This HCI Extension API is used to to enable or disable suspending slave latency.
  175. hciStatus_t HCI_EXT_SetSlaveLatencyOverrideCmd( uint8 control );

  176. //This API is used start a continuous transmitter modem test, using either a modulated or unmodulated carrier wave tone, at the frequency that corresponds to the specified RF channel. Use HCI_EXT_EndModemTest command to end the test.
  177. hciStatus_t HCI_EXT_ModemTestTxCmd( uint8 cwMode,
  178.                                            uint8 txFreq );

  179. //This API is used to start a continuous transmitter direct test mode test using a modulated carrier wave and transmitting a 37 byte packet of Pseudo-Random 9-bit data. A packet is transmitted on a different frequency (linearly stepping through all RF channels 0..39) every 625us. Use HCI_EXT_EndModemTest command to end the test.
  180. hciStatus_t HCI_EXT_ModemHopTestTxCmd( void );

  181. //This API is used to start a continuous receiver modem test using a modulated carrier wave tone, at the frequency that corresponds to the specific RF channel. Any received data is discarded. Receiver gain may be adjusted using the HCI_EXT_SetRxGain command. RSSI may be read during this test by using the HCI_ReadRssi command. Use HCI_EXT_EndModemTest command to end the test.
  182. hciStatus_t HCI_EXT_ModemTestRxCmd( uint8 rxFreq );

  183. //This API is used to shutdown a modem test. A complete Controller reset will take place.
  184. hciStatus_t HCI_EXT_EndModemTestCmd( void );

  185. //设置设备的BLE地址
  186. hciStatus_t HCI_EXT_SetBDADDRCmd( uint8 *bdAddr );

  187. //设置设备的睡眠时钟精度
  188. hciStatus_t HCI_EXT_SetSCACmd( uint16 scaInPPM );

  189. //This HCI Extension API is used to enable Production Test Mode.
  190. hciStatus_t HCI_EXT_EnablePTMCmd( void );

  191. //This HCI Extension API is used to set the frequency tuning up or down. Setting the mode up/down decreases/increases the amount of capacitance on the external crystal oscillator.
  192. hciStatus_t HCI_EXT_SetFreqTuneCmd( uint8 step );

  193. //保存频率调谐值到Flash
  194. hciStatus_t HCI_EXT_SaveFreqTuneCmd( void );

  195. //This HCI Extension API is used to set the maximum transmit output power for Direct Test Mode.
  196. hciStatus_t HCI_EXT_SetMaxDtmTxPowerCmd( uint8 txPower );

  197. llStatus_t HCI_EXT_MapPmIoPortCmd( uint8 ioPort, uint8 ioPin );

  198. //立即断开连接
  199. hciStatus_t HCI_EXT_DisconnectImmedCmd( uint16 connHandle );

  200. //读取或复位包错误率计数器
  201. hciStatus_t HCI_EXT_PacketErrorRateCmd( uint16 connHandle, uint8 command );

  202. //开始或结束包错误率计数
  203. hciStatus_t HCI_EXT_PERbyChanCmd( uint16 connHandle, perByChan_t *perByChan );

  204. //This HCI Extension API is used to Extend Rf Range using the TI CC2590 2.4 GHz RF Front End device
  205. hciStatus_t HCI_EXT_ExtendRfRangeCmd( void );

  206. //This HCI Extension API is used to enable or disable halting the CPU during RF. The system defaults to enabled.
  207. hciStatus_t HCI_EXT_HaltDuringRfCmd( uint8 mode );

  208. //This HCI Extension API is used to enable or disable a notification to the specified task using the specified task event whenever a Adv event ends. A non-zero taskEvent value is taken to be "enable", while a zero valued taskEvent is taken to be "disable".
  209. hciStatus_t HCI_EXT_AdvEventNoticeCmd( uint8 taskID, uint16 taskEvent );

  210. //This HCI Extension API is used to enable or disable a notification to the specified task using the specified task event whenever a Connection event ends. A non-zero taskEvent value is taken to be "enable", while a zero valued taskEvent taken to be "disable".
  211. hciStatus_t HCI_EXT_ConnEventNoticeCmd( uint8 taskID, uint16 taskEvent );

  212. //设置用户版本号
  213. hciStatus_t HCI_EXT_BuildRevisionCmd( uint8 mode, uint16 userRevNum );
  214. lacap.h

  215. //初始化L2CAP层
  216. void L2CAP_Init( uint8 taskId );

  217. //L2CAP任务时间处理函数
  218. uint16 L2CAP_ProcessEvent( uint8 taskId, uint16 events );

  219. //为协议或程序注册一个L2CAP通道
  220. bStatus_t L2CAP_RegisterApp( uint8 taskId, uint16 CID );

  221. //发送L2CAP数据包
  222. bStatus_t L2CAP_SendData( uint16 connHandle, l2capPacket_t *pPkt );

  223. //发送拒绝命令
  224. bStatus_t L2CAP_CmdReject( uint16 connHandle, uint8 id, l2capCmdReject_t *pCmdReject );

  225. //建立拒绝命令
  226. uint16 L2CAP_BuildCmdReject( uint8 *pBuf, uint8 *pCmd );

  227. //发送L2CAP Echo请求
  228. bStatus_t L2CAP_EchoReq( uint16 connHandle, l2capEchoReq_t *pEchoReq, uint8 taskId );

  229. //发送L2CAP信息请求
  230. bStatus_t L2CAP_InfoReq( uint16 connHandle, l2capInfoReq_t *pInfoReq, uint8 taskId );

  231. //建立信息响应
  232. uint16 L2CAP_BuildInfoRsp( uint8 *pBuf, uint8 *pCmd );

  233. //解析信息请求
  234. bStatus_t L2CAP_ParseInfoReq( l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len );

  235. //发送L2CAP连接参数更新请求
  236. bStatus_t L2CAP_ConnParamUpdateReq( uint16 connHandle, l2capParamUpdateReq_t *pUpdateReq, uint8 taskId );

  237. //解析连接参数更新请求
  238. bStatus_t L2CAP_ParseParamUpdateReq( l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len );

  239. //发送连接参数更新响应
  240. bStatus_t L2CAP_ConnParamUpdateRsp( uint16 connHandle, uint8 id, l2capParamUpdateRsp_t *pUpdateRsp );

  241. //建立连接参数更新响应
  242. uint16 L2CAP_BuildParamUpdateRsp( uint8 *pBuf, uint8 *pData );

  243. //在L2CAP层分配内存
  244. void *L2CAP_bm_alloc( uint16 size );
  245. gatt.h

  246. //初始化GATT客户端
  247. bStatus_t GATT_InitClient(void);

  248. //注册接收ATT的Indications或Notifications属性值
  249. void GATT_RegisterForInd(uint8 taskId);

  250. //准备写请求用于请求服务器准备写一个属性的值
  251. bStatus_t GATT_PrepareWriteReq(uint16 connHandle, attPrepareWriteReq_t *pReq, uint8 taskId);

  252. //执行写请求
  253. bStatus_t GATT_ExecuteWriteReq(uint16 connHandle, attExecuteWriteReq_t *pReq, uint8 taskId);

  254. //初始化GATT服务器
  255. bStatus_t GATT_InitServer(void);

  256. //为GATT服务器注册服务属性列表
  257. bStatus_t GATT_RegisterService(gattService_t *pService);

  258. //为GATT服务器注销一个属性列表
  259. bStatus_t GATT_DeregisterService(uint16 handle, gattService_t *pService);

  260. //注册接收ATT请求
  261. void GATT_RegisterForReq(uint8 taskId);

  262. //验证属性的读取权限
  263. bStatus_t GATT_VerifyReadPermissions(uint16 connHandle, uint8 permissions);

  264. //验证属性的写权限
  265. bStatus_t GATT_VerifyWritePermissions(uint16 connHandle, uint8 permissions, attWriteReq_t *pReq);

  266. //发送服务改变Indication
  267. uint8 GATT_ServiceChangedInd(uint16 connHandle, uint8 taskId);

  268. //通过UUID找到属性记录
  269. gattAttribute_t *GATT_FindHandleUUID(uint16 startHandle, uint16 endHandle, const uint8 *pUUID, uint16 len, uint16 *pHandle);

  270. //通过句柄找属性记录
  271. gattAttribute_t *GATT_FindHandle(uint16 handle, uint16 *pHandle);

  272. //找给定的属性相同类型的下一个属性
  273. gattAttribute_t *GATT_FindNextAttr(gattAttribute_t *pAttr, uint16 endHandle, uint16 service, uint16 *pLastHandle);

  274. //取得服务的属性数
  275. uint16 GATT_ServiceNumAttrs(uint16 handle);

  276. //发送Indication
  277. bStatus_t GATT_Indication(uint16 connHandle, attHandleValueInd_t *pInd, uint8 authenticated, uint8 taskId);

  278. //发送Notification
  279. bStatus_t GATT_Notification(uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 authenticated);

  280. //客户端设置ATT_MTU最大值
  281. bStatus_t GATT_ExchangeMTU(uint16 connHandle, attExchangeMTUReq_t *pReq, uint8 taskId);

  282. //客户端用来发现服务器的所有主要服务
  283. bStatus_t GATT_DiscAllPrimaryServices(uint16 connHandle, uint8 taskId);

  284. //客户端通过UUID发现服务器的特定服务
  285. bStatus_t GATT_DiscPrimaryServiceByUUID(uint16 connHandle, uint8 *pValue, uint8 len, uint8 taskId);

  286. //This sub-procedure is used by a client to find include service declarations within a service definition on a server. The service specified is identified by the service handle range.
  287. bStatus_t GATT_FindIncludedServices(uint16 connHandle, uint16 startHandle, uint16 endHandle, uint8 taskId);

  288. //找到所有特性
  289. bStatus_t GATT_DiscAllChars(uint16 connHandle, uint16 startHandle, uint16 endHandle, uint8 taskId);

  290. //通过UUID找到特性
  291. bStatus_t GATT_DiscCharsByUUID(uint16 connHandle, attReadByTypeReq_t *pReq, uint8 taskId);

  292. //找到所有特性描述
  293. bStatus_t GATT_DiscAllCharDescs(uint16 connHandle, uint16 startHandle, uint16 endHandle, uint8 taskId);

  294. //读取特性值
  295. bStatus_t GATT_ReadCharValue(uint16 connHandle, attReadReq_t *pReq, uint8 taskId);
  296.         bleTimeout: Previous transaction timed out.<BR>

  297. //通过UUID读取特性值
  298. bStatus_t GATT_ReadUsingCharUUID(uint16 connHandle, attReadByTypeReq_t *pReq, uint8 taskId);

  299. //读取长特性值
  300. bStatus_t GATT_ReadLongCharValue(uint16 connHandle, attReadBlobReq_t *pReq, uint8 taskId);

  301. //读取多个特性值
  302. bStatus_t GATT_ReadMultiCharValues(uint16 connHandle, attReadMultiReq_t *pReq, uint8 taskId);

  303. //写特性值,不需要回应
  304. bStatus_t GATT_WriteNoRsp(uint16 connHandle, attWriteReq_t *pReq);

  305. bStatus_t GATT_SignedWriteNoRsp(uint16 connHandle, attWriteReq_t *pReq);

  306. //写特性值
  307. bStatus_t GATT_WriteCharValue(uint16 connHandle, attWriteReq_t *pReq, uint8 taskId);

  308. //写长特性值
  309. bStatus_t GATT_WriteLongCharValue(uint16 connHandle, gattPrepareWriteReq_t *pReq, uint8 taskId);

  310. bStatus_t GATT_ReliableWrites(uint16 connHandle, attPrepareWriteReq_t *pReqs, uint8 numReqs, uint8 flags, uint8 taskId);

  311. //读取特性描述
  312. bStatus_t GATT_ReadCharDesc(uint16 connHandle, attReadReq_t *pReq, uint8 taskId);

  313. //读取长特性描述
  314. bStatus_t GATT_ReadLongCharDesc(uint16 connHandle, attReadBlobReq_t *pReq, uint8 taskId);

  315. //写特性描述
  316. bStatus_t GATT_WriteCharDesc(uint16 connHandle, attWriteReq_t *pReq, uint8 taskId);

  317. //写长特性描述
  318. bStatus_t GATT_WriteLongCharDesc(uint16 connHandle, gattPrepareWriteReq_t *pReq, uint8 taskId);
  319. gap.h

  320. //设备初始化
  321. bStatus_t GAP_DeviceInit(  uint8 taskID,
  322.                            uint8 profileRole,
  323.                            uint8 maxScanResponses,
  324.                            uint8 *pIRK,
  325.                            uint8 *pSRK,
  326.                            uint32 *pSignCounter );

  327. //设置GAP广播搜索响应数据
  328. bStatus_t GAP_SetAdvToken( gapAdvDataToken_t *pToken );

  329. //读取GAP广播响应数据
  330. gapAdvDataToken_t *GAP_GetAdvToken( uint8 adType );

  331. //移除GAP广播响应数据
  332. gapAdvDataToken_t *GAP_RemoveAdvToken( uint8 adType );

  333. //重建加载广播响应数据
  334. bStatus_t GAP_UpdateAdvTokens( void );

  335. //设置GAP参数
  336. bStatus_t GAP_SetParamValue( gapParamIDs_t paramID, uint16 paramValue );

  337. //取得GAP参数
  338. uint16 GAP_GetParamValue( gapParamIDs_t paramID );

  339. //设置设备地址类型
  340. bStatus_t GAP_ConfigDeviceAddr( uint8 addrType, uint8 *pStaticAddr );

  341. //注册任务ID
  342. void GAP_RegisterForHCIMsgs( uint8 taskID );

  343. //开始搜索
  344. bStatus_t GAP_DeviceDiscoveryRequest( gapDevDiscReq_t *pParams );

  345. //取得发现任务
  346. bStatus_t GAP_DeviceDiscoveryCancel( uint8 taskID );

  347. //设置改变开始广播
  348. bStatus_t GAP_MakeDiscoverable( uint8 taskID, gapAdvertisingParams_t *pParams );

  349. //设置改变搜索响应数据
  350. bStatus_t GAP_UpdateAdvertisingData( uint8 taskID, uint8 adType,
  351.       uint8 dataLen, uint8 *pAdvertData );

  352. //停止广播
  353. bStatus_t GAP_EndDiscoverable( uint8 taskID );

  354. //Resolves a private address against an IRK.
  355. bStatus_t GAP_ResolvePrivateAddr( uint8 *pIRK, uint8 *pAddr );

  356. //建立一个连接到从设备
  357. bStatus_t GAP_EstablishLinkReq( gapEstLinkReq_t *pParams );

  358. //中断连接
  359. bStatus_t GAP_TerminateLinkReq( uint8 taskID, uint16 connectionHandle );

  360. //更新连接参数到从设备
  361. bStatus_t GAP_UpdateLinkParamReq( gapUpdateLinkParamReq_t *pParams );

  362. //返回活跃连接数
  363. uint8 GAP_NumActiveConnections( void );

  364. //启动认证流程
  365. bStatus_t GAP_Authenticate( gapAuthParams_t *pParams, gapPairingReq_t *pPairReq );

  366. //发送配对失败消息
  367. bStatus_t GAP_TerminateAuth( uint16 connectionHandle, uint8 reason );

  368. //字符串格式的密钥更新
  369. bStatus_t GAP_PasskeyUpdate( uint8 *pPasskey, uint16 connectionHandle );

  370. //数字形式的密钥更新
  371. bStatus_t GAP_PasscodeUpdate( uint32 passcode, uint16 connectionHandle );

  372. //产生一个从机请求的安全消息到主机
  373. bStatus_t GAP_SendSlaveSecurityRequest( uint16 connectionHandle, uint8 authReq );

  374. //Set up the connection to accept signed data.
  375. bStatus_t GAP_Signable( uint16 connectionHandle, uint8 authenticated, smSigningInfo_t *pParams );

  376. //设置连接的绑定参数
  377. bStatus_t GAP_Bond( uint16 connectionHandle, uint8 authenticated,
  378.       smSecurityInfo_t *pParams, uint8 startEncryption );

  379. att.h

  380. //解析ATT包
  381. uint8 ATT_ParsePacket(l2capDataEvent_t *pL2capMsg, attPacket_t *pPkt);

  382. //比较UUID
  383. uint8 ATT_CompareUUID(const uint8 *pUUID1, uint16 len1, const uint8 *pUUID2, uint16 len2);

  384. //转换16bit的UUID到128bit
  385. uint8 ATT_ConvertUUIDto128(const uint8 *pUUID16, uint8 *pUUID128);

  386. //转换128bit的UUID到16bit
  387. uint8 ATT_ConvertUUIDto16(const uint8 *pUUID128, uint8 *pUUID16);

  388. //构建错误响应
  389. uint16 ATT_BuildErrorRsp(uint8 *pBuf, uint8 *pMsg);

  390. //解析错误响应
  391. bStatus_t ATT_ParseErrorRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  392. //构建交换MTU请求
  393. uint16 ATT_BuildExchangeMTUReq(uint8 *pBuf, uint8 *pMsg);

  394. //构建交换MTU响应
  395. uint16 ATT_BuildExchangeMTURsp(uint8 *pBuf, uint8 *pMsg);

  396. //解析MTU响应
  397. bStatus_t ATT_ParseExchangeMTURsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  398. //构建找信息请求
  399. uint16 ATT_BuildFindInfoReq(uint8 *pBuf, uint8 *pMsg);

  400. //解析找信息响应
  401. bStatus_t ATT_ParseFindInfoRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  402. //构建找信息响应
  403. uint16 ATT_BuildFindInfoRsp(uint8 *pBuf, uint8 *pMsg);

  404. //构建通过类型值找请求
  405. uint16 ATT_BuildFindByTypeValueReq(uint8 *pBuf, uint8 *pMsg);

  406. //构建通过类型值找响应
  407. uint16 ATT_BuildFindByTypeValueRsp(uint8 *pBuf, uint8 *pMsg);

  408. //解析通过类型值找响应
  409. bStatus_t ATT_ParseFindByTypeValueRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  410. //构建通过类型值读请求
  411. uint16 ATT_BuildReadByTypeReq(uint8 *pBuf, uint8 *pMsg);

  412. //构建通过类型值读响应
  413. uint16 ATT_BuildReadByTypeRsp(uint8 *pBuf, uint8 *pMsg);

  414. //解析通过类型值读响应
  415. bStatus_t ATT_ParseReadByTypeRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  416. //构建读请求
  417. uint16 ATT_BuildReadReq(uint8 *pBuf, uint8 *pMsg);

  418. //构建读响应
  419. uint16 ATT_BuildReadRsp(uint8 *pBuf, uint8 *pMsg);

  420. //解析读响应
  421. bStatus_t ATT_ParseReadRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  422. //构建场数据读取请求
  423. uint16 ATT_BuildReadBlobReq(uint8 *pBuf, uint8 *pMsg);

  424. //构建长数据读取响应
  425. uint16 ATT_BuildReadBlobRsp(uint8 *pBuf, uint8 *pMsg);

  426. //解析大数据读取响应
  427. bStatus_t ATT_ParseReadBlobRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  428. //构建多数据读取请求
  429. uint16 ATT_BuildReadMultiReq(uint8 *pBuf, uint8 *pMsg);

  430. //构建多数据读取响应
  431. uint16 ATT_BuildReadMultiRsp(uint8 *pBuf, uint8 *pMsg);

  432. //解析多数据读取响应
  433. bStatus_t ATT_ParseReadMultiRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  434. //Build Read By Group Type Response.
  435. uint16 ATT_BuildReadByGrpTypeRsp(uint8 *pBuf, uint8 *pMsg);

  436. // Parse Read By Group Type Response.
  437. bStatus_t ATT_ParseReadByGrpTypeRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  438. // Build Write Request.
  439. uint16 ATT_BuildWriteReq(uint8 *pBuf, uint8 *pMsg);

  440. //Parse Write Response.
  441. bStatus_t ATT_ParseWriteRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  442. // Build Prepare Write Request.
  443. uint16 ATT_BuildPrepareWriteReq(uint8 *pBuf, uint8 *pMsg);

  444. //Build Prepare Write Response.
  445. uint16 ATT_BuildPrepareWriteRsp(uint8 *pBuf, uint8 *pMsg);

  446. //Parse Prepare Write Response.
  447. bStatus_t ATT_ParsePrepareWriteRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  448. // Build Execute Write Request.
  449. uint16 ATT_BuildExecuteWriteReq(uint8 *pBuf, uint8 *pMsg);

  450. // Parse Execute Write Response.
  451. bStatus_t ATT_ParseExecuteWriteRsp(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  452. //Build Handle Value Indication.
  453. uint16 ATT_BuildHandleValueInd(uint8 *pBuf, uint8 *pMsg);

  454. //Parse Handle Value Indication.
  455. bStatus_t ATT_ParseHandleValueInd(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  456. // Parse Exchange MTU Request.
  457. bStatus_t ATT_ParseExchangeMTUReq(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  458. //Parse Find Information Request.
  459. bStatus_t ATT_ParseFindInfoReq(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  460. // Parse Find By Type Value Request.
  461. bStatus_t ATT_ParseFindByTypeValueReq(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  462. // Parse Read By Type Request.
  463. bStatus_t ATT_ParseReadByTypeReq(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  464. //Parse Read Request.
  465. bStatus_t ATT_ParseReadReq(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  466. //Parse Write Blob Request.
  467. bStatus_t ATT_ParseReadBlobReq(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  468. //Parse Read Multiple Request.
  469. bStatus_t ATT_ParseReadMultiReq(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  470. //Parse Write Request.
  471. bStatus_t ATT_ParseWriteReq(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  472. //Parse Execute Write Request.
  473. bStatus_t ATT_ParseExecuteWriteReq(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  474. //Parse Prepare Write Request.
  475. bStatus_t ATT_ParsePrepareWriteReq(uint8 sig, uint8 cmd, uint8 *pParams, uint16 len, attMsg_t *pMsg);

  476. // Parse Handle Value Confirmation.
  477. bStatus_t ATT_ParseHandleValueCfm(uint8 *pParams, uint16 len, attMsg_t *pMsg);

  478. //发送交换MTU请求
  479. bStatus_t ATT_ExchangeMTUReq(uint16 connHandle, attExchangeMTUReq_t *pReq);

  480. //Send Find Information Request.
  481. bStatus_t ATT_FindInfoReq(uint16 connHandle, attFindInfoReq_t *pReq);

  482. // Send Find By Type Value Request.
  483. bStatus_t ATT_FindByTypeValueReq(uint16 connHandle, attFindByTypeValueReq_t *pReq);

  484. //Send Read By Type Request.
  485. bStatus_t ATT_ReadByTypeReq(uint16 connHandle, attReadByTypeReq_t *pReq);

  486. // Send Read Request.
  487. bStatus_t ATT_ReadReq(uint16 connHandle, attReadReq_t *pReq);

  488. // Send Read Blob Request.
  489. bStatus_t ATT_ReadBlobReq(uint16 connHandle, attReadBlobReq_t *pReq);

  490. // Send Read Multiple Request.
  491. bStatus_t ATT_ReadMultiReq(uint16 connHandle, attReadMultiReq_t *pReq);

  492. // Send Read By Group Type Request.
  493. bStatus_t ATT_ReadByGrpTypeReq(uint16 connHandle, attReadByGrpTypeReq_t *pReq);

  494. // Send Write Request.
  495. bStatus_t ATT_WriteReq(uint16 connHandle, attWriteReq_t *pReq);

  496. // Send Prepare Write Request.
  497. bStatus_t ATT_PrepareWriteReq(uint16 connHandle, attPrepareWriteReq_t *pReq);

  498. // Send Execute Write Request.
  499. bStatus_t ATT_ExecuteWriteReq(uint16 connHandle, attExecuteWriteReq_t *pReq);

  500. // Send Handle Value Confirmation.
  501. bStatus_t ATT_HandleValueCfm(uint16 connHandle);

  502. // Send Error Response.
  503. bStatus_t ATT_ErrorRsp(uint16 connHandle, attErrorRsp_t *pRsp);

  504. //Send Exchange MTU Response.
  505. bStatus_t ATT_ExchangeMTURsp(uint16 connHandle, attExchangeMTURsp_t *pRsp);

  506. // Send Find Information Response.
  507. bStatus_t ATT_FindInfoRsp(uint16 connHandle, attFindInfoRsp_t *pRsp);

  508. //Send Find By Tyep Value Response.
  509. bStatus_t ATT_FindByTypeValueRsp(uint16 connHandle, attFindByTypeValueRsp_t *pRsp);

  510. //Send Read By Type Respond.
  511. bStatus_t ATT_ReadByTypeRsp(uint16 connHandle, attReadByTypeRsp_t *pRsp);

  512. //Send Read Response.
  513. bStatus_t ATT_ReadRsp(uint16 connHandle, attReadRsp_t *pRsp);

  514. // Send Read Blob Response.
  515. bStatus_t ATT_ReadBlobRsp(uint16 connHandle, attReadBlobRsp_t *pRsp);

  516. //Send Read Multiple Response.
  517. bStatus_t ATT_ReadMultiRsp(uint16 connHandle, attReadMultiRsp_t *pRsp);

  518. // Send Read By Group Type Respond.
  519. bStatus_t ATT_ReadByGrpTypeRsp(uint16 connHandle, attReadByGrpTypeRsp_t *pRsp);

  520. //Send Write Response.
  521. bStatus_t ATT_WriteRsp(uint16 connHandle);

  522. // Send Prepare Write Response.
  523. bStatus_t ATT_PrepareWriteRsp(uint16 connHandle, attPrepareWriteRsp_t *pRsp);

  524. // Send Execute Write Response.
  525. bStatus_t ATT_ExecuteWriteRsp(uint16 connHandle);

  526. // Send Handle Value Notification.
  527. bStatus_t ATT_HandleValueNoti(uint16 connHandle, attHandleValueNoti_t *pNoti);

  528. // Send Handle Value Indication.
  529. bStatus_t ATT_HandleValueInd(uint16 connHandle, attHandleValueInd_t *pInd);

  530. //设置ATT参数
  531. void ATT_SetParamValue(uint16 value);

  532. //取得ATT参数
  533. uint16 ATT_GetParamValue(void);

复制代码

以上就是CC2541,CC254x的常用库函数了。把他总结出来,有时候忘记的时候可以随时翻看一下,挺方便的,希望对大家有用!

好东西,很强

上一篇:zigbee协议栈程序的协调器以及终端的HEX文件大小均超过了256kb
下一篇:cc2541编译出错,什么原因导致的?

手机天线设计培训教程详情>>

手机天线设计培训教程 国内最全面、系统、专业的手机天线设计培训课程,没有之一;是您学习手机天线设计的最佳选择...【More..

射频和天线工程师培训课程详情>>

  网站地图