cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4

EyGe_3183606
New Contributor II

Hello,

We print constantly the Gatt error code to UART for debugging purposes.

Recently we encountered a case where the value was 2000171b (it was printed multiple times among other properly printed strings).

Given that the Gatt error code is of type CYBLE_GATT_ERR_CODE_T which has a maximum value of 0xFF, we were wondering how this could be and what does it mean?

Thanks,
David

0 Likes
5 Replies
Yugandhar
Moderator
Moderator

Hello David,

Can you please share your project ?

Thanks,

P Yugandhar.

0 Likes
EyGe_3183606
New Contributor II

Hi,

Sorry for my late reply.

Unfortunately, I cannot share my project due to company policy.

But I can share with you the functions that are related to this incident (I used three dots "..." to indicate code sections that are not relevant:

// Call back event function to handle various events from BLE stack

void BLE_ProcessEvents(uint32 event, void * eventParam)

{

     ...

     CYBLE_GATT_ERR_CODE_T gattErr;

     ...

     if(CYBLE_DEVICE_SERVICE_DEVICE_STATUS_CHAR_HANDLE == wrReqParam->handleValPair.attrHandle)

     {

                      iprintf("BLE Write: DEVICE_STATUS\n\r");

                      ...

                      gattErr = CyBle_GattsWriteAttributeValue(&wrReqParam->handleValPair, ZERO, &cyBle_connHandle,                     CYBLE_GATT_DB_PEER_INITIATED);

     }

     ...

     if(gattErr != CYBLE_GATT_ERR_NONE)

     {

          iprintf("Gatt Error code : %x \n\r", gattErr);    // Added for debugging

     }

}

void iprintf(char8 *pszFmt,...)

{

    uint8 *pszVal;

    uint32 iVal, xVal, i = 0, buffer[12], index = 1;

    uint8 cVal;

    uint32 *pArg;

    pArg =(uint32 *)&pszFmt;

    while(*pszFmt)

    {

        if('%' != *pszFmt)

        {

            iputc(*pszFmt);

            pszFmt++;

            continue;

        }

        pszFmt++;

        if(*pszFmt == 's')

        {

            pszVal = (uint8*)pArg[index++];

            for(; *pszVal != '\0'; pszVal++)

                iputc(*pszVal);

            pszFmt++;

            continue;

        }

        if(*pszFmt == 'd')

        {

            iVal = pArg[index++];

            i = 0;

            do{

                buffer[i++] = iVal % 10;

                iVal /= 10;

            }while(iVal);

            while(i > 0)

            {

                i--;

                iputc(*change(buffer));

            }

            pszFmt++;

            continue;

        }

        if(*pszFmt == 'c')

        {

            cVal = (uint8)pArg[index++];

            iputc(cVal);

            pszFmt++;

            continue;

        }

        if(*pszFmt == 'x')

        {

            xVal = pArg[index++];

            i = 0;

            do{

                buffer[i++] = xVal % 16;

                xVal /= 16;

            }while(xVal);

            if(i%2!=0)

                buffer[i++]=0;

            if(i<2)

                buffer[i++]=0;

            while(i > 0)

            {

                i--;

                iputc(*change(buffer));

            }

            pszFmt++;

            continue;

        }

        if(pszFmt == '\0')

        {

            break;

        }

    }

}

0 Likes
VenkataD_41
Moderator
Moderator

Hi,

This looks strange. Please typecast the enum variable in the print statement and check once.

iprintf("Gatt Error code : %x \n\r", (int)gattErr);

Thanks

Ganesh

0 Likes
EyGe_3183606
New Contributor II

It would seem that to typecast this would not be relevant since in any case the value provided by PSOC is not greater than 0xFF.

Wouldn't you agree?

0 Likes
VenkataD_41
Moderator
Moderator

Hi

You are correct. The value of this enum variable could not be more than 255. But I am not able to reproduce the issue at my side.

Please try adding this piece of code in your project and check once. Please do not forget to include <stdio.h> in your main.c .

int _write(int file, char *ptr, int len)

{

    int i;

    file = file;

    for (i = 0; i < len; i++)

    {

      UART_UartPutChar(*ptr++);

    }

    return len;

}

If you are still getting the issue after the above changes, please try to send a demo project that reproduces the behavior for us to test at our side.

Thanks

Ganesh

0 Likes