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!