Add device tracker detection and automatic creation following HA discovery convention
So as to trigger the away state, add an offline status to the identified BLE trackers
Set `interval` and `intervalacts` to the minimum when adaptive scanning is deactivated. When the user encounters a situation on which a device is not detected due to adaptive scanning, we set the gateway to continuous active to maximize the chance to detect the device.
* [BT] Adaptive scan
Add adaptive scan to avoid users setting parameters and deduct automatically the scan requirements from the list of devices
---------
Co-authored-by: DigiH <github@digih.net>
With only one control that enables the publication of all the advertisement data, default: false
Note that if the sensor is not recognized, we will no longer publish its advertisement data unless the control is true. This is for the sake of traffic reduction.
This commit add the capability to set passive scanning during runtime, versus buildtime before, so as to improve energy consumption of sensors when they don't require active scanning
* Use a task to process immediate BLE actions to prevent MQTT disconnection if the action takes too long to complete.
* Add state_on and state_off parameters to createDiscovery
This allows for connecting to devices that do not use the MAC address type 0.
This also adds the logging of the "mac_type" so it is visible to users trying to connect to broadcasting devices.
Additionally this will allow for future connectable devices using a MAC address type other than 0 to be automatically connected to
when support is added for them, similar to LYWSD03MMC etc..
* Add immediate parameter to BLE connection commands.
When sending a command to read/write a characteristic on a BLE server this adds a new parameter to cause the action to be
performed immediately. This will stop the scan in progress to perform the actions queued.
Example use:
```
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{
"ble_write_address":"AA:BB:CC:DD:EE:FF",
"ble_write_service":"cba20d00-224d-11e6-9fb8-0002a5d5c51b",
"ble_write_char":"cba20002-224d-11e6-9fb8-0002a5d5c51b",
"ble_write_value":"TEST",
"value_type":"STRING",
"ttl":4,
"immediate":true }'
```
Stop BLE processing when immeditate command sent.
* Use a shorter connection timeout.
* Update docs.
* Remove MQTT spam for connection retrys
* Prevent crashing when the normal connection process occurs at the same time as an immediate action.
* Use a semaphore to protect BLE device vector.