Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Smart Bluetooth Forum Discussions

Anonymous
Not applicable

Hello everybody,

I'm still creating a BLE application on the BCM20736S that is more or less an enhanced UART-bridge from a Cortex-M4 to BLE. The SDK version is 2.2.1.

Receiving data via BLE and sending it on PUART to the Cortex is working flawlessly, the other way round, it is hampered by not sending a notification.

This function fails:

__find_bonded_peer

It is called inside these generated functions:

BOOL store_in_db_*(UINT8* p_value, UINT8 value_len, BOOL write, BOOL notify)

But the iPhone is connected to the BLE module and the connection up callback is executed. A maximum of five peers is allowed.

I'm afraid, that there might be a basic misunderstanding on my side, regarding peers and bonding.

Do I have to actively add a peer on connection up? How to do this?

The use case is, that multiple devices are connected to the BLE module, be it mobile phones or future BLE accessories. But at the moment I'd be glad, if only one device would work...

On the iPhone a cross-platform software built around the Xamarin/MonkeyRobotics toolkit is running.

Using my custom function

static void notificationWithDB(UINT16 handle, unsigned char *data, unsigned char length)

{

    static const unsigned char zeroPad[22] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

    unsigned int i;

    BLEPROFILE_DB_PDU tempPDU;

    if(length > 0)

    {

        i = bleprofile_ReadHandle(handle, &tempPDU);

        if (tempPDU.len > length) //zero padding here

        {

            memcpy(tempPDU.pdu, zeroPad, tempPDU.len);

            memcpy(tempPDU.pdu, data, length);

        } else if (tempPDU.len == length)

        {

            memcpy(tempPDU.pdu, data, length);

        } else //truncate the data

        {

            memcpy(tempPDU.pdu, data, tempPDU.len);

        }

        bleprofile_WriteHandle(handle, &tempPDU);

        if (blecm_getAvailableTxBuffers() > 0)

        {

            bleprofile_sendNotification(handle, data, (INT32) length);

        }

    }

}

a notification is send.

Some of these do not contain any attribute data and crash the iPhone.

Do you spot a bug?

Thanks for your help!

Best regards

Hannes Baumgart

0 Likes
1 Solution
VictorZ_46
Employee
Employee
5 comments on blog 25 sign-ins 250 likes received

I assume your characteristic value is less or equal 20 octets in length.  Hopefully following should work better.

static void notificationWithDB(UINT16 handle, unsigned char *data, unsigned char length) 

    BLEPROFILE_DB_PDU tempPDU;

    if (length > 0) 

    { 

        memset(tempPDU.pdu, 0, sizeof(tempPDU.pdu)); 

        bleprofile_ReadHandle(handle, &tempPDU);

       

        if (length > tempPDU.len)

        {

            length = tempPDU.len;

        }

        memcpy(tempPDU.pdu, data, length); 

       

        bleprofile_WriteHandle(handle, &tempPDU); 

        if (blecm_getAvailableTxBuffers() > 0) 

        { 

            bleprofile_sendNotification(handle, tempPDU.pdu, (INT32) tempPDU.len); 

        } 

    } 

View solution in original post

0 Likes
1 Reply
VictorZ_46
Employee
Employee
5 comments on blog 25 sign-ins 250 likes received

I assume your characteristic value is less or equal 20 octets in length.  Hopefully following should work better.

static void notificationWithDB(UINT16 handle, unsigned char *data, unsigned char length) 

    BLEPROFILE_DB_PDU tempPDU;

    if (length > 0) 

    { 

        memset(tempPDU.pdu, 0, sizeof(tempPDU.pdu)); 

        bleprofile_ReadHandle(handle, &tempPDU);

       

        if (length > tempPDU.len)

        {

            length = tempPDU.len;

        }

        memcpy(tempPDU.pdu, data, length); 

       

        bleprofile_WriteHandle(handle, &tempPDU); 

        if (blecm_getAvailableTxBuffers() > 0) 

        { 

            bleprofile_sendNotification(handle, tempPDU.pdu, (INT32) tempPDU.len); 

        } 

    } 

0 Likes