WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Bluetooth Keyboard  (Read 11377 times)

Offline michiil

  • Newbie
  • *
  • Posts: 21
Bluetooth Keyboard
« on: January 14, 2016, 12:28:13 PM »
Hey guys,
i have searched the forum but didn't find anything helpfull so:
is the a way to connect a bluetooth keyboard on picore 7?

Thanks in advance

Offline beerstein

  • Hero Member
  • *****
  • Posts: 530
Re: Bluetooth Keyboard
« Reply #1 on: January 15, 2016, 07:14:11 AM »
WOW - That 's what I would like to have also. I spent days to get Bluetooth working on a Cubietruck. It turned out to be hell on earth for me.
I suggest to study how it can be done with Raspian on the Raspberry PI.
There is a lot of information out there. Google keywords "Raspian linux bluetootht Cubieboard aso) I assume it needs to be done via command line.
t(w)o be(ers) or not t(w)o be(ers) that is the question

Offline michiil

  • Newbie
  • *
  • Posts: 21
Re: Bluetooth Keyboard
« Reply #2 on: January 15, 2016, 08:02:35 AM »
I am just now building bluez. So i am pretty close to getting this working (:
I hope i will manage to build a tcz Package for everyone else to download (:

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14850
Re: Bluetooth Keyboard
« Reply #3 on: January 15, 2016, 08:46:44 AM »
I am just now building bluez. So i am pretty close to getting this working

I like that - good luck with the pairing  :)

Offline michiil

  • Newbie
  • *
  • Posts: 21
Re: Bluetooth Keyboard
« Reply #4 on: January 15, 2016, 09:50:25 AM »
Well its not as easy as i thougt..
I could build and install bluez, but when i try to start bluetoothctl it gets stuck and when i abort with ctrl+c i get the following error:
Code: [Select]
[bluetooth]#
process 6321: arguments to dbus_connection_unref() were incorrect, assertion "connection != NULL" failed in file dbus-connection.c line 2821.
This is normally a bug in some application using the D-Bus library.
  D-Bus not built with -rdynamic so unable to print a backtrace
Aborted

I guess i have to try a little more..

EDIT:
Okay after manually starting dbus (sudo /usr/local/etc/init.d/dbus start) bluetoothctl doesn't give an error anymore, but its till stuck.. I have read that this is properly because bleutootd is not running..
The problem is: how do i get it runnign?
« Last Edit: January 15, 2016, 10:13:12 AM by michiil »

Offline michiil

  • Newbie
  • *
  • Posts: 21
Re: Bluetooth Keyboard
« Reply #5 on: January 15, 2016, 10:47:12 AM »
Getting there:
when i am starting the bluetoothd i get:
bluetoothd[7057]: Bluetooth daemon 5.37
bluetoothd[7057]: Starting SDP server
bluetoothd[7057]: Bluetooth management interface 1.9 initialized
bluetoothd[7057]: Failed to obtain handles for "Service Changed" characteristic

maxbe someone knowns what to do?

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14850
Re: Bluetooth Keyboard
« Reply #6 on: January 15, 2016, 10:59:36 AM »
I get this (on corepure64):
Code: [Select]
$ sudo /usr/local/lib/bluetooth/bluetoothd -n
bluetoothd[30609]: Bluetooth daemon 5.28
bluetoothd[30609]: Starting SDP server
bluetoothd[30609]: Bluetooth management interface 1.10 initialized
bluetoothd[30609]: Endpoint registered: sender=:1.67 path=/MediaEndpoint/A2DPSource
bluetoothd[30609]: Endpoint registered: sender=:1.67 path=/MediaEndpoint/A2DPSink

If you use "bluetoothd -nd" you'll get verbose output, which might help

Offline michiil

  • Newbie
  • *
  • Posts: 21
Re: Bluetooth Keyboard
« Reply #7 on: January 15, 2016, 11:45:40 AM »
with -nd i get this:

Code: [Select]
bluetoothd[7221]: Bluetooth daemon 5.37
bluetoothd[7221]: src/adapter.c:adapter_init() sending read version command
bluetoothd[7221]: Starting SDP server
bluetoothd[7221]: src/sdpd-service.c:register_device_id() Adding device id record for 0002:1d6b:0246:0525
bluetoothd[7221]: src/plugin.c:plugin_init() Loading builtin plugins
bluetoothd[7221]: src/plugin.c:add_plugin() Loading hostname plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading wiimote plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading autopair plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading policy plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading a2dp plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading avrcp plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading network plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading input plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading hog plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading gap plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading scanparam plugin
bluetoothd[7221]: src/plugin.c:add_plugin() Loading deviceinfo plugin
bluetoothd[7221]: src/plugin.c:plugin_init() Loading plugins /usr/local/lib/bluetooth/plugins
bluetoothd[7221]: profiles/input/suspend-none.c:suspend_init()
bluetoothd[7221]: profiles/network/manager.c:read_config() Config options: Security=true
bluetoothd[7221]: src/main.c:main() Entering main loop
bluetoothd[7221]: src/rfkill.c:rfkill_event() RFKILL event idx 0 type 2 op 0 soft 0 hard 0
bluetoothd[7221]: Bluetooth management interface 1.9 initialized
bluetoothd[7221]: src/adapter.c:read_version_complete() sending read supported commands command
bluetoothd[7221]: src/adapter.c:read_version_complete() sending read index list command
bluetoothd[7221]: src/adapter.c:read_commands_complete() Number of commands: 61
bluetoothd[7221]: src/adapter.c:read_commands_complete() Number of events: 34
bluetoothd[7221]: src/adapter.c:read_commands_complete() enabling kernel-side connection control
bluetoothd[7221]: src/adapter.c:read_index_list_complete() Number of controllers: 1
bluetoothd[7221]: src/adapter.c:read_index_list_complete() Found index 0
bluetoothd[7221]: src/adapter.c:index_added() index 0
bluetoothd[7221]: src/adapter.c:btd_adapter_new() System name: BlueZ 5.37
bluetoothd[7221]: src/adapter.c:btd_adapter_new() Major class: 0
bluetoothd[7221]: src/adapter.c:btd_adapter_new() Minor class: 0
bluetoothd[7221]: src/adapter.c:btd_adapter_new() Modalias: usb:v1D6Bp0246d0525
bluetoothd[7221]: src/adapter.c:btd_adapter_new() Discoverable timeout: 180 seconds
bluetoothd[7221]: src/adapter.c:btd_adapter_new() Pairable timeout: 0 seconds
bluetoothd[7221]: src/adapter.c:index_added() sending read info command for index 0
bluetoothd[7221]: src/adapter.c:read_info_complete() index 0 status 0x00
bluetoothd[7221]: src/adapter.c:clear_uuids() sending clear uuids command for index 0
bluetoothd[7221]: src/adapter.c:clear_devices() sending clear devices command for index 0
bluetoothd[7221]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10001
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000007-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001800-0000-1000-8000-00805f9
bluetoothd[7221]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[7221]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[7221]: src/gatt-database.c:gatt_db_service_added() GATT Service added to local database
bluetoothd[7221]: Failed to obtain handles for "Service Changed" characteristic
bluetoothd[7221]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10002
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000007-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001801-0000-1000-8000-00805f9
bluetoothd[7221]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[7221]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[7221]: src/gatt-database.c:gatt_db_service_added() GATT Service added to local database
bluetoothd[7221]: profiles/audio/a2dp.c:media_server_probe() path /org/bluez/hci0
bluetoothd[7221]: plugins/hostname.c:hostname_probe()
bluetoothd[7221]: profiles/network/manager.c:panu_server_probe() path /org/bluez/hci0
bluetoothd[7221]: profiles/network/server.c:server_register() Registered interface org.bluez.NetworkServer1 on path /org/bluez/hci0
bluetoothd[7221]: profiles/network/manager.c:gn_server_probe() path /org/bluez/hci0
bluetoothd[7221]: profiles/network/manager.c:nap_server_probe() path /org/bluez/hci0
bluetoothd[7221]: profiles/audio/avrcp.c:avrcp_controller_server_probe() path /org/bluez/hci0
bluetoothd[7221]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10003
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000017-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110e-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110f-0000-1000-8000-00805f9
bluetoothd[7221]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[7221]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[7221]: profiles/audio/avrcp.c:avrcp_target_server_probe() path /org/bluez/hci0
bluetoothd[7221]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10004
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000017-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110c-0000-1000-8000-00805f9
bluetoothd[7221]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110e-0000-1000-8000-00805f9
bluetoothd[7221]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[7221]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[7221]: profiles/audio/a2dp.c:a2dp_sink_server_probe() path /org/bluez/hci0
bluetoothd[7221]: profiles/audio/a2dp.c:a2dp_source_server_probe() path /org/bluez/hci0
bluetoothd[7221]: src/adapter.c:btd_adapter_unblock_address() hci0 00:00:00:00:00:00
bluetoothd[7221]: src/adapter.c:load_link_keys() hci0 keys 0 debug_keys 0
bluetoothd[7221]: src/adapter.c:load_ltks() hci0 keys 0
bluetoothd[7221]: src/adapter.c:load_irks() hci0 irks 0
bluetoothd[7221]: src/adapter.c:load_conn_params() hci0 conn params 0
bluetoothd[7221]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[7221]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[7221]: src/adapter.c:set_did() hci0 source 2 vendor 1d6b product 246 version 525
bluetoothd[7221]: src/adapter.c:adapter_register() Adapter /org/bluez/hci0 registered
bluetoothd[7221]: src/adapter.c:set_dev_class() sending set device class command for index 0
bluetoothd[7221]: src/adapter.c:set_name() sending set local name command for index 0
bluetoothd[7221]: src/adapter.c:load_link_keys_complete() link keys loaded for hci0
bluetoothd[7221]: src/adapter.c:load_ltks_complete() LTKs loaded for hci0
bluetoothd[7221]: src/adapter.c:load_irks_complete() IRKs loaded for hci0
bluetoothd[7221]: src/adapter.c:load_conn_params_complete() Connection Parameters loaded for hci0

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14850
Re: Bluetooth Keyboard
« Reply #8 on: January 15, 2016, 12:28:42 PM »
If bluetoothd didn't exit it might be OK - did you try to pair with something?

Offline michiil

  • Newbie
  • *
  • Posts: 21
Re: Bluetooth Keyboard
« Reply #9 on: January 15, 2016, 12:30:02 PM »
It seems to work anyway (:
I startet bleutoothd in another ssh session so i could pair in mine (:

Code: [Select]
[bluetooth]# pair 00:04:20:F2:46:E6
Attempting to pair with 00:04:20:F2:46:E6
[CHG] Device 00:04:20:F2:46:E6 Connected: yes
[CHG] Device 00:04:20:F2:46:E6 UUIDs: 00001124-0000-1000-8000-00805f9b34fb
[CHG] Device 00:04:20:F2:46:E6 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device 00:04:20:F2:46:E6 UUIDs: 830a5548-5c66-23bd-0949-c0040000227e
[CHG] Device 00:04:20:F2:46:E6 Paired: yes
Pairing successful
[CHG] Device 00:04:20:F2:46:E6 Connected: no
[bluetooth]# trust 00:04:20:F2:46:E6
[CHG] Device 00:04:20:F2:46:E6 Trusted: yes
Changing 00:04:20:F2:46:E6 trust succeeded
[bluetooth]# connect 00:04:20:F2:46:E6
Attempting to connect to 00:04:20:F2:46:E6
[CHG] Device 00:04:20:F2:46:E6 Connected: yes
Connection successful
[Harmony Keyboard]#
« Last Edit: January 15, 2016, 12:56:04 PM by michiil »

Offline michiil

  • Newbie
  • *
  • Posts: 21
Re: Bluetooth Keyboard
« Reply #10 on: January 16, 2016, 04:29:15 AM »
Okay i need some help with the tcz file..
i habe built it but i think i have some permission error..

Code: [Select]
start-stop-daemon: can't execute '/usr/local/libexec/bluetooth/bluetoothd': Permission denied


What permissions and owner should i have on the different files?

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14850
Re: Bluetooth Keyboard
« Reply #11 on: January 16, 2016, 05:31:55 AM »
Did you start/stop bluetoothd as root?

Offline michiil

  • Newbie
  • *
  • Posts: 21
Re: Bluetooth Keyboard
« Reply #12 on: January 16, 2016, 05:41:04 AM »
I took the init.d script from the x86_64 bluez plugin and modified it a bit.. (only the path of bluetoothd really)

Code: [Select]
tc@Wohnzimmer:~$ sudo cat /usr/local/etc/init.d/bluez-5.37
#!/bin/sh

start() {
  if [ ! -f /var/run/dbus/bluez_flag ]; then
    /usr/local/etc/init.d/dbus restart
    touch /var/run/dbus/bluez_flag
  fi
  if ! pidof bluetoothd >/dev/null; then
    start-stop-daemon --start --exec /usr/local/libexec/bluetooth/bluetoothd & 2>/dev/null
  fi
}

stop() {
  start-stop-daemon --stop --exec /usr/local/libexec/bluetooth/bluetoothd 2>/dev/null
  sleep 2
}

status() {
  if pidof bluetoothd >/dev/null; then
    echo -e "\nbluetoothd is running.\n"
    exit 0
  else
    echo -e "\nbluetoothd is not running.\n"
    exit 1
  fi
}

case $1 in
  start) start
    ;;
  stop) stop
    ;;
  status) status
    ;;
  restart) stop; start
    ;;
  *) echo -e "\n$0 [start|stop|restart|status]\n"
    ;;
