[packages] bluez-utils: Add configuration and init scripts for hci serial devices
[openwrt/svn-archive/archive.git] / utils / bluez-utils / files / bluez-utils.init
index 1a3227a693514a3f54d90a71d0b972479816254b..0b326280bfd694697cbbe04917fc690ba8665dd1 100644 (file)
@@ -17,8 +17,9 @@ append_string() {
        local section="$1"
        local option="$2"
        local value="$3"
+       local default="$4"
        local _val
-       config_get _val "$section" "$option"
+       config_get _val "$section" "$option" "$default"
        [ -n "$_val" ] && append args "$3 $_val"
 }
 
@@ -31,13 +32,16 @@ hcid_config() {
        [ "$enabled" -gt 0 ] && /usr/sbin/hcid $args
 }
 
-sdpd_config() {
+hciattach_config() {
        local cfg="$1"
        args=""
-       append_bool "$cfg" nodaemon "-n"
-       append_bool "$cfg" something "-m"
+       append_string "$cfg" initspeed "-s" "115200"
+       append_string "$cfg" tty " " "ttyS1"
+       append_string "$cfg" type " " "csr"
+       append_string "$cfg" speed " " "115200"
+       append_string "$cfg" flow " " "noflow"
        config_get_bool enabled "$cfg" "enabled" '1'
-       [ "$enabled" -gt 0 ] && /usr/sbin/sdpd $args
+       [ "$enabled" -gt 0 ] && /usr/sbin/hciattach $args
 }
 
 rfcomm_config() {
@@ -70,6 +74,12 @@ dund_config() {
        append_bool "$cfg" cache "--cache"
 
        append_string "$cfg" pppdopts ""
+       config_get ifn "$cfg" interface
+       if [ -n "$ifn" ]; then
+               config_get unit "$cfg" unit
+               [ -z "$unit" ] || append args "unit $unit ipparam $ifn linkname $ifn"
+       fi
+
        config_get_bool enabled "$cfg" "enabled" '1'
        [ "$enabled" -gt 0 ] && /usr/bin/dund $args
 }
@@ -104,7 +114,7 @@ start() {
        config_load bluetooth
 
        config_foreach hcid_config hcid
-       config_foreach sdpd_config sdpd
+       config_foreach hciattach_config hciattach
        config_foreach rfcomm_config rfcomm
        config_foreach dund_config dund
        config_foreach pand_config pand
@@ -114,6 +124,6 @@ stop() {
        killall dund
        killall pand
        /usr/bin/rfcomm release all
-       killall sdpd
+       killall hciattach
        killall hcid
 }