? Directory
? One, the Core of Ble bluetooth function of
? Second, the complete code
? Three, use shineblink.com provide the free development of App, let your hardware can easily interact with the phone App ability
introduction
ShineBlink Core development board (hereinafter referred to as the Core) USES the Soc chip is the Nordic semiconductor company Nrf52840 chip, built-in 2.4 G wireless function (support Ble bluetooth, Thread Mesh networking and wireless protocol), so we can transform the Core by means of software into Ble turn bluetooth Uart passthrough module,
PS: the Core with only five, six lines of code can be realized Wifi/Ble/NB/Lora/ThreadMesh/RFID/Eth/Usb/RS485/RS232 communication, and more than 30 sensors/more than 10 kinds of hardware peripherals/more than 10 kinds of Mcu internal functions, and these functions can be up to five kinds of random combination running at the same time, learn more about the content of the Core can be on shineblink.com,
a, the Core of Ble bluetooth introduction
Ble bluetooth provides two features low power consumption of the Core, one is to Write features, one is to Notify features, among them:
- Write features: can be as a cell phone to send data to the Core of the channel, mobile phone via bluetooth connection to the Core of data is stored in the Write characteristics,
- Notify features: can be regarded as the Core to send data to the mobile channel, the Core data is sent to the mobile phone via bluetooth in Notify, but need to pay attention to, mobile phone to receive data from the Core, mobile terminal active must enable the Notify (demo will be mentioned below),
Below is a service provided by the Ble for the Core description, if you don't understand this also it doesn't matter, just speak according to the above understanding,
service (UUID: 0 x0001) description:
Service contains two characteristics (Characteristic) : a used to send data, one for receiving data
- Rx Characteristic (UUID: 0 x0002) is used to receive cell phone data
Mobile phone bluetooth may send data to the Rx Characteristic by way of ATT Write
- Tx Characteristic (UUID: 0 x0003) is used to send data to the mobile phone
If the phone bluetooth for Tx Characteristic can make the notification, the equipment can be used to send notification of way to send data to the mobile phone bluetooth
Please refer to here more about ble bluetooth
2, complete code
This example USES the Uart0 as turn interface, pin corresponding to the Core circuit boards Rx0, Tx0 pin,
- configuration Uart0 serial port baud rate is 115200 and began to work, the developer can also set the baud rate of the other,
LIB_Uart0Config (" BAUDRATE_115200 ")
Work - bluetooth in the default configuration low power parameters, device name for "MyBle666
"LIB_NrfBleDefaultConfig (" MyBle666 ")
- began circulationWhile (GC (1)==true)
Do
- query whether receive data from the mobile end bluetooth, if received by Uart0 forwarded
Ble_recv_flag, ble_recv_tab=LIB_NrfBleRecv ()
If ble_recv_flag==1 then - receive a pack of Ble data
LIB_Uart0Send (ble_recv_tab)
End
- Uart0 data query whether received, if received will forward through a Ble to mobile terminal
Uart0_recv_flag, uart0_recv_tab=LIB_Uart0Recv ()
If uart0_recv_flag==1 then - receive a pack of Uart data
LIB_NrfBleSend (uart0_recv_tab)
End
End
three, use shineblink.com provides the free development of App, let your hardware can easily interact with the phone App ability
Shineblink.com provides the free development of App Core docking way is very simple, can let you have a hardware device immediately own App, please see here for more details:
http://shineblink.com/#/technology
free development App download address:
https://b58ac2.link.yunpan.360.cn/lk/surl_yPpRxLMrUDt#/-0