📜 ⬆️ ⬇️

Bluetooth on Linux

1. Introduction


Do you know that setting up a bluetooth connection from a PC to Linux is not at all difficult?
So, now we will create a connection to the phone \ PDA, mount the file system of the phone to it on a PC and create a GPRS \ EDGE connection.


The iron on which I tested - the laptop ASUS M51TR, mobile phones - Motorola L9, Motorola E398. All this at Kubuntu 8.10.

Required packages:

2. Find the phone.


To do this, we need to know the MAC address of the phone and the channel numbers of the services we need.
')
Using sdptool, we are looking for our phone in reach:
sdptool browse

It will output something like this to the terminal:
Inquiring ...
Browsing 00:17:E4:1B:D2:E3 ...


Where 00: 17: E4: 1B: D2: E3 is the MAC address.

And then follow the description of the services provided by the cell phone, for example, for Dial-Up Networking:
Service Name : Dial-up Networking Gateway
Service Description: Dial-up Networking Gateway
Service Provider : Motorola
Service RecHandle: 0x10001
Service Class ID List:
"Dialup Networking" (0x1103)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel : 1
[, ]

Bold above, I highlighted the key points.
Service Name - the name of the service.
Service Provider - in most cases - the phone model (useful when many devices are found).
Channel is the second mandatory item, after the MAC address.

Follow the channel numbers for the necessary services (DUN, FTP) and register:
sdptool add DUN
sdptool add FTP

3. Connect


We edit the /etc/bluetooth/rfcomm.conf file, adding connections:

rfcomm0 {
bind yes;
device 00:17:E4:1B:D2:E3;
channel 1;
comment "Dialup Networking Gateway";
}


bind - automatically connect the device when the system starts,
device - the MAC address,
channel.

Each new service is added as rfcommN, where N is a number. Elementary, just insure;)
We save and check the performance:
sudo rfcomm bind all
rfcomm

We get the following on the exhaust:
rfcomm0: 00:17:E4:1B:D2:E3 channel 1 clean
rfcomm1: 00:17:E4:1B:D2:E3 channel 9 clean
rfcomm2: 00:17:E4:1B:D2:E3 channel 8 clean


If so, then everything is OK, devices are found and connected, if not - check rfcomm.conf

4. We mount


Need a service - OBEX FTP.

Create a mount point:
sudo mkdir -m777 /media/mobile

Add a user to the fuse group so that he can mount the file system:
sudo usermod -aG fuse username

Mount *:
obexfs -b00:17:E4:1B:D2:E3 -B9 /media/mobile
-b = MAC
-B = channel

or
obexfs -t /dev/rfcomm0 /media/mobile

Then:
cd /media/mobile
ls


Voila:
audio MMC(Removable) picture video

Unmounting, it's simple:
umount /media/mobile

* Perhaps when you first connect, you will be asked to pair the devices. For example, type “1234” on the phone, and then on the PC.

5. GPRS \ EDGE


Need service - DUN (Dial-Up Networking)
I have KDE, so we run kppp.
Configure -> Modems -> New -> Device ,
where Modem device is your configured device \ channel for DUN (see /etc/bluetooth/rfcomm.conf)

All the same: go to the tab Modem-> Modem Commands
(further settings for the Belarusian MTS, look at the operator site):
Initialization String 1: AT + CGDCONT = 1, “IP”, “mts”
Initialization String 2: ATZ

To test, click Query Modem .

The modem is configured, we configure the connection:
The main settings window -> Accounts -> New -> Manual Setup
Specify the name, say, MTS BY
Add a phone number: * 99 # or * 99 *** 1 # .

Is done. We choose in kppp account and modem, and the network!
(kppp-> use modem ->% configured modem% -> Connect)

Thanks for attention!

UPD: renamed the topic, that would not be confused;)

Source: https://habr.com/ru/post/53966/


All Articles