/etc/init.d/bluetooth (Einige Variablen werden in
/etc/default/bluetooth nochmal gesetzt und sind hier ggf. unnötig gesetzt.)
#! /bin/bash
### BEGIN INIT INFO
# Provides: bluetooth
# Required-Start: $local_fs $syslog $remote_fs
# Required-Stop: $local_fs $syslog $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start bluetooth daemons
### END INIT INFO
#
# bluez-utils Bluetooth subsystem starting and stopping
#
# originally from bluez's scripts/bluetooth.init
#
# Edd Dumbill
# LSB 3.0 compilance and enhancements by Filippo Giunchedi
#
# startup control over dund and pand can be changed by editing
# /etc/default/bluez-utils
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC="Bluetooth services"
HCID=/usr/sbin/hcid
HCIATTACH=/usr/sbin/hciattach
HCID_NAME=hcid
#HCID_OPTIONS="-x -s"
HCID_OPTIONS="-s"
HID2HCI=/usr/sbin/hid2hci
UART_CONF=/etc/bluetooth/uart
RFCOMM=/usr/bin/rfcomm
RFCOMM_NAME=rfcomm
RFCOMM_CONF=/etc/bluetooth/rfcomm.conf
SDPTOOL=/usr/bin/sdptool
DUND_DAEMON=/usr/bin/dund
DUND_NAME=dund
PAND_DAEMON=/usr/bin/pand
PAND_NAME=pand
HIDD_DAEMON=/usr/bin/hidd
HIDD_NAME=hidd
DUND_ENABLED=1
PAND_ENABLED=0
HIDD_ENABLED=0
DUND_OPTIONS="--listen --persist --msdun call treo650-js"
PAND_OPTIONS=""
HIDD_OPTIONS="--master --server"
test -f /etc/default/bluetooth && . /etc/default/bluetooth
test -f /etc/default/rcS && . /etc/default/rcS
. /lib/lsb/init-functions
# test for essential daemons
test -x $HCID || exit 0
test -x $HCIATTACH || exit 0
test -x $RFCOMM || exit 0
# disable nonessential daemons if not present
if test "$DUND_ENABLED" != "0"; then
if ! test -f $DUND_DAEMON; then
DUND_ENABLED=0
fi
fi
if test "$PAND_ENABLED" != "0"; then
if ! test -f $PAND_DAEMON; then
PAND_ENABLED=0
fi
fi
if test "$HIDD_ENABLED" != "0"; then
if ! test -f $HIDD_DAEMON; then
HIDD_ENABLED=0
fi
fi
set -e
run_sdptool()
{
test -x $SDPTOOL || return 1
if ! test -z "$SDPTOOL_OPTIONS" ; then
oldifs="$IFS"
IFS=";"
for o in $SDPTOOL_OPTIONS ; do
#echo "execing $SDPTOOL $o"
IFS=" "
$SDPTOOL $o &>/dev/null
done
IFS="$oldifs"
fi
}
enable_hci_input()
{
if [ "$VERBOSE" != no ]; then
log_success_msg "Switching on Bluetooth input devices..."
$HID2HCI --tohci
else
$HID2HCI --tohci >/dev/null 2>&1
fi
}
disable_hci_input()
{
if [ "$VERBOSE" != no ]; then
log_success_msg "Switching Bluetooth input devices back to HID mode..."
$HID2HCI --tohid
else
$HID2HCI --tohid >/dev/null 2>&1
fi
}
start_pan()
{
if test "$DUND_ENABLED" != "0"; then
#js
echo PER HAND: start $DUND_DAEMON -- $DUND_OPTIONS
start-stop-daemon --start --exec $DUND_DAEMON -- $DUND_OPTIONS
sleep 3
[ "$VERBOSE" != no ] && log_success_msg "Starting $DUND_NAME..."
fi
if test "$PAND_ENABLED" != "0"; then
start-stop-daemon --start --quiet --exec $PAND_DAEMON -- $PAND_OPTIONS
#js
echo start $PAND_DAEMON -- $PAND_OPTIONS
[ "$VERBOSE" != no ] && log_success_msg "Starting $PAND_NAME..."
fi
}
stop_pan()
{
if test "$DUND_ENABLED" != "0"; then
start-stop-daemon --stop --quiet --exec $DUND_DAEMON || true
[ "$VERBOSE" != no ] && log_success_msg "Stopping $DUND_NAME..."
fi
if test "$PAND_ENABLED" != "0"; then
start-stop-daemon --stop --quiet --exec $PAND_DAEMON || true
[ "$VERBOSE" != no ] && log_success_msg "Stopping $PAND_NAME..."
fi
}
start_hid()
{
if test "$HIDD_ENABLED" != "0"; then
start-stop-daemon --start --quiet --exec $HIDD_DAEMON -- $HIDD_OPTIONS
[ "$VERBOSE" != no ] && log_success_msg "Starting $HIDD_NAME..."
fi
}
stop_hid()
{
if test "$HIDD_ENABLED" != "0"; then
$HIDD_DAEMON --killall
start-stop-daemon --stop --quiet --exec $HIDD_DAEMON || true
[ "$VERBOSE" != no ] && log_success_msg "Stopping $HIDD_NAME..."
fi
}
start_uarts()
{
[ -f $HCIATTACH ] && [ -f $UART_CONF ] || return
grep -v '^#' $UART_CONF | while read i; do
if [ "$VERBOSE" != no ]; then
$HCIATTACH $i
else
$HCIATTACH $i >/dev/null 2>&1
fi
done
}
stop_uarts()
{
killall hciattach > /dev/null 2>&1 || true
}
start_rfcomm()
{
if [ -x $RFCOMM ] && [ -f $RFCOMM_CONF ] ; then
# rfcomm must always succeed for now: users
# may not yet have an rfcomm-enabled kernel
if [ "$VERBOSE" != no ]; then
log_success_msg "Starting $RFCOMM_NAME..."
$RFCOMM -f $RFCOMM_CONF bind all || true
else
$RFCOMM -f $RFCOMM_CONF bind all >/dev/null 2>&1 || true
fi
fi
}
stop_rfcomm()
{
if [ -x $RFCOMM ] ; then
if [ "$VERBOSE" != no ]; then
log_success_msg "Stopping $RFCOMM_NAME..."
$RFCOMM unbind all || true
else
$RFCOMM unbind all >/dev/null 2>&1 || true
fi
fi
}
restart_rfcomm()
{
if [ -x $RFCOMM ] && [ -f $RFCOMM_CONF ] ; then
if [ "$VERBOSE" != no ]; then
log_success_msg "Restarting $RFCOMM_NAME..."
$RFCOMM unbind all || true
$RFCOMM -f $RFCOMM_CONF bind all || true
else
$RFCOMM unbind all >/dev/null 2>&1|| true
$RFCOMM -f $RFCOMM_CONF bind all >/dev/null 2>&1 || true
fi
fi
}
case "$1" in
start)
log_daemon_msg "Starting $DESC"
if test "$BLUETOOTH_ENABLED" == "0"; then
log_progress_msg "disabled. see /etc/default/bluetooth"
log_end_msg 0
exit 0
fi
# start-stop-daemon --start --quiet --exec $HCID -- $HCID_OPTIONS || true
start-stop-daemon --start --exec $HCID -- $HCID_OPTIONS || true
log_progress_msg "hcid"
# sleep 2
start_uarts || true
start_hid || true
enable_hci_input || true
start_rfcomm || true
start_pan || true
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping $DESC"
stop_pan || true
stop_rfcomm || true
disable_hci_input || true
stop_hid || true
start-stop-daemon --stop --quiet --exec $HCID || true
log_progress_msg "$HCID_NAME"
stop_uarts || true
log_end_msg 0
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC"
stop_hid || true
stop_pan || true
start-stop-daemon --stop --quiet --exec $HCID || true
sleep 1
if test "$BLUETOOTH_ENABLED" == "0"; then
log_progress_msg "disabled. see /etc/default/bluetooth"
log_end_msg 0
exit 0
fi
start-stop-daemon --start --quiet --exec $HCID -- $HCID_OPTIONS || true
sleep 2
echo HCID restart
log_progress_msg "$HCID_NAME"
start_pan || true
start_hid || true
restart_rfcomm
log_end_msg 0
;;
*)
N=/etc/init.d/bluetooth
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
/etc/bluetooth/hcid.conf
#
# HCI daemon configuration file.
#
# 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 user;
# Pairing mode
# none - Pairing disabled
# multi - Allow pairing with already paired devices
# once - Pair once and deny successive attempts
pairing multi;
# Default PIN code for incoming connections
passkey "1234";
}
# Default settings for HCI devices
device {
# Local device name
# %d - device id
# %h - host name
name "%h-%d";
# Local device class
class 0x3e0100;
# class 0x000100;
# Default packet type
#pkt_type DH1,DM1,HV1;
# Inquiry and Page scan
iscan enable; pscan enable;
discovto 0;
# 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;
# Default link policy
# none - no specific policy
# rswitch - allow role switch
# hold - allow hold mode
# sniff - allow sniff mode
# park - allow park mode
lp rswitch,hold,sniff,park;
# auth enable;
# encrypt enable;
}
/etc/bluetooth/rfcomm.conf
#
# RFCOMM configuration file.
#
rfcomm0 {
# # Automatically bind the device at startup
bind yes;
#
# # Bluetooth address of the device
# device 11:22:33:44:55:66;
# Palm: device 00:07:E0:06:76:8F;
device 00:02:72:B0:00:26;
#
# # RFCOMM channel for the connection
channel 1;
#
# # Description of the connection
# comment "Example Bluetooth device";
comment "JS Treo";
}
/etc/default/bluetooth
# 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
#DUND_OPTIONS="--listen --persist"
# 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"
# js s.u.
# DUND_OPTIONS="--connect 00:07:E0:06:76:8F"
#
# Listen on channel 3
# DUND_OPTIONS="--listen --channel 3"
DUND_OPTIONS="--listen --persist --msdun call treo650-js"
#DUND_OPTIONS="--listen --persist --msdun "
# 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=0
# Arguments to pand
# Read the PAN howto for ways to set this up
# http://bluez.sourceforge.net/contrib/HOWTO-PAN
PAND_OPTIONS=""
# example pand lines
#
# Act as the controller of an ad-hoc network
# PAND_OPTIONS="--listen --role GN"
PAND_OPTIONS="--listen --role GN"
#
# Act as a network access point: routes to other networks
# PAND_OPTIONS="--listen --role NAP"
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=""
/etc/ppp/peers/treo650-js Hier sollte ein geeignetes, sonst
nicht verwendetes "privates Netz" eingesetzt werden. Der Nameserver sollte vom PC verwendet
werden (ahem, dürfte eigentlich nur für Netzverbindungen wichtig sein, welche hier nicht
besprochen werden). Das "debug" am Ende ist ganz nett, dann kann man im syslog
/var/log/message sehen, ob sich was tut, kann auch weg.
115200
# nodetach
noauth
local
ktune
noproxyarp
noipx
idle 0
192.168.1.101:192.168.1.103
ms-dns 137.248.1.8
netmask 255.255.255.0
debug