当前位置:网站首页>快速实现蓝牙iBeacn功能详解
快速实现蓝牙iBeacn功能详解
2022-06-27 06:17:00 【shine_blink】
Core变成iBeacon节点
一、iBeacon简介
iBeacon 是苹果公司2013年9月发布的移动设备用 OS(iOS7)上配备的新功能。其工作方式是,配备有 低功耗蓝牙(BLE) 通信功能的设备使用 BLE 技术向周围发送自己特有的 ID,接收到该 ID 的应用软件会根据该 ID 采取一些行动。比如,在店铺里设置 iBeacon 通信模块的话,便可让 iPhone 和 iPad 上运行一资讯告知服务器,或者由服务器向顾客发送折扣券及进店积分。此外,还可以在家电发生故障或停止工作时使用 iBeacon 向应用软件发送资讯。
二、iBeacon格式
iBeacon 使用的是 BLE 技术,具体而言,利用的是 BLE 中名为“通告帧”(Advertising)的广播帧。通告帧是定期发送的帧,只要是支持 BLE 的设备就可以接收到。iBeacon 通过在这种通告帧的有效负载部分嵌入苹果自主格式的数据来实现。
AD Field Length: Advertisement Data 的长度,表示有用的广播信息长度
Type: 广播类型
Company ID: 数据字段以两字节的公司 ID 码开始。SIG 将这些 ID 码发放给公司,其中 0x004C 代表的是Apple id(只有这个 ID,设备才会叫 iBeacon)
iBeacon Type: 字节 0x02 代表这个设备是 Beacon
iBeacon Length: 剩下字段的长度
UUID: 规定为 ISO/IEC11578:1996 标准的 128 位标识符
Major、Minor: 由 iBeacon 发布者自行设定,都是 16 位的标识符。比如,连锁店可以在 Major 写入区域资讯,可在 Minor 中写入个别店铺的 ID 等。另外,在家电中嵌入 iBeacon 功能时,可以用 Major 表示产品型号,用 Minor 表示错误代码,用来向外部通知故障
TX Power: APP 通过 iBeacon 发送信号强度估算出的在 1 米的时候 RSSI 强度
关于iBeacon的详细资料请参看苹果官方文档:
https://developer.apple.com/ibeacon/Getting-Started-with-iBeacon.pdf
三、完整代码
实现功能:自定义iBeacon广播的具体内容,并每隔半秒更新一次iBeacon广播内容中的Major和Minor字段的值。
--这里为了实验目的,任意定义了16个数据为作为uuid
uuid = {
0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF}
--初始化iBeacon广播信息具体内容,并开启iBeacon蓝牙广播,注意:该函数只能调用一次
--CompanyID=0x004C, Major=0x1234, Minor=0x5678, rssi_1m=0xC3(-59db), 广播间隔=100ms
LIB_NrfBleIbeaconConfig(0x004C,0x1234,0x5678,0x3C,100,uuid)
major = 0
minor = 10000
--开始大循环
while(GC(1) == true)
do
--每隔500ms(0.5秒)更新一次iBeacon蓝牙广播中的Major和Minor的值
LIB_DelayMs(500)
major = major + 1
minor = minor - 1
LIB_NrfBleIbeaconUpdate(major,minor)
end
四、演示
以上代码运行之后,我们在安卓手机安装nRF Connect App蓝牙调试软件,并通过Scan扫描到的iBeacon信息如下:
上图中不仅可以看到iBeacon节点的UUID信息,同事还可以实时看到Major的值在不停的增加,Minor的值在不停的减少。
更多详情请参看 shineblink.com官网链接
边栏推荐
- Dev++ environment setting C language keyword display color
- 免费的 SSH 和 Telnet 客户端PuTTY
- 乐观事务和悲观事务
- How to check the frequency of memory and the number of memory slots in CPU-Z?
- Dev++ 环境设置C语言关键字显示颜色
- KubeSphere 集群配置 NFS 存储解决方案-收藏版
- Gaussian distribution, linear regression, logistic regression
- 多线程基础部分Part 1
- Matlab quickly converts two-dimensional coordinates of images into longitude and latitude coordinates
- Openresty usage document
猜你喜欢

Convolution neural network -- Application of CNN model (ore prospecting prediction)

Altium designer 19 device silk screen label position shall be placed uniformly in batches

Assembly language - Wang Shuang Chapter 11 flag register - Notes

飞行器翼尖加速度和控制面的MPC控制

线程间等待与唤醒机制、单例模式、阻塞队列、定时器

汇编语言-王爽 第9章 转移指令的原理-笔记

matlab GUI界面仿真直流电机和交流电机转速仿真

创建一个基础WDM驱动,并使用MFC调用驱动

Distribution gaussienne, régression linéaire, régression logistique

机 器 学 习
随机推荐
Webrtc series - Nomination and ice of 7-ice supplement for network transmission_ Model
30 SCM common problems and solutions!
汇编语言-王爽 第11章 标志寄存器-笔记
Distribution gaussienne, régression linéaire, régression logistique
【入门】正则表达式基础入门笔记
openresty使用文档
JS to implement bidirectional data binding
310. 最小高度树
Software testing year end summary report template
机 器 学 习
KubeSphere 集群配置 NFS 存储解决方案-收藏版
multiprocessing.pool详解
JVM的垃圾回收机制
What's new in redis4.0 - active memory defragmentation
Configuration of vscode korofileheader
427- binary tree (617. merge binary tree, 700. search in binary search tree, 98. verify binary search tree, 530. minimum absolute difference of binary search tree)
How to check the frequency of memory and the number of memory slots in CPU-Z?
下载cuda和cudnn
Go log -uber open source library zap use
JVM common instructions