關(guān)于CH573透?jìng)鞔a問(wèn)題。

Hi,

我現(xiàn)在正在學(xué)習(xí)ch573的透?jìng)鞔a(BLE_UART),準(zhǔn)備將他們移植到CH579上使用,但是遇到了以下一些疑問(wèn),幫忙解答下。

1.UART_TO_BLE_SEND_EVT這個(gè)事件中是將手機(jī)發(fā)送給藍(lán)牙的數(shù)據(jù)又通過(guò)藍(lán)牙發(fā)送給手機(jī)了嗎?因?yàn)槲矣锌吹絙le_uart_WriteAttrCB中似乎是將接收到的數(shù)據(jù)處理后直接BLE_UART_EVT_BLE_DATA_RECIEVED事件。

uint16?Peripheral_ProcessEvent(?uint8?task_id,?uint16?events?)
{
????;
????????;
????????????;
??//這個(gè)地方在處理什么?
??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,判斷當(dāng)前連接notify是否打開。
????????????if(!ble_uart_notify_is_ready(peripheralConnList.connHandle)){
????????????????if(peripheralConnList.connHandle?==?GAP_CONNHANDLE_INIT){//如果當(dāng)前連接丟失,則刷新(初始化)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結(jié)束幀減去幀頭獲取數(shù)據(jù)長(zhǎng)度
?????????????if(app_drv_fifo_length(&app_uart_rx_fifo)>=?read_length){
??????????????????PRINT("FIFO_LEN:%d\r\n",app_drv_fifo_length(&app_uart_rx_fifo));

??????????????????//計(jì)算數(shù)據(jù)長(zhǎng)度,再將app_uart_rx_fifo數(shù)據(jù)傳遞給to_test_buffer,并將狀態(tài)轉(zhuǎn)換為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){//數(shù)據(jù)處理中止條件
??????????????????????result?=?app_drv_fifo_read(&app_uart_rx_fifo,to_test_buffer,&read_length);
??????????????????????uart_to_ble_send_evt_cnt?=0;
??????????????????}else{//再次啟動(dòng)UART_TO_BLE_SEND_EVT事件,此時(shí)狀態(tài)為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?OUT\r\n");
??????????????????}
???????????????}

????????????????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數(shù)據(jù)copy出來(lái)
????????????????????????result?=?ble_uart_notify(?peripheralConnList.connHandle,?&noti,0?);//發(fā)起通知

????????????????????????//判斷notif發(fā)送是否成功。
????????????????????????if(?result?!=?SUCCESS?)
????????????????????????{
????????????????????????????PRINT("R1:%02x\r\n",result);
????????????????????????????send_to_ble_state?=?SEND_TO_BLE_SEND_FAILED;
????????????????????????????GATT_bm_free(?(gattMsg_t?*)&noti,?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.能簡(jiǎn)要說(shuō)明下在app_drv_fifo.h里這幾個(gè)函數(shù)功能嗎?確定下是否和我理解的功能意思是否一樣,或者后期能加上注釋最好了。

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上相關(guān)外設(shè)API有PDF文檔嗎?在哪里獲取?


  1. BLE_UART的例程中的確是這樣的,將手機(jī)發(fā)送的信息又通過(guò)notify發(fā)給手機(jī),不需要可以屏蔽掉,

  2. 這幾個(gè)函數(shù)就是關(guān)于fifo的讀寫功能,same_addr函數(shù)操作的是硬件fifo,

  3. 關(guān)于相關(guān)api的文檔可參考ch573ble目錄里的pdf文件及程序中的注釋。



只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频