完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
Hi,
我现在正在学习ch573的透传代码(BLE_UART),准备将他们移植到CH579上使用,但是遇到了以下一些疑问,帮忙解答下。 1.UART_TO_BLE_SEND_EVT这个事件中是将手机发送给蓝牙的数据又通过蓝牙发送给手机了吗?因为我有看到ble_uart_WriteAttrCB中似乎是将接收到的数据处理后直接BLE_UART_EVT_BLE_DATA_RECIEVED事件。 uint16 Peripheral_ProcessEvent( uint8 task_id, uint16 events ) { ; ; ; //这个地方在处理什么? if(events & UART_TO_BLE_SEND_EVT) { static uint16_t read_length=0;; uint8_t result=0xff; switch(send_to_ble_state){ case SEND_TO_BLE_TO_SEND: //notify is not enabled,判断当前连接notify是否打开。 if(!ble_uart_notify_is_ready(peripheralConnList.connHandle)){ if(peripheralConnList.connHandle == GAP_CONNHANDLE_INIT){//如果当前连接丢失,则刷新(初始化)rx fifo //connection lost, flush rx fifo here app_drv_fifo_flush(&app_uart_rx_fifo); } break; } read_length = ATT_GetMTU(peripheralConnList.connHandle)-3;//获取MTU大小 //app_drv_fifo_length指RX结束帧减去帧头获取数据长度 if(app_drv_fifo_length(&app_uart_rx_fifo)>= read_length){ PRINT("FIFO_LEN:%drn",app_drv_fifo_length(&app_uart_rx_fifo)); //计算数据长度,再将app_uart_rx_fifo数据传递给to_test_buffer,并将状态转换为APP_DRV_FIFO_RESULT_SUCCESS。 result = app_drv_fifo_read(&app_uart_rx_fifo,to_test_buffer,&read_length); uart_to_ble_send_evt_cnt = 0; }else{ if(uart_to_ble_send_evt_cnt>10){//数据处理中止条件 result = app_drv_fifo_read(&app_uart_rx_fifo,to_test_buffer,&read_length); uart_to_ble_send_evt_cnt =0; }else{//再次启动UART_TO_BLE_SEND_EVT事件,此时状态为APP_DRV_FIFO_RESULT_SUCCESS。 tmos_start_task( Peripheral_TaskID, UART_TO_BLE_SEND_EVT,4); uart_to_ble_send_evt_cnt ++; PRINT("NO TIME OUTrn"); } } if(APP_DRV_FIFO_RESULT_SUCCESS == result){ noti.len = read_length; noti.pValue = GATT_bm_alloc( peripheralConnList.connHandle, ATT_HANDLE_VALUE_NOTI, noti.len, NULL, 0 ); if(noti.pValue != NULL){ tmos_memcpy( noti.pValue, to_test_buffer, noti.len );//将notify数据copy出来 result = ble_uart_notify( peripheralConnList.connHandle, ¬i,0 );//发起通知 //判断notif发送是否成功。 if( result != SUCCESS ) { PRINT("R1:%02xrn",result); send_to_ble_state = SEND_TO_BLE_SEND_FAILED; GATT_bm_free( (gattMsg_t *)¬i, ATT_HANDLE_VALUE_NOTI );//释放GATT消息 tmos_start_task( Peripheral_TaskID, UART_TO_BLE_SEND_EVT,2); }else{ send_to_ble_state = SEND_TO_BLE_TO_SEND; //app_fifo_write(&app_uart_tx_fifo,to_test_buffer,&read_length); //app_drv_fifo_write(&app_uart_tx_fifo,to_test_buffer,&read_length); read_length = 0; tmos_start_task( Peripheral_TaskID, UART_TO_BLE_SEND_EVT,2); } }else{ send_to_ble_state = SEND_TO_BLE_ALLOC_FAILED; tmos_start_task( Peripheral_TaskID, UART_TO_BLE_SEND_EVT,2); } }else{ //send_to_ble_state = SEND_TO_BLE_FIFO_EMPTY; } break; ; ; ; return 0; } static bStatus_t ble_uart_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint16 len, uint16 offset,uint8 method ) { ; ; ; // UUID if(pAttr->handle == ble_uart_ProfileAttrTbl[RAWPASS_RX_VALUE_HANDLE].handle) { if(ble_uart_ApPCBs) { ble_uart_evt_t evt; evt.type = BLE_UART_EVT_BLE_DATA_RECIEVED; evt.data.length = (uint16_t)len; evt.data.p_data = pValue; ble_uart_AppCBs(connHandle,&evt); } } ; ; ; return ( status ); } 2.能简要说明下在app_drv_fifo.h里这几个函数功能吗?确定下是否和我理解的功能意思是否一样,或者后期能加上注释最好了。 app_drv_fifo_result_t app_drv_fifo_write(app_drv_fifo_t *fifo, uint8_t *data, uint16_t *p_write_length); app_drv_fifo_result_t app_drv_fifo_write_from_same_addr(app_drv_fifo_t *fifo, uint8_t *data, uint16_t write_length); app_drv_fifo_result_t app_drv_fifo_read(app_drv_fifo_t *fifo, uint8_t *data, uint16_t *p_read_length); app_drv_fifo_result_t app_drv_fifo_read_to_same_addr(app_drv_fifo_t *fifo, uint8_t *data, uint16_t read_length); 3.你们的BLE上相关外设API有PDF文档吗?在哪里获取? |
|
相关推荐
1个回答
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
525 浏览 1 评论
CH579M+RT-Thread,RTC从Sleep模式唤醒失败是什么原因?
2904 浏览 2 评论
2400 浏览 1 评论
872浏览 2评论
691浏览 1评论
riscv-none-embed-objcopy: \'PWM_Output.elf\': No such file这个咋解决,
420浏览 1评论
534浏览 1评论
请教一下,Mounriver 编译不成功:找不到库文件,怎么整
816浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 02:42 , Processed in 1.121785 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号