9/15/2023 0 Comments Linux c get bluetooth mac address![]() To launch the scan every minute, edit crontab: Give the right permissions to the script: # you may add here a command or a script to be executed when the device is unavailable bin/echo 0 > /sys/class/gpio/gpio1/value # you may need to change this depending on your router bin/echo 'Device is off or out of range, relay is OFF' # you may add here a command or a script to be executed when the device is available bin/echo 1 > /sys/class/gpio/gpio1/value # you may need to change this depending on your router # check for a specific MAC ADDRESS presence: # scan for bluetooth devices and put the result into a variable: ![]() my OpenWrt, Raspberry and Linux, personal forum: Nano /root/check_presence_bt.sh #!/bin/sh To pair and trust your device do the following: Note: The device should remain in “discoverable mode”, if you do not want to let your device discoverable, you need to pair it and trust it. ![]() In my case the desired MAC Address is 30:21:15:13:9C:29 To scan for remote devices and to discover your device MAC Address, put your device in “discoverable mode” and use the following command: Note: To enable bluetooth at boot put the above three lines in the /etc/rc.local file Opkg install kmod-bluetooth bluez-libs bluez-utils kmod-usb-core kmod-usb-uhci kmod-usb2 usbutils Note: The script simply scans for any bluetooth device in range, so there is no need of pairing or trusting the device you want to detect. Using a bluetooth USB dongle for a presence detection system to activate a relay by using a GPIO (or doing anything else), when a bluetooth device is detected, for example your phone.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |