This PR modifies how the mock Central Manager simulates advertising.
Before
For each scanning CBMCentralManagerMock a list of timers was created, one for each CBMPeripheralSpec. Two instances of the manager could receive packets from the same peripheral in different time, as timers were independent and started on scanning of each manager. Connection to a device was immediate with just connection interval delay.
After
First of all, each CBMPeripheralSpec can have multiple advertising configurations. Each AdvertisingConfig has own advertising data, interval and a new parameter - a delay. If the interval is 0 and the delay > 0 the advertising will be sent only once, delay seconds after adding the peripheral to the simulation.
There is a single set of timers that will emulate advertising of every advertising set. The advertising data is delivered to all scanning central managers at the same time. Also, connection now waits for an advertising packet to come and only then continues, like in real life.
API changes
The change should be backwards compatible.
When defining a CBMPeripheralSpec now it is possible to call advertising block multiple times, for example:
This PR modifies how the mock Central Manager simulates advertising.
Before
For each scanning
CBMCentralManagerMock
a list of timers was created, one for eachCBMPeripheralSpec
. Two instances of the manager could receive packets from the same peripheral in different time, as timers were independent and started on scanning of each manager. Connection to a device was immediate with just connection interval delay.After
First of all, each
CBMPeripheralSpec
can have multiple advertising configurations. EachAdvertisingConfig
has own advertising data, interval and a new parameter - a delay. If the interval is 0 and the delay > 0 the advertising will be sent only once, delay seconds after adding the peripheral to the simulation. There is a single set of timers that will emulate advertising of every advertising set. The advertising data is delivered to all scanning central managers at the same time. Also, connection now waits for an advertising packet to come and only then continues, like in real life.API changes
The change should be backwards compatible.
When defining a
CBMPeripheralSpec
now it is possible to calladvertising
block multiple times, for example:It is also possible to change advertising set during a simulation with the new
CBMPeripheralSpec.simulateAdvertisingChange(:[AdvertisingConfig]?)