If you are a happy owner of OpenAutoPro (https://bluewavestudio.io/index.php/bluewave-shop/openauto-pro-detail) you will have noticed that, unfortunately, raspberry clock is not synchronized due to the absence of a RTC module. The lack of this module, for example, will not allow using the OpenAutoPro automatic day and night switch. Of course there are other options to enable it, but all of them, include: installing cables, modules or sensors. So since 99% of the time my infotainment is connected to my phone, I thought I could retrieve what I needed from my phone and sync raspberry via bluetooth. To fulfill those needs i developed OpenAutoPro Sync that will add the following features to OpenAutoPro infotainment system:
- Time sync
- Geolocation sunrise and sunset time (for day and night feature)
- Current outside temperature
All this without even a cable (obviously you will need a smartphone with internet and bluetooth).
Current time is retrieved directly from your phone, no internet needed.
Sunrise and sunset times are provided by www.yr.no via API so any change must coop with their usage limits. If you want to update your times open the app and click "Get sunrise and sunset time".
Temperature is gathered from www.yr.no API service, again here, any software modification must comply with their Terms of Service. Script will emulate a DS18B20 sensor. At the moment the data retrieved is based only on latitude and longitude, future developments will also account the altitude or variations in latitude and longitude that require an update of the data.
Enter in the root of the repo:
cd ~/open-auto-pro-sync
Run the script:
./setup-bt-services.sh
cd ~
sudo nano /etc/systemd/system/dbus-org.bluez.service
Add "-C" option at the end of ExecStart parameter
Add: "ExecStartPost=/usr/bin/sdptool add SP" after ExecStart
sudo pip3 install pybluez
git clone --branch python-script https://github.com/rizlas/open-auto-pro-sync
cd open-auto-pro-sync/oap_sync_script
sudo mkdir -p /usr/local/bin
sudo cp bt_rfcomm_server.py /usr/local/bin
sudo cp bt_rfcomm_server.service /etc/systemd/system
sudo systemctl enable bt_rfcomm_server.service
sudo systemctl start bt_rfcomm_server.service
nano /home/pi/.openauto/config/openauto_system.ini
Change this setting "TemperatureSensorDescriptor=/opt/sensor"
Disable ntp sync (try with sudo timedatectl set-ntp false)
Check the status script via:
systemctl status bt_rfcomm_server.service
The output should contain this line:
Active: active (running) since ...
Check script logs using:
tail -f /tmp/bt_server.log
- Download apk (https://github.com/rizlas/open-auto-pro-sync/raw/master/OpenAutoProSync.apk)
- Install (enable unknown sources)
- Grant permissions (if you want)
Check if the service is running from
Developer options -> Running services and you should see OpenAutoPro Sync icon
if the service is not running reboot your phone. Further investigation to try to keep the service alive are in progress.
You can always sync OpenAuto Pro manually. Just open the app and click top right button. This will also restart the sync service.
- https://developer.yr.no/ for meteorological Apis
- https://github.com/pybluez/pybluez for rfcomm bluetooth server
- Icon made by smalllikeart from www.flaticon.com
- https://bluewavestudio.io/ for OpenAutoPro
Feel free to make pull requests, fork, destroy or whatever you like most. Any criticism is more than welcome.