Take a look at the attached project.
It's more elaborate than the simple easiBeacons example i posted in the other thread.
It encapulates the functions of the easiBeacon library into a Class - a single instance of this Class is referenced as a Process Global in the Main Activity module.
You should be able to modify the project so that instance is referenced as a Process Global of a Service module if desired.
The project is designed to detect any of 3 easiBeacons i have.
These 3 easiBeacons have all been configured with the same UUID and the project will only detect easiBeacons with this UUID.
You could comment out the line in the Main Activity, line 39:
Code:
BeaconMonitor1.SetUUIDFilter(<my UUID here>)
Or you could set the UUID filter to the UUID of your easiBeacon(s).
My three easiBeacons all have the same Major id of 1, their Minor ids are 1, 2 and 3.
Configuring your easiBeacons with a unique combination of UUID, Major and Minor ids is the way to know if any found beacons are your own beacons.
You have to assume that nobody nearby will be using beacons and have them configured with the same UUID that you have chosen - not likely but not impossible...
The application can scan once or scan repeatedly using a Timer.
Look in the Class module and you'll see i disable the Timer in it's Tick event, perform a scan and then re-enable the Timer.
Could your exception be caused by your Timer Tick event being raised while a scan is already in progress?
Disabling the Timer while a scan is in progress would prevent such an exception.
So the application performs a scan for beacons and when the scan completes it populates a ListView with all found beacons.
Displaying the beacon's Major and Minor ids along with their proximity and battery level.
(Screengrab attached).
Compile and run the project and look in the log.
It's pretty self explanatory.
You'll see comments such as 'BeaconMonitor: callback sub ??? not found'.
The Class will raise events in the Activity if the corresponding callback sub exists in the Activity.
If you uncomment these lines in the Activity:
Code:
'Sub BeaconMonitor_BeaconFound(IBeacon1 As IBeacon)
' this event currently not used
'End Sub
'Sub BeaconMonitor_EnterRegion(IBeacon1 As IBeacon)
' this event currently not used
'End Sub
'Sub BeaconMonitor_ExitRegion(IBeacon1 As IBeacon)
' this event currently not used
'End Sub
Replace the comment "' this event currently not used" with a Log statement, you should see those callback subs now executed.
Look at the Class method 'Reset' - see it's comment?
Calling reset tells the library to forget about any beacons found by it's last scan.
If these last found beacons are forgotten then the library is unable to raise any 'ExitRegion' events - when it next scans and finds beacons it can't compare the beacons found by the new scan to the (forgotten) beacons found by the previous scan.
Therefore it cannot know if the android device has exited a region.
Post again if you have more questions and i'll try and help.
Martin.