Skip to content

flajann2/ruby-ble

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Bluetooth Low Energy for Ruby

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%