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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60051597c316ed311fb5c3203f5903e62f46e107c2094ae379db5dbf07c8232e
4
- data.tar.gz: 41a4cc508416234557867b3fd0ac8c27c5d856cea90c7531fb99f29106028ec8
3
+ metadata.gz: 05bb146cd01ae909001401030d988ca1e14977d6159c5da9ee81736e66a17540
4
+ data.tar.gz: b9240f153be4b7ca510344f41c94d8ad7bbb8a6dd2f72e41242c18641d772db8
5
5
  SHA512:
6
- metadata.gz: 22d0cf3c237e478f41ed217a67ce07a13e1dea8584142bee797fa7085cbf5e24445758cba5b2d29f7ca2ea50f973e20bb231e6579c50647bf286bb94e935f144
7
- data.tar.gz: 3ce7d04e91583044385715746750f9bfd83dcbd06831a0e38f8c123f57e05fd778c6eaf13e5f9a6d770e85156c8406f7c195eab637a620dc6b5fa99f66ff829f
6
+ metadata.gz: 415ed825c123a9ca66debe50a52e406da5d83310127956fc8f4caba7b28eddfbb679528be081c5449267ae44a6dd9e820bbbf86ea48af8ba2ac66a2f77445bbf
7
+ data.tar.gz: 64c3ade415dc32510a003e7cc41d1a61e532113541fd9de22ab5c4d31d8dfa797e099ff5bc05127ddf256438a1bf35a8461c70ebaf44c738af7fb5735dca0450
@@ -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.
@@ -0,0 +1,7 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ # Namespace placeholder so you can `require 'ant-wireless'`
5
+
6
+ require 'ant'
7
+
data/lib/ant.rb CHANGED
@@ -14,7 +14,6 @@ module Ant
14
14
  # Package version
15
15
  VERSION = '0.0.1'
16
16
 
17
-
18
17
  # A Range for matching valid ANT device numbers
19
18
  VALID_DEVICE_NUMBERS = ( 0...65535 ).freeze
20
19
 
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( mod=Ant::Channel::EventCallbacks )
48
- self.extend( mod )
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
- # data = SecureRandom.bytes( 8 )
83
- # self.log.debug "Sending our own broadcast data: %p." % [ data ]
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
- # def on_event_rx_flag_acknowledged( channel_num, data )
143
- #
144
- # end
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
- # def on_event_rx_acknowledged( channel_num, data )
177
- #
178
- # end
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..8]) ]
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..8]) ]
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.20210715102740
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-07-15 00:00:00.000000000 Z
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