Learning BLE from Scratch: Connection (Part 2)

Although our article is titled “Connection”, we are still within the scope of broadcast packets. Why is that?Do you remember the types of broadcasts we introduced?Among them, CONNECT_REQ, also known as CONNECT_IND, is the initiator’s connection request.Learning BLE from Scratch: Connection (Part 2)Broadcast Packet TypesLearning BLE from Scratch: Connection (Part 2)CONNECT_IND PacketDo you remember what this header means?Learning BLE from Scratch: Connection (Part 2)Broadcast Packet HeaderLearning BLE from Scratch: Connection (Part 2)Broadcast Packet Structure

When introducing broadcasts, the following concepts are often involved, which can sometimes be confusing.

Learning BLE from Scratch: Connection (Part 2)Connection Request Packet (Connect_Req) Link Layer Data Section

CRCInit: crcInitial value for CRC

WinSize:Send window size,transmit window size(transmitWindowSize) =window size(WinSize) x 1.25 ms;

WinOffset indicates the offset of the transmit window(transmitWindowSize),transmit window offset(transmitWindowSize) =window offset(WinSize) x 1.25 ms;

Learning BLE from Scratch: Connection (Part 2)

Intervalis used to indicate the link layer connection event time interval parameter connInterval,and is given in the form of connInterval = Interval x 1.25 ms,where Interval will have a value,ranging from8 to 24;

Latencyis used to represent the slave device connection delay(connSlaveLatency),where the slave connection delay(connSlaveLatency) =delay(Latency)

The timeout field indicates the link supervision timeout(connSupervisionTimeout),where the link supervision timeout(connSupervisionTimeout) =timeout(Timeout) x 10 ms;

Hopis used to indicate the hop length,which is used in data channel selection,and it will have a value,ranging from5 to 16;

SCAis used to indicate sleep clock accuracy

Let’s take a look at the specific dataLearning BLE from Scratch: Connection (Part 2)Data part with a maximum length of 37 bytesLearning BLE from Scratch: Connection (Part 2)CONNECT_IND data includes the access address, initial CRC value, window size 1.25*5=6.25 ms, window offset, connection interval, slave latency, and timeout. Let’s get a visual feel for it.Channel MapChM contains the channel distribution, which indicates the data channels that have been used and those that have not. Each channel is represented by a data bit,and this data bit is located according to the data channel index. If a channel is a used channel,its data bit is set to1. If a data bit’s value is0,it indicates that this channel is not in use. The37,38,39data bits are set to0,and will be ignored upon reception.Learning BLE from Scratch: Connection (Part 2)In Connection (Part 1), we also mentioned that connect_req actually informs the advertiser that the phone will send the first synchronization packet (P1) to you during the Transmit Window period, so please open your RF reception window during this time. Device B will reply with data packet P2 (ACK packet) after T_IFS time once it receives P1. Once the phone receives data packet P2, the connection can be considered successfully established.After a successful connection, the master and slave must interact at the beginning of each connection interval, meaning the master sends a packet to the slave, and the slave sends a packet back to the master. This entire interaction process is called a connection event.Learning BLE from Scratch: Connection (Part 2)Learning BLE from Scratch: Connection (Part 2)Empty Data PacketAt the beginning of each connection interval, the Master and Slave must interact, even if the interaction is an empty packet.I hope the combination of theory and practice has made things clearer for you.

Leave a Comment