This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2642R: RTOS: 我無法通過icall_fetchservicemsg()回傳值不會變更

Part Number: CC2642R
Other Parts Discussed in Thread: CC2640R2F

chipset: CC2640R2F

sdk: simplelink_cc13x2_26x2_sdk_2_40_00_81

IDE: IAR8.22.2

您好

我寫了2個藍芽notify function分別為Ble_Send_Task跟Ble_Send_Task_251用來傳送DATA,寫法基本一樣,差異只有藍芽傳送封包長度

現在遇到使用Ble_Send_Task 傳送數據後,disconnect再次連接devic是可以成功的,功能也正常

使用Ble_Send_Task_251後卻不能再次連線,後來發現是在SimplePeripheral_taskFxn 的for loop中ICall_fetchServiceMsg這個fxn回傳值不為ICALL_ERRNO_SUCCESS

導致後面GAP paring也沒辦法

使用Ble_Send_Task_251後ICall_fetchServiceMsg只會回傳ICALL_ERRNO_NOMSG

Please Suggest what could be going wrong. 

Regards

// Application main loop
  for (;;)
  {
    uint32_t events;

    // Waits for an event to be posted associated with the calling thread.
    // Note that an event associated with a thread is posted when a
    // message is queued to the message receive queue of the thread
    events = Event_pend(syncEvent, Event_Id_NONE, SP_ALL_EVENTS,
                        ICALL_TIMEOUT_FOREVER);
    
    if (events)
    {
      ICall_EntityID dest;
      ICall_ServiceEnum src;
      ICall_HciExtEvt *pMsg = NULL;
       
      // Fetch any available messages that might have been sent from the stack
      msgreturn = ICall_fetchServiceMsg(&src, &dest,
                                (void **)&pMsg);
      if (msgreturn == ICALL_ERRNO_SUCCESS) 
      {
        uint8_t safeToDealloc = TRUE;
        if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity))
        {
          ICall_Stack_Event *pEvt = (ICall_Stack_Event *)pMsg;

          // Check for BLE stack events first
          if (pEvt->signature != 0xffff)
          {
            // Process inter-task message
            safeToDealloc = SimplePeripheral_processStackMsg((ICall_Hdr *)pMsg);
          }
        }

void Ble_Send_Task_251(void)
{
  uint16_t len;
  bStatus_t status;
  attHandleValueNoti_t notify_back;
  notify_back.pValue=(uint8*)GATT_bm_alloc(gapConnHandle, ATT_HANDLE_VALUE_NOTI, GATT_MAX_MTU, &len);

  if(notify_back.pValue != NULL)
  {
    notify_back.len = 220;
    notify_back.handle = 0x0029;
    memcpy(notify_back.pValue, Master_Command251, 220);
    status = GATT_Notification(gapConnHandle, &notify_back, FALSE);
    if(status != SUCCESS)
    {
      GATT_bm_free( (gattMsg_t *)&notify_back, ATT_HANDLE_VALUE_NOTI );
    }
  }
  else
  {
    GATT_bm_free( (gattMsg_t *)&notify_back, ATT_HANDLE_VALUE_NOTI );
  }            
}

/*Ble_Send notify*/
void Ble_Send_Task(void)
{         
  uint16_t len;
  bStatus_t status;
  attHandleValueNoti_t notify_back;
  notify_back.pValue=(uint8*)GATT_bm_alloc(gapConnHandle, ATT_HANDLE_VALUE_NOTI, GATT_MAX_MTU, &len);
  
  if(notify_back.pValue != NULL)
  {
    notify_back.len = 20;
    notify_back.handle = 0x0029;
    memcpy(notify_back.pValue, Master_Command, 20);
    status = GATT_Notification(gapConnHandle, &notify_back, FALSE);
    test_status=status;
    if(status != SUCCESS)
    {
      GATT_bm_free( (gattMsg_t *)&notify_back, ATT_HANDLE_VALUE_NOTI );
    }
  }
  else
  {
    GATT_bm_free( (gattMsg_t *)&notify_back, ATT_HANDLE_VALUE_NOTI );
  }            
}

  • 您好,我们已收到您的问题并升级到英文论坛寻求帮助,如有答复将尽快回复您。谢谢!

  • 您好,您可以先参考下GitHub 上提供的 SimpleSerialSocketServer示例,此项目实现通知以流化数据。 此外您还可以参考吞吐量示例 (central peripheral),它使用大的通知来流式传输大量数据。 吞吐量示例还能够发送 251 B 大小的数据包,应该会对您的问题有所帮助。还请您验证下,因为发送 251 的有效载荷大小也涉及更改 MTU 大小。

    请问您使用的CC2640R2还是 CC2642,因为标题中写的是CC2640R2,但是内容和sdk都说的是CC2642,能请您确认下吗?

    在创建新任务时,您是否已经注册过该任务? 请参阅用户指南中的Creating Additional ICall Enabled Tasks

  • 您好
    使用的chipset為cc2642,上面打錯了

    創建任務皆為註冊過了

    我兩個notify FXN一個傳送量為20byte一個為220byte,扣掉ble 包含inf應該是足夠的才對

  • 好的收到。

    请问下您有没有验证过配置文件中定义的特性设置为处理 220 字节的有效负载?

    此外, gattservapp_util.c 中已存在此功能 (请参见 gattServApp_SendNotiInd ())。 您这边是否可以使用它?开箱即用示例支持通用有效载荷大小,而不是固定有效载荷大小。

    从您提供的示例代码来看:如果 GATT_BM_ALLO分配 返回 NULL,那么表示该操作分配内存时出现故障或错误。 如果是这种情况,那么不应该释放任何空间,因为无论如何都没有分配任何空间。 (也就是说外部 Else { } 语句应被删除)。