Настройка соединения КПК с компьютером через Bluetooth
Настроим соединение КПК с компьютером посредством Bluetooth.
По умолчанию считаем, что устройство распозналась корректно и коснёмся только настройки конфигов. Все действия производились на системе Ubuntu 7.04 - Feisty Fawn, Bluetooth dongle KY-BT100.
Первым делом редактируем файл /etc/bluetooth/hcid.conf
#
# HCI daemon configuration file.
#
# $Id: hcid.conf,v 1.4 2004/04/29 20:14:21 holtmann Exp $
#
# HCId options
options {
# Automatically initialize new devices
autoinit yes;
# Security Manager mode
# none - Security manager disabled
# auto - Use local PIN for incoming connections
# user - Always ask user for a PIN
#
security auto;
# Pairing mode
# none - Pairing disabled
# multi - Allow pairing with already paired devices
# once - Pair once and deny successive attempts
pairing multi;
# PIN helper
#pin_helper /usr/bin/bluepin;
# Этот пин-хелпер не поддерживается, просто пишем наш ПИН
passkey "1234";
# D-Bus PIN helper
#dbus_pin_helper;
}
# Default settings for HCI devices
device {
# Local device name
# %d - device id
# %h - host name
name "%h-%d";
# Local device class
class 0x100;
# Default packet type
#pkt_type DH1,DM1,HV1;
# Inquiry and Page scan
iscan enable; pscan enable;
# Default link mode
# none - no specific policy
# accept - always accept incoming connections
# master - become master on incoming connections,
# deny role switch on outgoing connections
#
#lm accept,master;
#
lm accept;
# Default link policy
# none - no specific policy
# rswitch - allow role switch
# hold - allow hold mode
# sniff - allow sniff mode
# park - allow park mode
#
#lp hold,sniff;
#
lp rswitch,hold,sniff,park;
# Authentication and Encryption
# Это тоже судя по всему не работает
#auth enable;
#encrypt enable;
}
Далее делаем:
# hcitool scan
Scanning ...
00:09:2D:2B:92:18 Mokia
КПК нашелся. Это его MAC адрес, запоминаем.
В многих howto пишут, что дальше нужно сделать pairing устройств
# hcitool cc 00:09:2D:2B:92:18
и
# hcitool auth 00:09:2D:2B:92:18
но у меня на эти команды никакой реакции не последовало
Командой l2ping 00:09:2D:2B:92:18 можно проверить пингуется ли устройство.
Редактируем файл /etc/default/bluetooth, включаем сервисы dund, pand и опции sdp
# Defaults for bluez-utils
# This file supersedes /etc/default/bluez-pan. If
# that exists on your system, you should use this
# file instead and remove the old one. Until you
# do so, the contents of this file will be ignored.
# start bluetooth on boot?
# compatibility note: If this variable is not found bluetooth will
# start
BLUETOOTH_ENABLED=1
############ HIDD
#
# To have Bluetooth mouse and keyboard support, get the
# Linux 2.6.6 patch or better from bluez.org, and set
# HIDD_ENABLED to 1.
HIDD_ENABLED=0
HIDD_OPTIONS="--master --server"
# to make hidd always use a particular interface, use something
# like this, substituting the bdaddr of the interface:
# HIDD_OPTIONS="-i AA:BB:CC:DD:EE:FF --server"
#
# remove '--master' if you're having trouble working with Ericsson
# T630 phones with hidd operational at the same time.
############ COMPATIBILITY WITH OLD BLUEZ-PAN
# Compatibility: if old PAN config exists, use it
# rather than this file.
if test -f /etc/default/bluez-pan; then
. /etc/default/bluez-pan
return
fi
############
############ DUND
#
# Run dund -- this allows ppp logins. 1 for enabled, 0 for disabled.
DUND_ENABLED=1
# Arguments to dund: defaults to acting as a server
# добавляем --msdun call axim-bt, что означает соединение через ppp с axim-bt
DUND_OPTIONS="--listen --persist --activesync --msdun call axim-bt"
# Run dund --help to see the full array of options.
# Here are some examples:
#
# Connect to any nearby host offering access
# DUND_OPTIONS="--search"
#
# Connect to host 00:11:22:33:44:55
# DUND_OPTIONS="--connect 00:11:22:33:44:55"
#
# Listen on channel 3
# DUND_OPTIONS="--listen --channel 3"
# Special consideration is needed for certain devices. Microsoft
# users see the --msdun option. Ericsson P800 users will need to
# listen on channel 3 and also run 'sdptool add --channel=3 SP'
############ PAND
#
# Run pand -- ethernet: creates new network interfaces bnep
# that can be configured in /etc/network/interfaces
# set to 1 for enabled, 0 for disabled
PAND_ENABLED=1
# Arguments to pand
# Read the PAN howto for ways to set this up
# http://bluez.sourceforge.net/contrib/HOWTO-PAN
PAND_OPTIONS="--listen --role NAP"
# example pand lines
#
# Act as the controller of an ad-hoc network
# PAND_OPTIONS="--listen --role GN"
#
# Act as a network access point: routes to other networks
# PAND_OPTIONS="--listen --role NAP"
#
# Act as a client of an ad-hoc controller with number 00:11:22:33:44:55
# PAND_OPTIONS="--role PANU --connect 00:11:22:33:44:55"
#
# Connect to any nearby network controller (access point or ad-hoc)
# PAND_OPTIONS="--role PANU --search"
############ SDPTOOL
# this variable controls the options passed to sdptool on boot, useful if you
# need to setup sdpd on boot.
# options are ;-separated, i.e. for every ; an sdptool instance will be
# launched
#
# examples:
# SDPTOOL_OPTIONS="add --channel=3 SP" # ericsson P800 serial profile
# SDPTOOL_OPTIONS="add --channel=8 OPUSH ; add --channel=9 FTRN" # motorola
# # object push and file transfer
SDPTOOL_OPTIONS="add --channel=1 SP" Редактируем /etc/bluetooth/rfcomm.conf
# RFCOMM configuration file.
#
rfcomm0 {
# # Automatically bind the device at startup
bind yes;
#
# # Bluetooth address of the device
# MAC адрес нашего устройства
device 00:09:2D:2B:92:18;
#
# # RFCOMM channel for the connection
channel 1;
#
# # Description of the connection
comment "Dell Axim x50";
}
Создаём файл /etc/ppp/peers/axim-bt
DNS можно посмотреть в /etc/resolv.conf
nodefaultroute noauth local 10.10.99.99:10.10.99.100 ms-dns ВАШ DNS nodeflate linkname synce-device
Теперь на КПК идём в Bluetooth Manager, Поиск сервисов, Новое ActiveSync соединение.
В списке устройств должен появиться наш компьютер, в моём случае Linux-ak-0 (это называние берётся из файла hcid.conf - Local device name). Авторизацию и шифрование не включаем.
Создаётся новое соединение, которое и запускаем. После старта будет создано ppp0 с нашими IP адресами из axim-bt.
Проверяем пинг, всё должно работать. Что-бы выйти в интернет через компьютер, нужно включить ipforward:
echo 1 > /proc/sys/net/ipv4/ip_forward
или в файле /etc/sysctl.conf
Для того, что-бы можно было принимать и передавать файлы через блютус, нужно поставить gnome-obex и для "спаривания" запустить команду passkey-agent --default /etc/bluetooth/pin, вместо пути к файлу можно написать /usr/bin/bluepin, тогда будет появляться попап с запросом pin кода.
- Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии
