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.

LP-EM-CC2340R5:Continuous data transmission by basic_ble_GATT_client

Part Number: LP-EM-CC2340R5

Tool/software:

Background

I am using two LP-EM-CC2340R5 evaluation boards for communication.

If I write 01 to Characteristic3, 01 is notified to Characteristic4.

Connect the Central device to the Terminal. Refer to the Write the Characteristic menu.By selecting Characteristic3, 01 is sent.

Therefore, if you do not select Characteristic3, 01 will not be sent.

Question

How can I send 01 continuously with Characteristic3?

Specifically, I want to send 01 with Characteristic3 every 50ms.

  • Hi,

    Thanks for reaching out. Because you are already using the basic_ble_GATT_client project sample, you can add a timer to send a message every 50ms in the app_menu.c file under the app folder: 

    As an example, you can add your sending a message function every 50ms in the app_menu.c. Start a timer instance where you have a callback function that be called when the timer expired, set the time to set in the timer (50ms), a flag that indicates if the timer is periodic or not. An example below, please note that this will not work if you just copy and paste, this is just an example of how it may look like and you would need to setup your timer and setup as requirement for your code.

    void sendMessage(timerHandle timerHandle, void *unused)
    {
        static int i = 0;
        bStatus_t status;
        req.pValue = GATT_bm_alloc(menuCurrentConnHandle, ATT_WRITE_REQ, 1, NULL);
        req.len = 1;
        req.pValue[0] = i;
        req.sig = 0;
        req.cmd = 1;
        req.handle = CHAR_3_HDL;
        i++;
    
        status = GATT_WriteNoRsp(menuCurrentConnHandle, &req);
        MenuModule_printf(APP_MENU_GENERAL_STATUS_LINE, 0, "Call Status: GATTWrite = "
                          MENU_MODULE_COLOR_BOLD MENU_MODULE_COLOR_RED "%d" MENU_MODULE_COLOR_RESET,
                          status);
        if (status != SUCCESS)
        {
            GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ);
        }
    
    }
    
    void Menu_doSend(uint8 index)
    {
        static bool timerStarted = false;
        static timerHandle timer;
        // Start pinging
        if (index == 0)
        {
            if (timerStarted)
            {
                MenuModule_printf(APP_MENU_GENERAL_STATUS_LINE, 0, "Call Status: ping already started");
    
            } else
            {
                timer = StartTimer(sendMessage, 50, true, NULL);
                timerStarted = true;
            }
        }
    }

    Regards,

    Ivan

  • Thank you for your reply.

    I was able to send data continuously by creating a timer.