hcitools_wrapper 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data/lib/hcitools_wrapper.rb +94 -0
- data.tar.gz.sig +2 -0
- metadata +88 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 50e1e641ad84e259b22ee677b9045add9cae7917
|
4
|
+
data.tar.gz: 6af14659f5fa556785a08e2c8aa286ac467ade9e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d4b7e74aec8c194b8203510728ed6820c4094346a256cd3effe2fab3af7cbd5c76a0a048d28318121c74ba8b2f1d22a30cd174b8d24925ba716f3d1c305a0bd
|
7
|
+
data.tar.gz: f4f44d66ad5891e12f7c06e083b96f12ecc547f882ba0d9ad16dd9acb08b6e45fdbd2cabb4c4665a437d2cd49d2711ea8f210a196d38e7bc9c8763474b05ddb4
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: hcitools_wrapper.rb
|
4
|
+
|
5
|
+
require 'run_every'
|
6
|
+
|
7
|
+
|
8
|
+
module HcitoolsWrapper
|
9
|
+
|
10
|
+
class Scan
|
11
|
+
|
12
|
+
# options interval and duration are in seconds
|
13
|
+
#
|
14
|
+
def self.start(runinterval: 10, scanduration: 2)
|
15
|
+
|
16
|
+
RunEvery.new(seconds: runinterval) do
|
17
|
+
pid = spawn("sudo hcitool lescan", :err=>"log")
|
18
|
+
sleep scanduration
|
19
|
+
`sudo hciconfig hci0 reset `
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class Detect
|
27
|
+
|
28
|
+
def initialize(bd_address: '', interval: 0, verbose: false)
|
29
|
+
|
30
|
+
@bd_address = bd_address
|
31
|
+
@interval = interval
|
32
|
+
@verbose = verbose
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def start()
|
37
|
+
|
38
|
+
id = @bd_address.split(':').reverse.join(' ')
|
39
|
+
found = false
|
40
|
+
a = []
|
41
|
+
|
42
|
+
t3 = Time.now + @interval
|
43
|
+
|
44
|
+
IO.popen('sudo hcidump --raw').each_line do |x|
|
45
|
+
|
46
|
+
found = if found then
|
47
|
+
|
48
|
+
rssi = (x.split.last.hex - 256)
|
49
|
+
a << rssi.to_i unless a.include? rssi.to_i
|
50
|
+
h = {bdaddress: @bd_address, rssi: rssi.inspect}
|
51
|
+
|
52
|
+
if t3 < Time.now then
|
53
|
+
|
54
|
+
avg = a.max + (a.min - a.max) / 2
|
55
|
+
|
56
|
+
if @verbose then
|
57
|
+
puts Time.now.inspect + ': ' + h.inspect
|
58
|
+
puts "max: %s, min: %s, average: %s, a: %s" % \
|
59
|
+
[a.max, a.min, avg, a.sort.inspect]
|
60
|
+
puts 'changed!' if avg != a.max + (a.min - a.max) / 2
|
61
|
+
end
|
62
|
+
|
63
|
+
# the RSSI will vary by up to 10 when the device is stationary
|
64
|
+
if a.length > 10 or rssi > (a.max + 10) or rssi < (a.min + 10) then
|
65
|
+
|
66
|
+
if block_given? then
|
67
|
+
yield a, avg
|
68
|
+
end
|
69
|
+
|
70
|
+
a = []
|
71
|
+
end
|
72
|
+
|
73
|
+
t3 = Time.now + @interval
|
74
|
+
end
|
75
|
+
|
76
|
+
false
|
77
|
+
|
78
|
+
else
|
79
|
+
x.include?(id)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
if __FILE__ == $0 then
|
90
|
+
|
91
|
+
hw = HcitoolsWrapper::Scan.start
|
92
|
+
#hw = HcitoolsWrapper::Detect.new bd_address: 'FF:FF:00:00:FD:1D', verbose: true
|
93
|
+
#hw.start
|
94
|
+
end
|
data.tar.gz.sig
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hcitools_wrapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTE1MDcxODE2MjY0MloXDTE2MDcxNzE2MjY0MlowSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
+
ggEBAKj3jDW8rGJH7SIP6GKQWpaEucFlfkvPX4LtuxOJg6hYS57+zUUKO+5GPPHW
|
19
|
+
8XnlMN74sGrwT7dPd7s7hNSIRtxQ1amzYaT590jumOT/gLaOD+0DbqzKIKvfrFpD
|
20
|
+
B+3NSr+6RbJFnVj/cfKWc1E87azMbZ08T2zC9Qc/NZ99qjlQeCE1GCvCtlJqsPVQ
|
21
|
+
mjJP040thzRLYzIHd6P+eQjml/mP7MVtpU628QvUgAVVqMDYxAZnLqS2jL50likE
|
22
|
+
DAvF/K8HmqMAApGxIWxiC61otcO9jcys7uvm4bARP1hfxDdvVvN19L2eI1mR1Z+I
|
23
|
+
IuqnCXIaWh/tUNt2QVzBCqj9Ja0CAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
24
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUEO8gAPWPPEaK267fqLNgUWnOl1cwJgYDVR0RBB8w
|
25
|
+
HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
|
26
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAEYsxYj+C
|
27
|
+
AOi5pasoUX2xKu6Gqnn3i2tUsGmg6Z6uA/0lJtxkmElLoizZaj02yLA/EQpTZ0hN
|
28
|
+
7hXGcP5q8q/mtPACq1ziLCz6s5EQNksatShrTmjsVJCrZmLdMSpAo1ULRveNtfD7
|
29
|
+
Ms9/yasQaopa/tYT8F7TQgDhu00+jxVgvrkZnslJkRaduv1Wk1OhtNH40cWlNEdC
|
30
|
+
Ffv1UR4qqqKFONh5iM3aHQOgYGEeKgTeKCwd9ygtwWbO5840IMvbv+ohVjbQgW9z
|
31
|
+
zUSFf/yp8K6i0NNL6umy/xpv+2v4DFJo/OxVeDHpyyaJnVVKM/70sw8VQZYjiiYU
|
32
|
+
31I/k3v2LBoYwA==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2015-07-18 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: run_every
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.1'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.1.9
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.1'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.1.9
|
56
|
+
description:
|
57
|
+
email: james@r0bertson.co.uk
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/hcitools_wrapper.rb
|
63
|
+
homepage: https://github.com/jrobertson/hcitools_wrapper
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.4.8
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Uses hcitool lescan + hcidump --r to fetch the RSSI values from a Bluetooth
|
87
|
+
device address.
|
88
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|