重点要关注GAP, GATT。
主要针对什么是Characteristics
以下信息都可以由MASTER CONTROL PANEL googleplay读出来
GAP和GATT的差别
GAP: 通用访问协议(Generic Attribute Profile).
官方说明
用于广播(advertising)的协议.
包含信息:
- RSSI
- Address
- Address Type (short or long)
- Advertising Data:
- ShortenedLocalName
- Flags (discoverable? can connent?)
- UUID
- ManufacturerSpecificData
没有公司信息数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| static void advertising_init(void) { uint32_t err_code; ble_advdata_t advdata; memset(&advdata, 0, sizeof(advdata)); advdata.name_type = BLE_ADVDATA_FULL_NAME; advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; ble_adv_modes_config_t options = {0}; options.ble_adv_fast_enabled = BLE_ADV_FAST_ENABLED; options.ble_adv_fast_interval = APP_ADV_INTERVAL; options.ble_adv_fast_timeout = APP_ADV_TIMEOUT_IN_SECONDS; err_code = ble_advertising_init(&advdata, NULL, &options, on_adv_evt, NULL); APP_ERROR_CHECK(err_code); }
|
有公司信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| static void advertising_init(void) { uint32_t err_code; ble_advdata_t advdata; ble_advdata_manuf_data_t manuf_data; uint8_t data[] = "SomeData!"; manuf_data.company_identifier = 0x0059; manuf_data.data.p_data = data; manuf_data.data.size = sizeof(data); memset(&advdata, 0, sizeof(advdata)); advdata.name_type = BLE_ADVDATA_SHORT_NAME; advdata.short_name_len = 6; advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; advdata.p_manuf_specific_data = &manuf_data; ble_adv_modes_config_t options = {0}; options.ble_adv_fast_enabled = BLE_ADV_FAST_ENABLED; options.ble_adv_fast_interval = APP_ADV_INTERVAL; options.ble_adv_fast_timeout = APP_ADV_TIMEOUT_IN_SECONDS; err_code = ble_advertising_init(&advdata, NULL, &options, on_adv_evt, NULL); APP_ERROR_CHECK(err_code); }
|
其中:广播接入地址:固定为0x8E89BED6
GATT: 通用属性协议(Generic Attribute Profile)
官方说明
通讯协议, 负责连接之后数据传送.
通用属性配置文件(GATT)在属性协议(ATT)的基础上构建,为属性协议传输和存储数据建立了一些通用操作和框架。
包括: UART/HRS/HID 等.
ATT 包含信息:
- Attribute Handles
- Attribute Types (UUIDs)
- Attribute Permissions
- Attribute Values
GATT 信息:
- Service Declaration attribute
- Characteristic Declaration
- Characteristic Value Declaration
- Descriptor Declaration
BLE UART S132
这篇文章说的很清楚
调试碰到的问题
2017.04.27
- SDK 8 的版本函数和10的版本函数不一样.
- 要考虑自己的板子晶振问题, 和启动有关 ble_static_init
2017.04.28
- 自己的板子UART 要注意流控 APP_UART_FLOW_CONTROL_DISABLED
2017.04.30
- 如果用STATIC, 在KEIL里,不同的C文件调用, 会生成不同的实例. 所以必须用extern 的方式.
2017.05.05