scan_beacon 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/lib/scan_beacon/ble112_device.rb +18 -0
- data/lib/scan_beacon/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b97500f1a0b47564be46701c0aa5ae7551ea802f
|
4
|
+
data.tar.gz: 04e4b224e01a2d30b7af811cd6f378486107ab46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf657f7dffc86477efcca6d8821c5386d0d49cd80e023a8e6e41c158f7df32b85dcedc767d2d8558e3b48818d201faaad2a34edeb2ce482897c133f7f37e6214
|
7
|
+
data.tar.gz: 1134b3f84873408a7ade2bef1b1b95b326ace6007fa72260407cf0c2a7150c127a6adce11be953d78080035d0a97ea408e2d67a01396c3167eec62d5b7413954
|
data/.gitignore
CHANGED
data/Gemfile
ADDED
@@ -5,9 +5,11 @@ module ScanBeacon
|
|
5
5
|
BG_COMMAND = 0
|
6
6
|
BG_EVENT = 0x80
|
7
7
|
# msg classes
|
8
|
+
BG_MSG_CLASS_SYSTEM = 0
|
8
9
|
BG_MSG_CLASS_CONNECTION = 3
|
9
10
|
BG_MSG_CLASS_GAP = 6
|
10
11
|
# messages
|
12
|
+
BG_RESET = 0
|
11
13
|
BG_DISCONNECT = 0
|
12
14
|
BG_SET_MODE = 1
|
13
15
|
BG_DISCOVER = 2
|
@@ -23,6 +25,7 @@ module ScanBeacon
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def open
|
28
|
+
configure_port
|
26
29
|
File.open(@port, 'r+b') do |file|
|
27
30
|
@file = file
|
28
31
|
yield self
|
@@ -30,6 +33,12 @@ module ScanBeacon
|
|
30
33
|
@file = nil
|
31
34
|
end
|
32
35
|
|
36
|
+
def configure_port
|
37
|
+
if RUBY_PLATFORM =~ /linux/
|
38
|
+
system("stty -F #{@port} 115200 -brkint -icrnl -imaxbel -opost -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke;min=0")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
33
42
|
def start_scan
|
34
43
|
# disconnect any connections
|
35
44
|
bg_command(@file, BG_MSG_CLASS_CONNECTION, BG_DISCONNECT,0)
|
@@ -51,6 +60,15 @@ module ScanBeacon
|
|
51
60
|
BLE112Response.new( bg_read(@file) )
|
52
61
|
end
|
53
62
|
|
63
|
+
def reset
|
64
|
+
open do
|
65
|
+
@file.write([BG_COMMAND, 1, BG_MSG_CLASS_SYSTEM, BG_RESET, 0].pack('C*'))
|
66
|
+
end
|
67
|
+
# give time for the device to reboot.
|
68
|
+
# TODO: figure out a way that doesn't involve sleeping arbitrarily.
|
69
|
+
sleep 1
|
70
|
+
end
|
71
|
+
|
54
72
|
class BLE112Response
|
55
73
|
def initialize(data)
|
56
74
|
@data = data
|
data/lib/scan_beacon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scan_beacon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radius Networks
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
|
+
- Gemfile
|
63
64
|
- LICENSE.txt
|
64
65
|
- README.md
|
65
66
|
- Rakefile
|