当前位置:网站首页>Fast realization of Bluetooth communication between MCU and mobile phone
Fast realization of Bluetooth communication between MCU and mobile phone
2022-06-27 06:24:00 【shine_ blink】
Core Via mobile phone Ble Bluetooth for communication
Big update !
shineblink.com Development free App, Developers don't have to do anything Android or IOS Development , That is, you can have a mobile phone that can and Core Development board communication specialty App
One 、 Realization function
Core Our main chip comes with BLE Bluetooth function , So just Core You can easily realize the mutual communication with mobile phones . The function of this chapter is to establish Bluetooth connection with mobile phone :(1)Core every other 0.2 Send a packet of data to the mobile phone in seconds ,(2) We're debugging on the phone App Customize any packet sent to Core,Core When received, pass through Print() Function print out .
Be careful : because Core Inside comes 2.4G Wireless capabilities , Therefore, the Bluetooth communication function of this chapter can be realized without external devices or modules . But if it's used Ble Bluetooth function ,Core Of 2.4G The single point or multi-point communication function cannot be used , Developers need to pay attention to this .
Mobile debugging App Here we choose to use apples IOS Well known LightBlue, Android mobile phone download and install BleTool Or Android version LightBlue It's fine too .
Two 、 Implementation mechanism
Core Of ble Low power Bluetooth offers two features , One is Write characteristic , One is Notify characteristic . among :
Write characteristic : It can be seen as a mobile phone sending data to Core The passage of , The mobile phone is sent to Core The data is stored in Write In the feature .
Notify characteristic : It can be seen as Core Channel to send data to the phone ,Core The data sent to the mobile phone through Bluetooth is stored in Notify On . But we need to pay attention , The phone wants to receive from Core The data of , You need to enable this on your mobile phone Notify( It will be mentioned in the following demonstration ).
The following is true. Core Of Ble Provided by the service describe , It doesn't matter if you don't understand this paragraph , Just follow the above understanding .
service(UUID: 0x0001) describe : service There are two features (Characteristic):
One for sending data , One to receive dataRx Characteristic (UUID: 0x0002) Used to receive data from mobile phones Mobile phone Bluetooth can be used through ATT Write Way to Rx
Characteristic send data Tx Characteristic (UUID: 0x0003) To send data to a mobile phone If Bluetooth is Tx
Characteristic Enabled notification, Then the device can send notification To send data to mobile phone Bluetooth
3、 ... and 、 Complete code
-- Configure Low Power Bluetooth to work with default parameters , The name of the device is "MyBle002"
-- The device name is the name shown in the list when the mobile phone scans the Bluetooth device .
LIB_NrfBleDefaultConfig("MyBle002")
-- Start the big cycle
while(GC(1) == true)
do
LIB_DelayMs(200)
send_tab = {
0,1,2,3,4,5,6,7,8,9}
-- take send_tab In the array 10 Elements sent to the phone
LIB_NrfBleSend(send_tab)
-- Check whether you receive Bluetooth data from your mobile phone , If you receive it print Print out
recv_flag, recv_tab = LIB_NrfBleRecv()
if recv_flag == 1 then
-- Print received data
for k,v in ipairs(recv_tab) do
print(k,v)
end
end
end
Four 、 demonstration
1. Turn on the iPhone LightBlue Software , And start searching for Bluetooth devices nearby , find "MyBle002" Then click to enter
2. find properties notify characteristic , Click to enter
3. Click on Listen for notification, So that you can receive Core The data is coming in
4. You can see every 0.2 A packet of data will be received in seconds
5. Back to the step 2 The interface of , Click on properties write, And then click write new value
6. Set to send to Core The data is AA BB CC DD EE FF

7. Last in Core Of TF Cary LOG.TXT The file can be seen that we just sent it manually by mobile phone Core Of AA BB CC DD EE FF data 
For more details, please refer to shineblink.com The website links
边栏推荐
- KubeSphere 集群配置 NFS 存储解决方案-收藏版
- C Primer Plus Chapter 11_ Strings and string functions_ Codes and exercises
- Active learning
- Spark's projection
- Assembly language - Wang Shuang Chapter 8 two basic problems in data processing - Notes
- G1和ZGC垃圾收集器
- 高斯分布Gaussian distribution、線性回歸、邏輯回歸logistics regression
- Distribution gaussienne, régression linéaire, régression logistique
- 下载cuda和cudnn
- 【Cocos Creator 3.5.1】event. Use of getbutton()
猜你喜欢
随机推荐
Dev++ environment setting C language keyword display color
分数阶PID控制
信息系统项目管理师---第七章 项目成本管理
tar: /usr/local:归档中找不到tar: 由于前次错误,将以上次的错误状态退出
427-二叉树(617.合并二叉树、700.二叉搜索树中的搜索、98. 验证二叉搜索树、530.二叉搜索树的最小绝对差)
Information System Project Manager - Chapter VII project cost management
[collection] Introduction to basic knowledge of point cloud and functions of point cloud catalyst software
JVM class loading mechanism
How to check the frequency of memory and the number of memory slots in CPU-Z?
快速实现蓝牙iBeacn功能详解
Assembly language - Wang Shuang Chapter 3 notes and experiments
JVM tuning ideas
KubeSphere 集群配置 NFS 存储解决方案-收藏版
TiDB 数据库快速上手指南
[QT notes] simple understanding of QT meta object system
免费的 SSH 和 Telnet 客户端PuTTY
Us camera cloud service scheme: designed for lightweight video production scenes
Crawler learning 5--- anti crawling identification picture verification code (ddddocr and pyteseract measured effect)
Assembly language - Wang Shuang Chapter 8 two basic problems in data processing - Notes
Maxcompute SQL 的查询结果条数受限1W









