小熊派 Pico-H3863 开发板支持 BLE 1MHz/2MHz 频宽、BLE4.0/4.1/4.2/5.0/5.1/5.2 协议、BLE Mesh 和 BLE 网关功能,最大空口速率2Mbps.
**点击工具栏中的 **系统配置
选项,展开 Application
目录,勾选 Enable Sample
、Enable the Sample of products
、Support BLE UART sample
以及 Select ble uart type
,勾选 Enable BLE UART Server sample
;
**点击 **Save
.
**关键工程文件位于 **application
- samples
- products
- ble_uart
- ble_uart.c
static void *ble_uart_server_task(const char *arg)
{
unused(arg);
ble_uart_server_init();
errcode_t ret = uapi_uart_register_rx_callback(CONFIG_BLE_UART_BUS,
UART_RX_CONDITION_FULL_OR_SUFFICIENT_DATA_OR_IDLE,
1, ble_uart_read_int_handler);
if (ret != ERRCODE_SUCC) {
osal_printk("Register uart callback fail.");
return NULL;
}
while (1) {
msg_data_t msg_data = { 0 };
int msg_ret = osal_msg_queue_read_copy(mouse_msg_queue, &msg_data, &msg_rev_size, OSAL_WAIT_FOREVER);
if (msg_ret != OSAL_SUCCESS) {
osal_printk("msg queue read copy fail.");
if (msg_data.value != NULL) {
osal_vfree(msg_data.value);
}
continue;
}
if (msg_data.value != NULL) {
ble_uart_server_send_input_report(msg_data.value, msg_data.value_len);
osal_vfree(msg_data.value);
}
}
return NULL;
}
重编译
工程后 程序加载
至开发板并重置 RST
开发板即可。
**点击工具栏中的 **系统配置
选项,展开 Application
目录,勾选 Enable Sample
、Enable the Sample of products
、Support BLE UART sample
以及 Select ble uart type
,勾选 Enable BLE UART Client sample
;
**点击 **Save
.
**关键工程文件位于 **application
- samples
- products
- ble_uart
- ble_uart.c
static void *ble_uart_client_task(const char *arg)
{
unused(arg);
osal_printk("ble_uart_client_task entry.");
ble_uart_client_init();
errcode_t ret = uapi_uart_register_rx_callback(CONFIG_BLE_UART_BUS,
UART_RX_CONDITION_FULL_OR_SUFFICIENT_DATA_OR_IDLE,
1, ble_uart_read_int_handler);
if (ret != ERRCODE_SUCC) {
osal_printk("Register uart callback fail.");
return NULL;
}
while (1) {
msg_data_t msg_data = { 0 };
int msg_ret = osal_msg_queue_read_copy(mouse_msg_queue, &msg_data, &msg_rev_size, OSAL_WAIT_FOREVER);
if (msg_ret != OSAL_SUCCESS) {
osal_printk("msg queue read copy fail.");
if (msg_data.value != NULL) {
osal_vfree(msg_data.value);
}
continue;
}
if (msg_data.value != NULL) {
uint16_t write_handle = ble_uart_get_write_vlaue_handle();
ble_uart_client_write_cmd(msg_data.value, msg_data.value_len, write_handle);
osal_vfree(msg_data.value);
}
}
return NULL;
}
重编译
工程后 程序加载
至开发板并重置 RST
开发板即可。
更多回帖