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.

[参考译文] CC1350:在发送后等待接收器确认

Guru**** 1829670 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1112872/cc1350-waiting-for-an-acknowledgment-from-receiver-after-transmit

器件型号:CC1350

您好专家、

我想修改 WORtx 并在 RX 示例上唤醒,例如 TX 发送信号并等待 acksignal 时。 Rx 端接收并发送 ACK。首先、我尝试创建2个任务、一个用于 Rx、另一个用于 TX、但当我按下按钮时、无线电 TX 端的唤醒没有响应 (我尝试使用2个信标实现、BIOS 等待永远)。然后我在无线电 TX 端的两个唤醒中尝试了以下修改:
静态空 txTaskFunction (UArg0、UArgarg1)

/*发送数据包*/
rf_runCmd (rfHandle、(rf_Op*)&rf_cmdPropTxAdv、rf_PriorityNormal、NULL、0);
/*添加了等待 RX 信号的部件*/
IF (Flag1==10)

Semaphore_pend (rxSemaphoreHandle、BIOS_WAIT_FOREVE);
Flag1=0;

Semaphore_construction (&rxSemaphore、0、NULL);
rxSemaphoreHandle = semaphore_handle (&rxSemaphore);

期待您的回复。

此致、

Vivian

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    继续开机自检

    以下是在无线电 TX 端的唤醒上完成的修改:

    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
        /* If we've received a new packet and it's available to read out */
        if (e & RF_EventRxEntryDone)
        {
            do
            {
    
    
                /* Get current unhandled data entry */
                currentDataEntry = RFQueue_getDataEntry();
    
                /* Handle the packet data, located at &currentDataEntry->data:
                 * - Length is the first byte with the current configuration
                 * - Data starts from the second byte */
                packetLength      = *(uint8_t*)(&currentDataEntry->data);
                packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);
    
                /* This code block is added to avoid a compiler warning.
                * Normally, an application will reference these variables for
                * useful data. */
    
                dummy = packetLength + packetDataPointer[0];
    
                Semaphore_post(rxSemaphoreHandle);
            } while(RFQueue_nextEntry() == DATA_ENTRY_FINISHED);
        }
    }
    void txTaskInit()
    {
        /* Initialize TX semaphore */
        Semaphore_construct(&txSemaphore, 0, NULL);
        txSemaphoreHandle = Semaphore_handle(&txSemaphore);
    
        /* Initialize and create TX task */
        Task_Params_init(&txTaskParams);
        txTaskParams.stackSize = TX_TASK_STACK_SIZE;
        txTaskParams.priority = TX_TASK_PRIORITY;
        txTaskParams.stack = &txTaskStack;
        Task_construct(&txTask, txTaskFunction, &txTaskParams, NULL);
    }
    
    /* TX task function. Executed in Task context by TI-RTOS when the scheduler starts. */
    static void txTaskFunction(UArg arg0, UArg arg1)
    {
        /* Initialize the display and try to open both UART and LCD types of display. */
        Display_Params params;
        Display_Params_init(&params);
        params.lineClearMode = DISPLAY_CLEAR_BOTH;
        Display_Handle uartDisplayHandle = Display_open(Display_Type_UART, &params);
        Display_Handle lcdDisplayHandle = Display_open(Display_Type_LCD, &params);
    
        /* Print initial display content on both UART and any LCD present */
        Display_printf(uartDisplayHandle, 0, 0, "Wake-on-Radio TX");
        Display_printf(uartDisplayHandle, 0, 0, "Pkts sent: %u", seqNumber);
        Display_printf(lcdDisplayHandle, 0, 0, "Wake-on-Radio TX");
        Display_printf(lcdDisplayHandle, 1, 0, "Pkts sent: %u", seqNumber);
    
        /* Setup callback for button pins */
        PIN_Status status = PIN_registerIntCb(buttonPinHandle, &buttonCallbackFunction);
        Assert_isTrue((status == PIN_SUCCESS), NULL);
    
        /* Initialize the radio */
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        /* Initialize TX_ADV command from TX command */
        initializeTxAdvCmdFromTxCmd(&RF_cmdPropTxAdv, &RF_cmdPropTx);
    
        /* Set application specific fields */
        RF_cmdPropTxAdv.pktLen = PAYLOAD_LENGTH +1; /* +1 for length byte */
        RF_cmdPropTxAdv.pPkt = packet;
        RF_cmdPropTxAdv.preTrigger.triggerType = TRIG_REL_START;
        RF_cmdPropTxAdv.preTime = WOR_PREAMBLE_TIME_RAT_TICKS(WOR_WAKEUPS_PER_SECOND);
    
        /* Request access to the radio */
    #if defined(DeviceFamily_CC26X0R2)
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
    #else
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    #endif// DeviceFamily_CC26X0R2
    
        /* Set the frequency */
        RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    
        /* Enter main TX loop */
        while(1)
        {
            /* Wait for a button press */
            Semaphore_pend(txSemaphoreHandle, BIOS_WAIT_FOREVER);
    
            /* Create packet with incrementing sequence number and random payload */
            packet[0] = PAYLOAD_LENGTH;
            packet[1] = (uint8_t)(seqNumber >> 8);
            packet[2] = (uint8_t)(seqNumber++);
            packet[3]=flag;
            uint8_t i;
            for (i = 4; i < PAYLOAD_LENGTH +1; i++)
            {
                packet[i] = rand();
            }
    
            /* Send packet */
            RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);
            if (flag1==10)
            {
                Semaphore_pend(rxSemaphoreHandle, BIOS_WAIT_FOREVER);
                flag1=0;
            }
            Semaphore_construct(&rxSemaphore, 0, NULL);
               rxSemaphoreHandle = Semaphore_handle(&rxSemaphore);
               RF_Params rfParams;
               RF_Params_init(&rfParams);
    
               if( RFQueue_defineQueue(&dataQueue,
                                       rxDataEntryBuffer,
                                       sizeof(rxDataEntryBuffer),
                                       NUM_DATA_ENTRIES,
                                       MAX_LENGTH + NUM_APPENDED_BYTES))
               {
                   /* Failed to allocate space for all data entries */
                   while(1);
               }
    
               /* Modify CMD_PROP_RX command for application needs */
               /* Set the Data Entity queue for received data */
               RF_cmdPropRx.pQueue = &dataQueue;
               /* Discard ignored packets from Rx queue */
               RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1;
               /* Discard packets with CRC error from Rx queue */
               RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1;
               /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
               RF_cmdPropRx.maxPktLen = MAX_LENGTH;
               RF_cmdPropRx.pktConf.bRepeatOk = 1;
               RF_cmdPropRx.pktConf.bRepeatNok = 1;
    
               rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    
               /* Set the frequency */
               RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    
               /* Enter RX mode and stay forever in RX */
               RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRx,
                                                          RF_PriorityNormal, &callback,
                                                          RF_EventRxEntryDone);
             break;
            /* Update display */
            Display_printf(uartDisplayHandle, 0, 0, "Pkts sent: %u", seqNumber);
            Display_printf(lcdDisplayHandle, 1, 0, "Pkts sent: %u", seqNumber);
    
            /* Toggle LED */
            PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !PIN_getOutputValue(Board_PIN_LED1));
        }
    
    }

    以下是对讲机 Rx 侧唤醒时所做的修改:

                RF_cmdPropTxAdv.pktLen = PAYLOAD_LENGTH +1; /* +1 for length byte */
                RF_cmdPropTxAdv.pPkt = packet;
                RF_cmdPropTxAdv.preTrigger.triggerType = TRIG_NOW;
    
                /* Create packet with incrementing sequence number and random payload */
                packet[0] = PAYLOAD_LENGTH;
                packet[1] = (uint8_t)(seqNumber >> 8);
                packet[2] = (uint8_t)(seqNumber++);
                packet[3]=1;//success
                uint8_t i;
                for (i = 4; i < PAYLOAD_LENGTH +1; i++)
                {
                    packet[i] = rand();
                }
    
                /* Send packet */
                RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);

    当我按下按钮时,数据包被发送和接收,然后 ACK 被发送(断点到达代码)

    此类实现是否有任何实现示例?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Vivian:

    遗憾的是、我们没有任何您尝试实现的精确用例的实现示例。 我建议尝试使用 SmartRF Studio 验证 RX 器件是否正确发送了 ACK 数据包。

    此致、

    高斯图