Project

sb-ble

0.0
No commit activity in last 3 years
No release in over 3 years
This supports LE Advertising
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

sb-ble

Bluetooth Low Energy for Ruby – Sensorberg Version:

[[https://badge.fury.io/rb/ble][https://badge.fury.io/rb/ble.svg]]

NOTE WELL: THIS IS UNDER DEVELOPMENT RIGHT NOW AND NOT YET READY FOR SERIOUS USE

Prelimaries

This is a fork of a fork. More features are being added here, such as support for advertising.

Requirements

  • ruby >= 2.3
  • Dbus
  • bluez >= 5.36 (available on debian testing)
  • bluetoothd started with option -E (experimental)

Examples

# Selecter adapter
$a = BLE::Adapter.new('hci0')
puts "Info: #{$a.iface} #{$a.address} #{$a.name}"

# Run discovery
$a.start_discovery
sleep(2)
$a.stop_discovery

# Get device and connect to it
$d = $a['F4:AD:CB:FB:B4:85']
$d.connect

# Get temperature from the environmental sensing service
$d[:environmental_sensing, :temperature]

# Dump device information
srv = :device_information
$d.characteristics(srv).each {|uuid|
    info  = BLE::Characteristic[uuid]
    name  = info.nil? ? uuid : info[:name]
    value = $d[srv, uuid] rescue '/!\\ not-readable /!\\'
    puts "%-30s: %s" % [ name, value ]
}

Contributors

  • Fred Mitchell (Sensorberg GmbH) LE Advertisement support
  • Oliver Valls (tramuntanal): Bug fixes / BLE Notification support
  • Stephane D’Alu