Mobile Bluetooth Networking to Record Interaction Between
Animals in the Wild
By: Adam King
Supervisors:
Alfredo Terzoli & Peter Wentworth
Problem Statement
• Develop a system to record interaction between animals in the wild using
Bluetooth
• Be able to exchange these interactions between devices
• Upload these enteractions – Brad
Recording Interaction
• What is an interaction?
• Widcomm SDK allows control of the Widcomm Bluetooth stack
• Look for devices
• Log discovered devices – handle stale interactions – handle new interactions
StartInquiry()
• Discovers all devices within the 10m radius
– According to Widcomm
• No limit to amount of devices that will be discovered
• Takes about 10s for a complete inquiry
• While a device is discovering it can not be discovered
– Make sure that devices are not in lockstep
Encounter
• Structure to encapsulate a single interaction
• Members:
– Local and Foreign Mac addresses – Start and Touch times
– State – TTL
Other Members
• Start Time
– First time a device is discovered – ie: beginning of an interaction
• Touch Time
– Last time a device was discovered
• TTL
– Similar to an IP packet’s TTL
– Encounter’s state = deleted when TTL is 0
Encounter State
• Can be one of:
• open
• closed
• uploaded
• deleted
• State Chart:
Store
• Store manages all Encounters
• Takes care of issues such as:
– where to insert new encounter
– where to insert a received encounter – which encounter to send
Inserting a new Encounter
Inserting a Received Encounter
Choosing an Encounter to send
So how does it all happen?
• Seen inquiry function
• Then discover services on each device found
– Two services to look for
• Interaction Service
• Upload service
– Service discovery is expensive though
Interaction Controller
• Receives a list of all devices found – Attempts to touch each open encounter
associated with the device
• If no open encounter store creates a new one
• Otherwise the encounter’s touch time is updated
– Asks store to update itself
• Close stale encounters
– Attempts to swap data
The Stack Again
Logical Link Control and Adaptation Protocol
• “provides connection-oriented and connectionless data services to upper layer protocols”
Specification of the Bluetooth System
• Lowest layer to make connections
• Simplest
• Client/Server
Swapping Encounters
• After all the devices have been processed
• At service discovery time discover which devices are advertising the interaction service
• Attempt to connect to each of those devices and send a single encounter
– Timeout
– Select encounter to send policy
Swapping Encounters
• Now offer the interaction service – Set up a service
– Set up server
• How long does the server exist for?
– Inquiry takes 10s
– Service discovery takes time
Listening as a server
• Listen as a server for a random amount of time
• Does three things:
– Accepts incoming connections
– Advertises its mac address (it can be discovered)
– ‘Staggers’ the devices
So how long to wait for?
• Seed the random numbers with each devices mac address
• Listen for a random amount of time + some minimum time
• Results of 10 000 times using the mac address – 08:00:28:a0:1a:1a
– average: 31s – min: 15s – max: 47s
Program Structure
• while true
discover devices
if there are any devices
discover services on those devices if upload service found
upload encounters else
process the found devices swap data