cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Smart Bluetooth

Anonymous
Not applicable

Using the smart designer I've created a project that has a service with a notification only characteristic. The code generated as a result of this looks as follows:

// It should be called when 'myNotificationOnlyCharacteristic' is changed.

BOOL store_in_db_myNotificationOnlyCharacteristic(UINT8* p_value, UINT8 value_len)

{

    BLEPROFILE_DB_PDU db_pdu;

    if (__find_bonded_peer(myDevice_addr))

    {

        // Exit if notify and indicate are not configured in the Client Configuration Descriptor

        if (0 == (p_bonded->myNotificationOnlyCharacteristic_client_configuration & (CCC_NOTIFICATION)))

        {

            ble_trace1("don't notify handle:%02x", HDLC_MY_NOTIFICIATION_ONLY_VALUE);

            return TRUE;

        }

        // Just return FALSE if connection is down

        if (myDevice_connection_handle == 0)

        {

            ble_trace1("not connected handle:%02x", HDLC_MY_NOTIFICIATION_ONLY_VALUE);

            return FALSE;

        }

        // Just return FALSE if we are waiting for confirmation

        if (myDevice_indication_sent != 0)

        {

            ble_trace1("wait confirmation handle:%02x", HDLC_MY_NOTIFICIATION_ONLY_VALUE);

            return FALSE;

        }

        // Read the value of the characteristic

        bleprofile_ReadHandle(HDLC_MY_NOTIFICIATION_ONLY_VALUE, &db_pdu);

       // Notify property is true. If client has registered for notification

        if (p_bonded->myNotificationOnlyCharacteristic_client_configuration & CCC_NOTIFICATION)

        {

            ble_trace2("notify len:%d handle:%02x", db_pdu.len, HDLC_MY_NOTIFICIATION_ONLY_VALUE);

            bleprofile_sendNotification(HDLC_MY_NOTIFICIATION_ONLY_VALUE, (UINT8 *)db_pdu.pdu, db_pdu.len);

        }

    }

    return TRUE;

}

When that code is running & this function is called when new data is available is doesn't look like the new data gets written to (HDLC_MY_NOTIFICIATION_ONLY_VALUE, &db_pdu). In fact neither of the input parameters seem to be used anywhere?

I edited the code to include:

        // Read the value of the characteristic

        bleprofile_ReadHandle(HDLC_MY_NOTIFICIATION_ONLY_VALUE, &db_pdu);

        memcpy(&db_pdu.pdu[0], p_value, value_len);

        db_pdu.len = value_len;

// Notify property is true. If client has registered for notification

        if (p_bonded->myNotificationOnlyCharacteristic_client_configuration & CCC_NOTIFICATION)

        {

            ble_trace2("notify len:%d handle:%02x", db_pdu.len, HDLC_MY_NOTIFICIATION_ONLY_VALUE);

            bleprofile_sendNotification(HDLC_MY_NOTIFICIATION_ONLY_VALUE, (UINT8 *)db_pdu.pdu, db_pdu.len);

        }

& in doing that the new data does appear in notification form the other side of a bluetooth connection. Is this the way Notifications are meant to be used in the SDK?

On another issue, whenever the Apps I'm using to test the device try to enable nofitications it can be unreliable as to whether or not notifications arrive at the App. Read & Writes to other characteristics seem ok proving that the btle connection is sound, it's only the notifications that seem to be difficult. Has anyone else experienced this?

0 Likes
Reply
1 Solution
Anonymous
Not applicable

Hello Paul,

Glad to hear that you are making progress.

  1. Yes, you should avoid the "store_in_db_location_and_navigation_navigation" & functions when using the Smart Designer.
  2. The Smart Designer was designed more as a template or guide for the TODO tasks that are needed once you declare your profiles.  It covers basic things to do after your Characteristics, Properties and Permissions.
  3. For instance if you view the Characteristics of the LN Control Point:pastedImage_2.png
  4. The Properties Tab indicate which ones are mandatory and cannot be changed as shown above
  5. In the code .wic view below, wed see that Write and Indication are declared:pastedImage_3.png
  6. Finally, the Smart Designer gives you a ToDo list to complete the code:pastedImage_4.png

