ant-wireless 0.1.0.pre.20210715102740 → 0.1.0.pre.20210810141303
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/ant_ext/ant_ext.c +1 -1
- data/lib/ant-wireless.rb +7 -0
- data/lib/ant.rb +0 -1
- data/lib/ant/channel.rb +2 -3
- data/lib/ant/channel/event_callbacks.rb +25 -16
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05bb146cd01ae909001401030d988ca1e14977d6159c5da9ee81736e66a17540
|
4
|
+
data.tar.gz: b9240f153be4b7ca510344f41c94d8ad7bbb8a6dd2f72e41242c18641d772db8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 415ed825c123a9ca66debe50a52e406da5d83310127956fc8f4caba7b28eddfbb679528be081c5449267ae44a6dd9e820bbbf86ea48af8ba2ac66a2f77445bbf
|
7
|
+
data.tar.gz: 64c3ade415dc32510a003e7cc41d1a61e532113541fd9de22ab5c4d31d8dfa797e099ff5bc05127ddf256438a1bf35a8461c70ebaf44c738af7fb5735dca0450
|
data/ext/ant_ext/ant_ext.c
CHANGED
@@ -490,7 +490,7 @@ Init_ant_ext()
|
|
490
490
|
/*
|
491
491
|
* Document-module: Ant
|
492
492
|
*
|
493
|
-
* This is an extension for using the ANT ultra-low power wireless protocol via
|
493
|
+
* This is an extension for using the ANT ultra-low power wireless protocol via
|
494
494
|
* the Garmin USB ANT Stick. ANT can be used to send information
|
495
495
|
* wirelessly from one device to another device, in a robust and flexible
|
496
496
|
* manner.
|
data/lib/ant-wireless.rb
ADDED
data/lib/ant.rb
CHANGED
data/lib/ant/channel.rb
CHANGED
@@ -44,9 +44,8 @@ class Ant::Channel
|
|
44
44
|
|
45
45
|
|
46
46
|
### Set up the given +mod+ as the handler module for channel events.
|
47
|
-
def set_event_handlers(
|
48
|
-
self.
|
49
|
-
self.on_event( &self.method(:handle_event_callback) )
|
47
|
+
def set_event_handlers( object=Ant::Channel::EventCallbacks )
|
48
|
+
self.on_event( &object.method(:handle_event_callback) )
|
50
49
|
end
|
51
50
|
|
52
51
|
|
@@ -62,6 +62,10 @@ module Ant::Channel::EventCallbacks
|
|
62
62
|
end
|
63
63
|
|
64
64
|
|
65
|
+
###############
|
66
|
+
module_function
|
67
|
+
###############
|
68
|
+
|
65
69
|
### Default callback hook -- handles event callbacks.
|
66
70
|
def handle_event_callback( channel_num, event_id, data )
|
67
71
|
handler_method = HANDLER_METHODS[ event_id ] or
|
@@ -78,10 +82,9 @@ module Ant::Channel::EventCallbacks
|
|
78
82
|
### Handle an TX event.
|
79
83
|
def on_event_tx( channel_num, data )
|
80
84
|
# self.log.info "Broadcast message on channel %d was transmitted." % [ channel_num ]
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
# self.send_broadcast_data( data )
|
85
|
+
data = SecureRandom.bytes( 8 )
|
86
|
+
self.log.info "Sending our own broadcast data: \n%s" % [ hexdump(data) ]
|
87
|
+
self.send_broadcast_data( data )
|
85
88
|
end
|
86
89
|
|
87
90
|
|
@@ -139,11 +142,20 @@ module Ant::Channel::EventCallbacks
|
|
139
142
|
end
|
140
143
|
|
141
144
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
+
def on_event_rx_flag_acknowledged( channel_num, data )
|
146
|
+
flags = data.bytes[ 9 ]
|
147
|
+
if flags & Ant::ANT_EXT_MESG_BITFIELD_DEVICE_ID
|
148
|
+
usDeviceNumber = data.bytes[10] | (data.bytes[11] << 8)
|
149
|
+
ucDeviceType = data.bytes[12]
|
150
|
+
ucTransmissionType = data.bytes[13]
|
151
|
+
self.log.info "Got an acknowledge on Chan ID(%d/%d/%d)" %
|
152
|
+
[usDeviceNumber, ucDeviceType, ucTransmissionType]
|
153
|
+
end
|
154
|
+
|
155
|
+
self.on_event_rx_acknowledged( channel_num, data )
|
156
|
+
end
|
157
|
+
|
145
158
|
|
146
|
-
### Handle an RX_FLAG_BURST_PACKET event.
|
147
159
|
def on_event_rx_flag_burst_packet( channel_num, data )
|
148
160
|
flags = data.bytes[ 9 ]
|
149
161
|
if flags & Ant::ANT_EXT_MESG_BITFIELD_DEVICE_ID
|
@@ -158,7 +170,6 @@ module Ant::Channel::EventCallbacks
|
|
158
170
|
end
|
159
171
|
|
160
172
|
|
161
|
-
### Handle an RX_FLAG_BROADCAST event.
|
162
173
|
def on_event_rx_flag_broadcast( channel_num, data )
|
163
174
|
flags = data.bytes[ 9 ]
|
164
175
|
if flags & Ant::ANT_EXT_MESG_BITFIELD_DEVICE_ID
|
@@ -173,23 +184,21 @@ module Ant::Channel::EventCallbacks
|
|
173
184
|
end
|
174
185
|
|
175
186
|
|
176
|
-
|
177
|
-
|
178
|
-
|
187
|
+
def on_event_rx_acknowledged( channel_num, data )
|
188
|
+
self.log.info "Acknowledged: Rx:\n%s" % [ hexdump(data[1..9]) ]
|
189
|
+
end
|
179
190
|
|
180
191
|
|
181
|
-
### Handle an RX_BURST_PACKET event.
|
182
192
|
def on_event_rx_burst_packet( channel_num, data )
|
183
193
|
channel = (data.bytes[0] & CHANNEL_NUMBER_MASK) >> 5
|
184
194
|
sequence_num = data.bytes[0] & SEQUENCE_NUMBER_MASK
|
185
195
|
|
186
|
-
self.log.info "Burst (0x%02x): Rx: %d:\n%s" % [ channel, sequence_num, hexdump(data[1..
|
196
|
+
self.log.info "Burst (0x%02x): Rx: %d:\n%s" % [ channel, sequence_num, hexdump(data[1..9]) ]
|
187
197
|
end
|
188
198
|
|
189
199
|
|
190
|
-
### Handle an RX_BROADCAST event.
|
191
200
|
def on_event_rx_broadcast( channel_num, data )
|
192
|
-
self.log.info "Broadcast: Rx:\n%s" % [ hexdump(data[1..
|
201
|
+
self.log.info "Broadcast: Rx:\n%s" % [ hexdump(data[1..9]) ]
|
193
202
|
end
|
194
203
|
|
195
204
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ant-wireless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.20210810141303
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-08-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- ext/ant_ext/message.c
|
66
66
|
- ext/ant_ext/types.h
|
67
67
|
- ext/ant_ext/version.h
|
68
|
+
- lib/ant-wireless.rb
|
68
69
|
- lib/ant.rb
|
69
70
|
- lib/ant/channel.rb
|
70
71
|
- lib/ant/channel/event_callbacks.rb
|