esac

I tried some commands to start it manually:
Code: [Select]
tc@Wohnzimmer:~$ /usr/local/etc/init.d/bluez-5.37 start
-sh: /usr/local/etc/init.d/bluez-5.37: Permission denied
tc@Wohnzimmer:~$ sudo /usr/local/etc/init.d/bluez-5.37 start
sudo: /usr/local/etc/init.d/bluez-5.37: command not found
tc@Wohnzimmer:~$ sudo sh /usr/local/etc/init.d/bluez-5.37 start
tc@Wohnzimmer:~$ start-stop-daemon: can't execute '/usr/local/libexec/bluetooth/bluetoothd': Permission denied

I am used to debian so i wanted to use service but its not aviable on tinycore so whats the right way to start a init.d script manually?

Also the permissions if it helps:
Code: [Select]
tc@Wohnzimmer:~$ ls -lsa /usr/local/libexec/bluetooth/
total 0
     0 drwxr-xr-x    2 tc       staff           80 Jan 15 20:45 ./
     0 drwxr-xr-x    4 tc       staff          120 Jan 15 20:44 ../
     0 lrwxrwxrwx    1 root     root            61 Jan 15 21:00 bluetoothd -> /tmp/tcloop/bluez-5.37/usr/local/libexec/bluetooth/bluetoothd
     0 lrwxrwxrwx    1 root     root            56 Jan 15 21:00 obexd -> /tmp/tcloop/bluez-5.37/usr/local/libexec/bluetooth/obexd
