How to initialize Bluetooth in a startup script with Yocto Poky Linux -


i have script initializes bluetooth setup on intel edison. allows pairing , connecting headless machine running yocto poky linux. suggested put startup script in /etc/init.d , run update-rc.d myscript.sh defaults. script ran didn't work (generated boot errors saying bluetooth device not found) because bluetooth had not started yet. did reasearch , after removing links did update-rc.d myscript.sh defaults 99 claimed run script last did't make differrence -- still ran in same place in boot sequence. verified links had s99 on them seemed set correctly. there post on asking similar question ubuntu system mine poky linux. solution suggested putting startup script in directory not exist on system. there other suggestions, putting in rc.local, did , got same result, runs before bluetooth initialized.

here script. program called nmea_thread , run last. else initializing bluetooth.

#!/bin/sh /usr/sbin/rfkill unblock bluetooth /usr/bin/hciconfig hci0 /usr/bin/hciconfig hci0 piscan  /usr/bin/hciconfig hic0 sspmode 0 /home/root/simpleagent/simple-agent & /home/root/nmea_thread  

often bluetooth initialized asynchronously, can't sure script run after hci0 added. solution wait bt initialization in background:

#!/bin/bash  if [ "$1" != "background" ];      $0 background & else     #wait until bt initialized     ((i = 0; <= 100; i++))       hciconfig hci0 && break       usleep 100000     done     /usr/sbin/rfkill unblock bluetooth     /usr/bin/hciconfig hci0     /usr/bin/hciconfig hci0 piscan      /usr/bin/hciconfig hic0 sspmode 0     /home/root/simpleagent/simple-agent &     /home/root/nmea_thread  fi 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -