没有合适的资源?快使用搜索试试~ 我知道了~
首页BLE蓝牙-4.0-学习笔记
蓝牙4.0 BLE center与peripheral建立连接绑定过程 2 蓝牙4.0 BLE peripheral 广播设置 7 蓝牙4.0 BLE 数据传输 (一) 11 蓝牙4.0 BLE 数据传输 (二) 12 蓝牙4.0 BLE 数据传输(三) 16 蓝牙4.0 BLE 数据传输(四) 19 蓝牙4.0 BLE 数据传输(五) 23 蓝牙4.0 BLE 程序设计相关问题解答(转载) 25 蓝牙4.0 BLE SimpleBLEPeripheral_添加新CHAR值及UUID 33 蓝牙4.0 BLE peripheral 广播设置学习笔记(转载) 45 蓝牙4.0 BLE key处理过程看任务、事件、消息机制 50 CC254x 内部存储结构 FLASH 53 蓝牙4.0 BLE FLASH 操作 58
资源详情
资源评论
资源推荐

蓝牙 4.0BLEcenter 与 peripheral 建立连接绑定过程............................................................2
蓝牙 4.0 BLE peripheral 广播设置..........................................................................................9
蓝牙 4.0 BLE 数据传输 (一)............................................................................................15
蓝牙 4.0 BLE 数据传输 (二)............................................................................................16
蓝牙 4.0 BLE 数据传输(三).............................................................................................20
蓝牙 4.0 BLE 数据传输(四).............................................................................................23
蓝牙 4.0 BLE 数据传输(五).............................................................................................27
蓝牙 4.0 BLE 程序设计相关问题解答(转载)..................................................................29
蓝牙 4.0 BLE SimpleBLEPeripheral_添加新 CHAR 值及 UUID..........................................38
蓝牙 4.0 BLE peripheral 广播设置学习笔记(转载).........................................................51
蓝牙 4.0 BLE key 处理过程看任务、事件、消息机制........................................................56
CC254x 内部存储结构 FLASH.............................................................................................59
蓝牙 4.0 BLE FLASH 操作....................................................................................................64

蓝牙 4.0BLEcenter 与 peripheral 建立连接
绑定过程
-------------------------------------------------------------------------------------------------------------------
蓝牙主机从机建立连接绑定过程
center 与 simplePeripheral 建立连接过程
center 首 先 进 行 osal_init_system() 初 始 化 各 个 任 务 , SimpleBLECentral_Init-
>osal_set_event( simpleBLETaskId, START_DEVICE_EVT ); 进 入
SimpleBLECentral_ProcessEvent()
调用
VOID GAPCentralRole_StartDevice( (gapCentralRoleCB_t *)
&simpleBLERoleCB );// 当 初 始 化 完 成 , 会 发 送
GAP_DEVICE_INIT_DONE_EVENT 由于注册了 simpleBLERoleCB 函数,因此
发 送 的 event 由 simpleBLERoleCB 函 数 接 收 static void
simpleBLECentralEventCB( gapCentralRoleEvent_t *pEvent ) 此 时 pEvent-
>gap.opcode =GAP_DEVICE_INIT_DONE_EVENT,相应信息存储于 pEvent 中
typedef union
{
gapEventHdr_t gap; //!< GAP_MSG_EVENT and status.
gapDeviceInitDoneEvent_t initDone; //!< GAP initialization done.
gapDeviceInfoEvent_t deviceInfo; //!< Discovery device information event
structure.
gapDevDiscEvent_t discCmpl; //!< Discovery complete event structure.
gapEstLinkReqEvent_t linkCmpl; //!< Link complete event structure.
gapLinkUpdateEvent_t linkUpdate; //!< Link update event structure.

gapTerminateLinkEvent_t linkTerminate; //!< Link terminated event structure.
} gapCentralRoleEvent_t;
联合体,只有 deviceInfo 里面的数据是正确的
typedef struct
{
osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
uint8 opcode; //!< GAP_DEVICE_INIT_DONE_EVENT
uint8 devAddr[B_ADDR_LEN]; //!< Device's BD_ADDR
uint16 dataPktLen; //!< HC_LE_Data_Packet_Length
uint8 numDataPkts; //!< HC_Total_Num_LE_Data_Packets
} gapDeviceInitDoneEvent_t;
能获得如设备地址等信息
设备初始化完成
通过串口发送'1'触发设备发现
进行设备扫描
GAP_DEVICE_INFO_EVENT 0x0D //!< Sent during the Device
Discovery Process when a device is discovered.
GAP_DEVICE_DISCOVERY_EVENT 0x01 //!< Sent when the Device
Discovery Process is complete.
当发现一个设备时,触发一个设备 info 事件同样是在 simpleBLECentralEventCB
处理此时 pEvent 改变为 deviceInfo 可以获得广告设备的类型,地址。rssi 强度,
还有广告数据,内容如下。
typedef struct
{
osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
uint8 opcode; //!< GAP_DEVICE_INFO_EVENT
uint8 eventType; //!< Advertisement Type: @ref
GAP_ADVERTISEMENT_TYPE_DEFINES
uint8 addrType; //!< address type: @ref GAP_ADDR_TYPE_DEFINES
uint8 addr[B_ADDR_LEN]; //!< Address of the advertisement or SCAN_RSP
int8 rssi; //!< Advertisement or SCAN_RSP RSSI
uint8 dataLen; //!< Length (in bytes) of the data field (evtData)
uint8 *pEvtData; //!< Data field of advertisement or SCAN_RSP
} gapDeviceInfoEvent_t;

center 代码是通过设备服务器的 uuid 来查找设备,一旦找到相应的设备,将设
备加入
设备表 simpleBLEDevList[]中 simpleBLEScanRes 扫描到的个数自加一。
typedef struct
{
uint8 eventType; //!< Indicates advertising event type used by the advertiser:
GAP_ADVERTISEMENT_TYPE_DEFINES
uint8 addrType; //!< Address Type: @ref GAP_ADDR_TYPE_DEFINES
uint8 addr[B_ADDR_LEN]; //!< Device's Address
} gapDevRec_t;
设备表的结构体
addrType 有:
#define ADDRTYPE_PUBLIC 0x00
Use the BD_ADDR.
#define ADDRTYPE_STATIC 0x01
Static address.
#define ADDRTYPE_PRIVATE_NONRESOLVE 0x02
Generate Non-Resolvable Private Address.
#define ADDRTYPE_PRIVATE_RESOLVE 0x03
Generate Resolvable Private Address.
case GAP_DEVICE_INFO_EVENT:
{
if ( DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE )
{
if ( simpleBLEFindSvcUuid( SIMPLEPROFILE_SERV_UUID, // 通过 uuid 找
到的设备
pEvent->deviceInfo.pEvtData,
pEvent->deviceInfo.dataLen ) )
{
// HalUARTWrite(0,"info\n",sizeof("info\n"));//dataLen 数据长度 pEvtData
数据

simpleBLEAddDeviceInfo( pEvent->deviceInfo.addr, pEvent-
>deviceInfo.addrType );
}
}
}
break;
此时已经获得了扫描到的设备个数,以及设备地址,还有广告内容等信息。
通过串口发送‘3’来 建立连接
建立连接:
typedef struct
{
uint8 taskID; //!< Requesting App/Profile's Task ID
uint8 highDutyCycle; //!< TRUE to high duty cycle scan, FALSE if not.
uint8 whiteList; //!< Determines use of the white list: @ref
GAP_WHITELIST_DEFINES
uint8 addrTypePeer; //!< Address type of the advertiser: @ref
GAP_ADDR_TYPE_DEFINES
uint8 peerAddr[B_ADDR_LEN]; //!< Advertiser's address
} gapEstLinkReq_t;
调 用 GAP_EstablishLinkReq(gapEstLinkReq_t params ); 完 成 后 发 送
GAP_LINK_ESTABLISHED_EVENT, 由
simpleBLECentralEventCB( gapCentralRoleEvent_t *pEvent )处理
#define GAP_LINK_ESTABLISHED_EVENT 0x05 //!< Sent when the
Establish Link Request is complete.
用此时 pEvent 变为:
typedef struct
{
osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
uint8 opcode; //!< GAP_LINK_ESTABLISHED_EVENT
uint8 devAddrType; //!< Device address type: @ref
GAP_ADDR_TYPE_DEFINES
uint8 devAddr[B_ADDR_LEN]; //!< Device address of link
uint16 connectionHandle; //!< Connection Handle from controller used to ref the
device
uint16 connInterval; //!< Connection Interval
剩余63页未读,继续阅读















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0