5 Replies Latest reply on Nov 20, 2018 2:21 AM by user_1516261

    Cy_BLE_GAPP_UpdateAdvScanData returns undocumented result CY_BLE_ERROR_INVALID_OPERATION

    user_1516261

      Sometimes when calling Cy_BLE_GAPP_UpdateAdvScanData, CY_BLE_ERROR_INVALID_OPERATION is returned. This return value is not documented in the API description, so the reason for this is unknown. Before calling UpdateAdvScanData() I check that Cy_BLE_GetAdvertisementState() == CY_BLE_ADV_STATE_ADVERTISING. The result is not consistent, but always happens eventually when running long enough. After this happens the first time, all subsequent calls to UpdateAdvScanData returns CY_BLE_ERROR_INVALID_OPERATION.

       

      I have tried to recover from this by calling Cy_BLE_GAPP_StopAdvertisement(), but when I do that CY_BLE_EVT_GAPP_ADVERTISEMENT_START_STOP is never received and the stack gets stuck in advertisement state CY_BLE_ADV_STATE_STOP_INITIATED. I have tried calling Cy_BLE_StackSoftReset() and Cy_BLE_StackShutdown(), but they do not seem to work, the specified event (CY_BLE_EVT_SOFT_RESET_COMPLETE/CY_BLE_EVT_STACK_SHUTDOWN_COMPLETE) are never received.

       

      The test case I'm running sets a bit in the advertisement every 5 seconds, when this bit is set, the central node will connect, exchange a couple of messages and then disconnect. After the disconnect the advertisement is restarted with the bit set to 0. The problem happen after 5-10 minutes running this test case.

        • 1. Re: Cy_BLE_GAPP_UpdateAdvScanData returns undocumented result CY_BLE_ERROR_INVALID_OPERATION
          ShipingW_81

          I'd like to check if you find issue on your custom board, or DVK board? Based on your description, this issue is only occurred occasionally after "running long enough". I guess it might not be a explicit issue.

          Anyway, please check firstly if the data to be updated is consistent with the settings in BLE customizer. For instance, the discovery mode.

          • 2. Re: Cy_BLE_GAPP_UpdateAdvScanData returns undocumented result CY_BLE_ERROR_INVALID_OPERATION
            user_1516261

            Hi,

             

            I'm using the cy_ble_configPtr set by the customizer and I am only changing advData and advDataLength. The code is like this:

             

            bool updateAdvertisement(cy_stc_ble_gapp_disc_data_t* advertisement)

            {

                if (advertisment->advDataLen <= CY_BLE_GAP_MAX_ADV_DATA_LEN)

                {

                    cy_en_ble_api_result_t res = CY_BLE_SUCCESS;

             

                    memcpy(cy_ble_configPtr->discoveryModeInfo[cy_ble_advIndex].advData->advData, advertisment->advData, advertisment->advDataLen);

                    cy_ble_configPtr->discoveryModeInfo[cy_ble_advIndex].advData->advDataLen = advertisment->advDataLen;

             

                    if (Cy_BLE_GetAdvertisementState() == CY_BLE_ADV_STATE_ADVERTISING)

                        res = Cy_BLE_GAPP_UpdateAdvScanData(&cy_ble_configPtr->discoveryModeInfo[cy_ble_advIndex]);

             

             

                    CY_ASSERT(res == CY_BLE_SUCCESS);

             

             

                    return res == CY_BLE_SUCCESS;

                }

                else

                {

                    return false;

                }

            }

            • 3. Re: Cy_BLE_GAPP_UpdateAdvScanData returns undocumented result CY_BLE_ERROR_INVALID_OPERATION
              ShipingW_81

              Did you test on your custom board, or DVK board? Possible to attach simple project for us to reproduce this issue?

              • 4. Re: Cy_BLE_GAPP_UpdateAdvScanData returns undocumented result CY_BLE_ERROR_INVALID_OPERATION
                user_1516261

                Hi, I had the issue on our custom boards. I'm currently working on creating a stripped down version to run on the development boards so I can see if can reproduce it on them

                • 5. Re: Cy_BLE_GAPP_UpdateAdvScanData returns undocumented result CY_BLE_ERROR_INVALID_OPERATION
                  user_1516261

                  I have not been able to reproduce the problem on the development boards, but I got some other issues instead on the board (the periphal device is in state CY_BLE_ADV_STATE_ADVERTISING, but advertisement is not heard either by the central node or when I use a BLE scanning app on my phone, another issue is that Discconnect sometimes fails with CY_BLE_ERROR_NO_DEVICE_ENTITY even though I provide it with the bdHandle I received upon connection) so maybe I would've gotten it if it weren't for those other issues

                   

                  However, I realized that I didn't have any checks that CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE was received before calling Cy_BLE_GAPP_UpdateAdvScanData() again. So I added that and noticed that CY_BLE_INVALID operation is received when calling Cy_BLE_GAPP_UpdateAdvScanData() in this situation.

                   

                  However, it seems that the reason my code was able to call UpdateAdvScanData twice was that CY_BLE_EVT_GAPP_UPDATE_ADV_SCAN_DATA_COMPLETE was never received. This time between the two calls was 4.8 seconds and no complete event had been received in this period, even though Cy_BLE_GAPP_UpdateAdvScanData() had returned CY_BLE_SUCCESS.