In Summary, the Smart Designer was developed as a guideline.

Hope this helps.

JT

View solution in original post

0 Likes
Reply
7 Replies
Anonymous
Not applicable

Hello Paul,

Try using the hello_sensor app in the SDK WITHOUT the Smart Designer as it is our main example for demonstrating Notifications, but you have probably seen this one.

Did you ensure notifications in Smart Designer?  As a sanity check, just look at the app, thanks.

App Reads/Writes:

We have not heard this scenario since you are able to see the Read/Write's happening and NOT the Notifications.

Again, check the hello_sensor.c for our Notification methodology.

Thanks

JT

0 Likes
Reply
Anonymous
Not applicable

thanks for the input.

Looked into hello sensor as suggested & found  the method of writing data for a notification service & the "notifying" of that data:

in hello_sensor_interrupt_handler:765 there's the call to "bleprofile_WriteHandle(HANDLE_HELLO_SENSOR_VALUE_NOTIFY…" however the data is changed directly in the lines above it. This call seems to finalise the data change. Another function (hello_sensor_send_message) takes care of triggering the notification & is called later.

The solution in my code at the top makes no use of "bleprofile_WriteHandle", is this a problem?

It's also confusing that the hello_sensor project doesn't seem to make use of functions created by the smart designer, is that true?

Finally, the functions generated by the smart designer have the parameters "(UINT8* p_value, UINT8 value_len)" what're these used for?

Many thanks.

0 Likes
Reply
Anonymous
Not applicable

Hello Paul,

From the Developers:

1.  The Smart Designer provides code that is auto-generated

2.  The hello_sensor project  is hand-coded by the developers

3.  Your solution using "bleprofile_WriteHandle" is a problem:

      If the client reads the characteristics, it will not receive what was notified previously.

Thanks

JT

Anonymous
Not applicable

Thank for the feedback JT.

Just to clarify:

2. Is there an example of a project, using Smart Designer functions, implementing notifications, coded by the developers?

3. So to be clear, my project *should definitely* use "bleprofile_WriteHandle"?

0 Likes
Reply
Anonymous
Not applicable

Hello Paul,

Take a look at the location_navigation APP example in the SDK:

pastedImage_0.png

Let me know if this helps

Thanks

JT

0 Likes
Reply
Anonymous
Not applicable

Thanks JT.

Looked over that project & yes! That project has the same smart designer setup that mine does. It also looks to have the equivalent auto-generated function "BOOL store_in_db_location_and_navigation_navigation(UINT8* p_value, UINT8 value_len)" in it. However, the main source doesn't look to use this function at all.

The main source uses calls to "bleprofile_sendNotification" to send the notifications & calls of memcpy & "bleprofile_WriteHandle" to set the data.

Should the use of the "store_in_db_location_and_navigation_navigation" & functions like it be avoided?

0 Likes
Reply
Anonymous
Not applicable

Hello Paul,

Glad to hear that you are making progress.

  1. Yes, you should avoid the "store_in_db_location_and_navigation_navigation" & functions when using the Smart Designer.
  2. The Smart Designer was designed more as a template or guide for the TODO tasks that are needed once you declare your profiles.  It covers basic things to do after your Characteristics, Properties and Permissions.
  3. For instance if you view the Characteristics of the LN Control Point:pastedImage_2.png
  4. The Properties Tab indicate which ones are mandatory and cannot be changed as shown above
  5. In the code .wic view below, wed see that Write and Indication are declared:pastedImage_3.png
  6. Finally, the Smart Designer gives you a ToDo list to complete the code:pastedImage_4.png

In Summary, the Smart Designer was developed as a guideline.

Hope this helps.

JT

View solution in original post

0 Likes
Reply