tamashii-bluetooth 0.1.0.beta.1 → 0.1.0.beta.2
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 +4 -4
- data/README.md +1 -1
- data/lib/tamashii/bluetooth/beacon.rb +1 -0
- data/lib/tamashii/bluetooth/beacon/ibeacon.rb +51 -0
- data/lib/tamashii/bluetooth/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: dbc4a56a2f2dc7d712a4ac976e3912c5f181c63d
|
4
|
+
data.tar.gz: b43e6f0208c8eb5a1163add2869174cb9d8042e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7af6e87ddf7562edb8664da781df24e3752b475911f16d3d1f57df405e0d4f5e491fb7992c248aea1b48ebcc6fbee536f181b0c0d2eb9f96829f69fcf8071679
|
7
|
+
data.tar.gz: b3e1a58f29c08a7591f3dce206a7cce895ba19122c57d0bfa71d06a9d1f42d1443c92e2a993fb79d63baba9f1360f6d3edca761e2f2083df5b8f164086f6134b
|
data/README.md
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tamashii
|
4
|
+
module Bluetooth
|
5
|
+
module Beacon
|
6
|
+
# Apple iBeacon
|
7
|
+
class IBeacon < Advertisment
|
8
|
+
attr_reader :uuid, :major, :minior, :measured_power
|
9
|
+
|
10
|
+
def initialize(uuid, major = 0, minior = 0, measured_power = -59)
|
11
|
+
@uuid = uuid.delete('-')
|
12
|
+
@major = major
|
13
|
+
@minior = minior
|
14
|
+
@measured_power = measured_power
|
15
|
+
|
16
|
+
@data = create_data
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_data
|
20
|
+
[
|
21
|
+
frame.length + 5,
|
22
|
+
0xFF, 0x4C, 0x00, 0x02,
|
23
|
+
frame.length,
|
24
|
+
frame
|
25
|
+
].flatten
|
26
|
+
end
|
27
|
+
|
28
|
+
def frame
|
29
|
+
@frame ||= [
|
30
|
+
uuid_hex,
|
31
|
+
int_to_hex(major, 2),
|
32
|
+
int_to_hex(minior, 2),
|
33
|
+
measured_power
|
34
|
+
].flatten
|
35
|
+
end
|
36
|
+
|
37
|
+
def int_to_hex(value, size)
|
38
|
+
value
|
39
|
+
.to_s(16)
|
40
|
+
.rjust(size * 2, '0')
|
41
|
+
.scan(/../)
|
42
|
+
.map(&:hex)
|
43
|
+
end
|
44
|
+
|
45
|
+
def uuid_hex
|
46
|
+
uuid.scan(/../).map(&:hex)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tamashii-bluetooth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.beta.
|
4
|
+
version: 0.1.0.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 蒼時弦也
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- ext/bluetooth/osx/xpc.c
|
122
122
|
- lib/tamashii/bluetooth.rb
|
123
123
|
- lib/tamashii/bluetooth/beacon.rb
|
124
|
+
- lib/tamashii/bluetooth/beacon/ibeacon.rb
|
124
125
|
- lib/tamashii/bluetooth/beacon/line.rb
|
125
126
|
- lib/tamashii/bluetooth/device.rb
|
126
127
|
- lib/tamashii/bluetooth/version.rb
|