Bluetooth entrance is the feature that allows users to unlock the gym doors using the Bluetooth option on their mobile phones.
First the user is asked to allow the mobility app to use the Bluetooth feature of the mobile device.
When the user allows to use the Bluetooth option, the Bluetooth scan will start.
The available Bluetooth doors will get listed and the user can select the required door and switch ON the toggle button to open the door.
Searching for and unlocking passage readers
We start the process by searching for the nearby beacons (by using the settings beaconUUID and beaconIdentifier).
Need to enable Bluetooth for scanning to work. In Android, you need to give location permissions and Bluetooth scanning permissions.
beaconUUID - the UUID of the beacons to search for
beaconIdentifier - the identifier of the beacons to search for
After searching for the nearby beacons we can get their major and minor values.
Using the `GET /passagereaders` endpoint we can get the information about a passage reader by providing the detected major and minor values.
Using the `POST /customers/:customerId/passagetries` endpoint we can open a particular passage reader by providing its id.
By default, we are printing a ticket when a passage reader is unlocked.
Managing user devices
Can get the devices of a particular customer by using the `GET /customers/:customerId/devices` endpoint. Using the information returned we can figure out the user's primary device (using the `lastBecamePrimary` property).
Using the `POST /customers/:customerId/devices/:deviceId/primary` we can set a particular device as the primary device of the customer.
The setting `daysBetweenSwitchingPassageDevice` dictates how frequently the customer can update their primary device. (e.g. if the value is 5, the customer can only change the primary device after 5 days. If they change the primary device yesterday, they will not be able to change the primary device today).
Before unlocking a passage reader the current device is set as the customer’s primary device. If it fails (due to a violation of `daysBetweenSwitchingPassageDevice`), the passage is not unlocked. This is done to prevent the user from sharing their account with others in order to allow them to gain access. (since, most likely, they will have different devices, only one person will gain access for a particular time period).