当前位置:网站首页>Quick realization of Bluetooth ibeacn function
Quick realization of Bluetooth ibeacn function
2022-06-27 06:24:00 【shine_ blink】
Core become iBeacon node
One 、iBeacon brief introduction
iBeacon It's apple 2013 year 9 Mobile devices released in January use OS(iOS7) New features on . The way it works is , Equipped with Low power Bluetooth (BLE) Communication function of the device use BLE Technology sends its own unique ID, Receive the ID Your application software will be based on this ID Take some action . such as , Set up... In the store iBeacon Communication module , Can let iPhone and iPad Run an information notification server on , Or the server sends discount coupons and store entry points to customers . Besides , It can also be used when the home appliance breaks down or stops working iBeacon Send information to the application .
Two 、iBeacon Format
iBeacon It uses BLE technology , To be specific , Use of is BLE Middle name is “ Announcement frame ”(Advertising) The broadcast frame of . An announcement frame is a frame sent periodically , As long as it's support BLE Your device can receive .iBeacon This is achieved by embedding data in Apple's own format in the payload part of this announcement frame .
AD Field Length: Advertisement Data The length of , Indicates the length of useful broadcast information
Type: The radio type
Company ID: The data field is a two byte company ID Code start .SIG Will these ID Code issued to the company , among 0x004C It stands for Apple id( Only this ID, The device will call iBeacon)
iBeacon Type: byte 0x02 This device is Beacon
iBeacon Length: The length of the remaining fields
UUID: It is stipulated that ISO/IEC11578:1996 The standard 128 Bit identifier
Major、Minor: from iBeacon The publisher sets it himself , All are 16 Bit identifier . such as , Chain stores can be in Major Write area information , Can be found in Minor For individual stores ID etc. . in addition , Embed... In appliances iBeacon When the function , It can be used Major Indicates the product model , use Minor Indicates the error code , It is used to notify the outside of the fault
TX Power: APP adopt iBeacon The transmitted signal strength is estimated at 1 When it's rice RSSI Strength
About iBeacon Please refer to Apple's official documentation for details of :
https://developer.apple.com/ibeacon/Getting-Started-with-iBeacon.pdf
3、 ... and 、 Complete code
Realization function : Customize iBeacon The specific content of the broadcast , And update every half a second iBeacon In the broadcast content Major and Minor Value of field .
-- Here for experimental purposes , Arbitrarily defined 16 Data is as uuid
uuid = {
0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF}
-- initialization iBeacon Specific content of broadcast information , And open iBeacon Bluetooth radio , Be careful : This function can only be called once
--CompanyID=0x004C, Major=0x1234, Minor=0x5678, rssi_1m=0xC3(-59db), Broadcast interval =100ms
LIB_NrfBleIbeaconConfig(0x004C,0x1234,0x5678,0x3C,100,uuid)
major = 0
minor = 10000
-- Start the big cycle
while(GC(1) == true)
do
-- every other 500ms(0.5 second ) Updated once iBeacon In Bluetooth broadcast Major and Minor Value
LIB_DelayMs(500)
major = major + 1
minor = minor - 1
LIB_NrfBleIbeaconUpdate(major,minor)
end
Four 、 demonstration
After the above code runs , We install... On Android phones nRF Connect App Bluetooth debugging software , And pass Scan Scanned iBeacon The information is as follows :
Not only can you see iBeacon Node UUID Information , Colleagues can also see in real time Major The value of is constantly increasing ,Minor The value of is constantly decreasing .
For more details, please refer to shineblink.com The website links
边栏推荐
猜你喜欢
Assembly language - Wang Shuang Chapter 13 int instruction - Notes
thrift
Kubesphere cluster configuration NFS storage solution - favorite
快速实现蓝牙iBeacn功能详解
Openresty usage document
建模竞赛-光传送网建模与价值评估
Go log -uber open source library zap use
第 299 场周赛 第四题 6103. 从树中删除边的最小分数
多线程基础部分Part 1
Multithreading basic part2
随机推荐
tracepoint
Functional continuous
创建一个基础WDM驱动,并使用MFC调用驱动
Information System Project Manager - Chapter VII project cost management
TiDB 基本功能
Keep 2 decimal places after multiplying SQLSEVER fields
分数阶PID控制
可扩展哈希
Multithreading basic part part 1
汇编语言-王爽 第9章 转移指令的原理-笔记
LeetCode 0086. Separate linked list
JVM garbage collection mechanism
Us camera cloud service scheme: designed for lightweight video production scenes
KubeSphere 集群配置 NFS 存储解决方案-收藏版
古典密码体制--代换和置换
TiDB的事务概览
Configuration of vscode korofileheader
多线程带来的的风险——线程安全
Scala函数柯里化(Currying)
Assembly language - Wang Shuang Chapter 11 flag register - Notes