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.

BLE Notification Issue for iOS and Mac OS X

Other Parts Discussed in Thread: CC2540

Hi there,

I have been working on a project with CC2540 as peripheral device and mobile device (iOS, OS X and Android). I am having issues on receiving notifications on iOS device. I would be super glad you if you can share your opinions with me.

Currently my system works as following.

I have a 1 BLE Profile that has 2 characteristic (A and B) where A is writable and B is readable+notifyable. My use case is designed as following:

*** X: CC2540
*** Y: Android Device
*** Z: iOS Device
*** Q: OS X Device

1- X starts Advertising
2- Y discover the device, connect it and bond to device (Long term bonding is done with 6 digit passkey).
3- Rightafter the connection establish Y enable the Notification Characteristic B.
4- Y Send some information and wait for incoming notifications
5- After ~2 seconds X sends 30 20-byte notification to Y.
6- After sending all data as notification from X to Y, X disconnect from the BLE Channel.

This scenario works for Android device where sometimes I am having problems with iOS device and OS X device.

Everything works great until the step 5. However, sometimes neighter Z or Q can not get 30 notification from the X. On my Mac computer I am loging incoming notifications via callback however, instead of having notifications on every T period (Notification frequency sent from X), period is slowing down and stop having notifications. Moreover to this, I am probing the air traffic with TI's packet sniffer and on the scope with Power analysis (seeing TX peaks on the scope). It looks it is working as expected.


First I tought that maybe I am violating Apple's Developer Guide Rules. However, I think I am not violating the design rules of Apple. Here are my BLE Channel Parameters:

#define DEFAULT_ADVERTISING_INTERVAL          32
#define DEFAULT_ENABLE_UPDATE_REQUEST         TRUE
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL     16
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL     32
#define DEFAULT_DESIRED_SLAVE_LATENCY         0
#define DEFAULT_DESIRED_CONN_TIMEOUT          150
#define DEVICE_SEND_NOTIFICATION_PERIOD_IN_MS 200    //200 ms

Even I try different values for the DEVICE_SEND_NOTIFICATION_PERIOD_IN_MS from 20 ms to 200 ms, Z or Q sometimes slow down having notification and stops.

Then I thought that maybe BLE RX buffer of Z or Q is getting full. However, AFAIK I have no access to flush the RX buffer on Objective C.

I am also giving my notification sending code for X as following:

*** "Profile.c" ***
bStatus_t DeviceProfile_SendNotification( uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId )
{
  uint16 value = GATTServApp_ReadCharCfg( connHandle, DeviceProfileCharConfig );

  // If notifications enabled
  if ( value & GATT_CLIENT_CFG_NOTIFY )
  {
    // Set the handle
    pNoti->handle = DeviceProfileAttrTbl[NOTIFICATION_POSITION].handle;

    // Send the Notification
    return GATT_Notification( connHandle, pNoti, FALSE );
  }

  return bleNotReady;
}

***

*** "Device.c" ***

...
static attHandleValueNoti_t NotificationCharContext;
NotificationCharContext.handle = 0;
NotificationCharContext.len = 20
osal_memcpy(NotificationCharContext.value, dataToSend, 20);

if DeviceProfile_SendNotification( gapConnHandle, &NotificationCharContext, Device_TaskID ) == SUCCESS)
{
    bleNotificationIndex++;
        osal_start_timerEx( Device_TaskID, BLE_NOTIFICATION_EVT, DEVICE_SEND_NOTIFICATION_PERIOD_IN_MS );
}
...

***

I would be super happy if you guys give me hand on this. I am really confused about how to send proper notification. On Android side, everything works as expected where I am having very hard times on iOS and OS X.

Thank you so much again,

Have a great day!

  • Hi dnz,

    Could you provide a sniffer log of the "failing" communication with iOS devices? I am assuming that you get the communication up and running at least.

    Best Regards

    Joakim 

  • Hi there,

    Sorry for late reply and thank you so much Joakim for your reply. As a HW Engineer, I always try to blame HW at last. However, this time looks like it is an HW issue. On MacMini Late 2012 there is an issue with its wireless module. It interferes with USB 3 interface. 

    http://eshop.macsales.com/installvideos/mac_mini2012_bt_h/

    When I try the app on Macbook Air, it was working without an issue. 

    Thank you so much for your help Joakim. 

    Have a great day all!

  • Hi Dnz,

    Thank you for sharing the information. USB 3.0 is a known culprit for 2.4GHz protocols..

    Best Regards 

    Joakim