My test Observer application running on a CC2541-based custom board seems to be missing some advertisements while advertising, although the same hardware doesn't seem to miss any packets when downloading a 148K binary image using OAD. I'm wondering if my approach to this (or my understanding of how Observers and discovery works) is just wrong. I had previously posted this as a reply to a related question I had last week, but have received no additional responses, so I thought maybe a separate thread would be better.
My application is trying to determine when a CC2541-based Observer passes through a doorway, where the tag is affixed to the top of the door opening and directionally attenuated with ferrite shields. Obviously, we want to minimize the false positives generated by Observers passing by the doorway rather than through it. For our application, predictable performance is more important than maximum battery life (within reason). We need our Observer devices to last 12-18 hours on a 150mAh battery, and the Broadcasters to last as long as we can get on 2 AA batteries. Ideally, our Broadcasters would last years on a coin cell, but we realize that isn't realistic, and we have the flexibility to use larger capacity batteries. Cost is probably a bigger issue.
I made a simple test program where the Broadcaster sends a minimal advertisement every 250 ms. I also made a test Observer program that enters discovery for 250 ms. When a device event is received, I set a flag, and when the discovery complete event is received I set an LED based on the flag and restart discovery for another 250 ms.
static void simpleBLEObserverEventCB( gapObserverRoleEvent_t *pEvent ) { switch ( pEvent->gap.opcode ) { case GAP_DEVICE_INIT_DONE_EVENT: break; case GAP_DEVICE_INFO_EVENT: { bDetected = TRUE; } break; case GAP_DEVICE_DISCOVERY_EVENT: { if (bDetected) HalLedSet( HAL_LED_GREEN, HAL_LED_MODE_ON ); else HalLedSet( HAL_LED_GREEN, HAL_LED_MODE_OFF ); bDetected = FALSE; // Start the Observer discovering devices GAPObserverRole_StartDiscovery( DEVDISC_MODE_ALL, false, false); } break; default: break; } }
I would have expected that if the Broadcaster was near the reader (within a few feet) that I would have the LED constantly on. What I actually see is that the Observer definitely misses many advertisements, in fact I would say it may miss 10-20%, sometimes more. I tried staggering the intervals by setting the Broadcaster to 200 ms and the Observer to 250 ms discovery periods, and the results are nearly the same. If I double the broadcasting rate compared to the discovery period, it is much better, but still not perfect.
Should the Observer be able to detect a Broadcaster closer to 100% of the time over a 250 ms discovery period? Or is this pretty normal? Why would I be missing advertisements so frequently during my discovery period?
Thanks,
-rich