I'm writting a script for automatized bluetooth GPS connection. I even have working PND but one thing is not as elegant as it could be.
Official GPS guide suggests insertion of BT MAC address into /etc/bluetooth/rfcomm.conf. My script is currently reading the MAC address from txt file in appdata where it must be inserted manually too. Which is unnecessary redundancy.
I would like to read rfcomm.conf and parse the GPS MAC address out of it.
Unfortunatelly my AWK or SED skills are close to zero. I used AWK long, long time ago on a very basic level. Of course I tried to search the internet for help but all I found was focused on parsing XML and not really fitting my case.
This is how simple rfcomm.conf looks like:
Goal is to find the right rfcomm# element - the one which contains line "comment "GPS";" - and then read the MAC value from line "device XX:XX:XX:XX:XX:XX;" .
Keep in mind that users can have more rfcomm# devices defined in this file.
Thanks in advance for any help!
Official GPS guide suggests insertion of BT MAC address into /etc/bluetooth/rfcomm.conf. My script is currently reading the MAC address from txt file in appdata where it must be inserted manually too. Which is unnecessary redundancy.
I would like to read rfcomm.conf and parse the GPS MAC address out of it.
Unfortunatelly my AWK or SED skills are close to zero. I used AWK long, long time ago on a very basic level. Of course I tried to search the internet for help but all I found was focused on parsing XML and not really fitting my case.
This is how simple rfcomm.conf looks like:
Code:
# RFCOMM configuration file.
rfcomm0 {
# Automatically bind the device at startup
bind no;
# Bluetooth address of the device
device XX:XX:XX:XX:XX:XX;
# RFCOMM channel for the connection
channel 1;
# Description of the connection
comment "GPS";
}
Goal is to find the right rfcomm# element - the one which contains line "comment "GPS";" - and then read the MAC value from line "device XX:XX:XX:XX:XX:XX;" .
Keep in mind that users can have more rfcomm# devices defined in this file.
Thanks in advance for any help!