添加厂商数据,以及修改透传UUID

This commit is contained in:
OPTOC
2025-09-17 15:16:18 +08:00
parent 32c932219f
commit 9f364c9b0d
3 changed files with 21 additions and 5 deletions

View File

@@ -70,10 +70,10 @@ static struct
// #define ESP_GATT_UUID_SPP_COMMAND_NOTIFY 0xABF4 // 命令响应的返回。 // #define ESP_GATT_UUID_SPP_COMMAND_NOTIFY 0xABF4 // 命令响应的返回。
/// SPP Service /// SPP Service
static const uint8_t spp_service_uuid[16] = {0x6E,0x40,0x00,0x01,0xB5,0xA3,0xF3,0x93,0xE0,0xA9,0xE5,0x0E,0x24,0xDC,0xCA,0x9E}; static const uint8_t spp_service_uuid[16] = {0x9E,0xCA,0xDC,0x24,0x0E,0xE5,0xA9,0xE0,0x93,0xF3,0xA3,0xB5,0x01,0x00,0x40,0x6E};
/// Characteristic UUID /// Characteristic UUID
#define ESP_GATT_UUID_SPP_DATA_RECEIVE {0x6E,0x40,0x00,0x03,0xB5,0xA3,0xF3,0x93,0xE0,0xA9,0xE5,0x0E,0x24,0xDC,0xCA,0x9E} // 透传数据接收 #define ESP_GATT_UUID_SPP_DATA_RECEIVE {0x9E,0xCA,0xDC,0x24,0x0E,0xE5,0xA9,0xE0,0x93,0xF3,0xA3,0xB5,0x03,0x00,0x40,0x6E} // 透传数据接收
#define ESP_GATT_UUID_SPP_DATA_NOTIFY {0x6E,0x40,0x00,0x02,0xB5,0xA3,0xF3,0x93,0xE0,0xA9,0xE5,0x0E,0x24,0xDC,0xCA,0x9E} // 透传数据发送 #define ESP_GATT_UUID_SPP_DATA_NOTIFY {0x9E,0xCA,0xDC,0x24,0x0E,0xE5,0xA9,0xE0,0x93,0xF3,0xA3,0xB5,0x02,0x00,0x40,0x6E} // 透传数据发送
/* 第二个 Service 使用 16-bit UUID示例: 0xBEEFchar 使用 0xBEE1 */ /* 第二个 Service 使用 16-bit UUID示例: 0xBEEFchar 使用 0xBEE1 */
static const int16_t cmd_uuid = 0xABF0; static const int16_t cmd_uuid = 0xABF0;
@@ -765,9 +765,11 @@ static void _ble_spp_server_init(void)
memcpy(s_mac, esp_bt_dev_get_address(), sizeof(s_mac)); memcpy(s_mac, esp_bt_dev_get_address(), sizeof(s_mac));
if (s_init_param.manufacturer_data) if (s_init_param.manufacturer_data != NULL)
{ {
s_init_param.manufacturer_data(s_manufacturer_data); s_init_param.manufacturer_data(s_manufacturer_data);
printf("set manufacturer data %d %d\n",s_manufacturer_data[0],s_manufacturer_data[1]);
} }
else else
{ {

View File

@@ -91,11 +91,21 @@ static void ble_server_connect_handler(ble_server_status_t status)
SYS_LOG_INF("ble stop"); SYS_LOG_INF("ble stop");
} }
} }
static void _sb_manufacturer_encode(uint8_t manufacturer_data[20])
{
memset(manufacturer_data, 0, 20);
manufacturer_data[0] = 'K';
manufacturer_data[1] = 'Y';
manufacturer_data[2] = PRODUCT0;
manufacturer_data[3] = PRODUCT1;
manufacturer_data[4] = VERSIONS;
}
uint8_t ble_init(init_device_t *port) uint8_t ble_init(init_device_t *port)
{ {
ble_server_init_t ble_init_param = { ble_server_init_t ble_init_param = {
.device_name = "Sertorf", // 设备名 .device_name = "Sertorf", // 设备名
.manufacturer_data = NULL, // 回调函数,生成 manufacturer[20] .manufacturer_data = _sb_manufacturer_encode, // 回调函数,生成 manufacturer[20] 设置厂商数据
.connect_cb = ble_server_connect_handler, // 回调函数, NULL 值可用 .connect_cb = ble_server_connect_handler, // 回调函数, NULL 值可用
}; };
//初始化参数 //初始化参数

View File

@@ -9,6 +9,10 @@
#include "../data_port/socket_inet/socket_inet.h" #include "../data_port/socket_inet/socket_inet.h"
#include "sys_log.h" #include "sys_log.h"
#define PRODUCT0 0x24
#define PRODUCT1 0x78
#define VERSIONS 0X01
#define UART_ENABLE 1 #define UART_ENABLE 1
#define BLE_ENABLE 1 #define BLE_ENABLE 1
#define WIFI_ENABLE 1 #define WIFI_ENABLE 1