蓝牙芯片代码可以参考Project\BLE_Examples\BLE_Beacon例程
需要做些修改
1、添加宏定义
- #define H16(x) (((int) (x)) >> 8)
- #define L16(x) (((int) (x)))
-
- #define H32(x) (((int) (x)) >> 24)
- #define MH32(x) (((int) (x)) >> 16)
- #define L32(x) (((int) (x)) >> 8)
- #define XL32(x) (((int) (x)))
2、添加变量
- float vlotage = 3.3;//V
- uint32_t time = 2500;//ms
- float pressure = 101.5;//hPa
- float temperature = 26.2;//degC
- float angleX = 10.2;//deg
- float angleY = 0.3;//deg
3、添加更新广播函数
-
- static void Update_Beaconing(void)
- {
- /* Set AD Type Flags at beginning on Advertising packet */
- uint8_t adv_data[] = {
- /* Advertising data: Flags AD Type */
- 0x02,
- 0x01,
- 0x06,
- 31,
- 0x11,
- 0x22,
- 0x33,
- 0x44,
- 0x55,
- 0x66,
- 0x77,
- 0x88,
- 0x99,
- H16(vlotage * 10),
- L16(vlotage * 10),
- H32(time),
- MH32(time),
- L32(time),
- XL32(time),
- H16(pressure * 10),
- L16(pressure * 10),
- H16(temperature * 10),
- L16(temperature * 10),
- H16(angleX * 10),
- L16(angleX * 10),
- H16(angleY * 10),
- L16(angleY * 10),
- };
- /* Update the ADV data with the BEACON manufacturing data */
- hci_le_set_advertising_data (sizeof(adv_data), adv_data);
- }
4、更新广播时先修改对应的变量后执行Update_Beaconing函数
5、安装上位机测试软件(限android),源码下载地址:
https://github.com/int8cn/jsble
6、在手机存储器下建立int8文件夹,将rar中的文件复制到int8文件夹中
本帖最后由 littleshrimp 于 2018-1-23 10:25 编辑