« Last Edit: January 16, 2016, 05:43:51 AM by michiil »

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14850
Re: Bluetooth Keyboard
« Reply #13 on: January 16, 2016, 06:49:28 AM »
The command should be:
Code: [Select]
$ sudo /usr/local/etc/init.d/bluez start..and you can also use the control panel services gui

It looks like you have a typo somewhere?

Offline michiil

  • Newbie
  • *
  • Posts: 21
Re: Bluetooth Keyboard
« Reply #14 on: January 16, 2016, 07:52:43 AM »
Success!
Code: [Select]
tc@Wohnzimmer:~$ tce-load -i bluez-5.37.tcz
created directory: '/usr/local/etc/bluetooth'
'/usr/local/share/bluez-5.37/files/main.conf' -> '/usr/local/etc/bluetooth/main.conf'
bluez-5.37.tcz: OK
tc@Wohnzimmer:~$ sudo /usr/local/etc/init.d/bluez-5.37 start
no /usr/local/bin/dbus-daemon found; none killed
rm: can't remove '/var/run/dbus/pid': No such file or directory
tc@Wohnzimmer:~$ sudo bluetoothctl
[NEW] Controller 00:15:83:D2:28:ED BlueZ 5.37 [default]
[bluetooth]# power on
Changing power on succeeded
[CHG] Controller 00:15:83:D2:28:ED Powered: yes

I just adjusted all permissions according to the wiki (:

Thanks a lot for your help (: