@@ 1,16 1,16 @@
# -*- encoding: utf-8 -*-
-# stub: ant-wireless 0.3.0.pre.20210930122511 ruby lib
+# stub: ant-wireless 0.3.0.pre.20211008123124 ruby lib
# stub: ext/ant_ext/extconf.rb
Gem::Specification.new do |s|
s.name = "ant-wireless".freeze
- s.version = "0.3.0.pre.20210930122511"
+ s.version = "0.3.0.pre.20211008123124"
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1".freeze) if s.respond_to? :required_rubygems_version=
s.metadata = { "bug_tracker_uri" => "https://todo.sr.ht/~ged/ruby-ant-wireless", "changelog_uri" => "https://deveiate.org/code/ant-wireless/History_md.html", "documentation_uri" => "https://deveiate.org/code/ant-wireless", "homepage_uri" => "https://sr.ht/~ged/ruby-ant-wireless/", "source_uri" => "https://hg.sr.ht/~ged/ruby-ant-wireless" } if s.respond_to? :metadata=
s.require_paths = ["lib".freeze]
s.authors = ["Michael Granger".freeze, "Mahlon E. Smith".freeze]
- s.date = "2021-09-30"
+ s.date = "2021-10-08"
s.description = "A binding for the ANT ultra-low power wireless protocol via the Garmin USB ANT Stick. ANT can be used to send information wirelessly from one device to another device, in a robust and flexible manner.".freeze
s.email = ["ged@FaerieMUD.org".freeze, "mahlon@martini.nu".freeze]
s.extensions = ["ext/ant_ext/extconf.rb".freeze]
@@ 132,6 132,7 @@ rant_channel_init( VALUE self, VALUE cha
rb_iv_set( self, "@device_number", Qnil );
rb_iv_set( self, "@transmission_type", Qnil );
rb_iv_set( self, "@rf_frequency", Qnil );
+ rb_iv_set( self, "@agility_frequencies", Qnil );
rb_hash_aset( registry, channel_number, self );
@@ 299,6 300,31 @@ rant_channel_set_channel_rf_freq( VALUE
}
+static VALUE
+rant_channet_set_frequency_agility( VALUE self, VALUE freq1, VALUE freq2, VALUE freq3 )
+{
+ rant_channel_t *ptr = rant_get_channel( self );
+ unsigned char ucFreq1 = NUM2CHR( freq1 ),
+ ucFreq2 = NUM2CHR( freq2 ),
+ ucFreq3 = NUM2CHR( freq3 );
+ VALUE frequencies = rb_ary_new_from_args( 3, freq1, freq2, freq3 );
+
+ if ( ucFreq1 > 124 || ucFreq2 > 124 || ucFreq3 > 124 ) {
+ rb_raise( rb_eArgError, "frequencies must be between 0 and 124." );
+ }
+
+ rant_log_obj( self, "info",
+ "Configuring channel %d to use frequency agility on %d, %d, and %d MHz.",
+ ptr->channel_num, ucFreq1 + 2400, ucFreq2 + 2400, ucFreq3 + 2400 );
+ ANT_ConfigFrequencyAgility( ptr->channel_num, ucFreq1, ucFreq2, ucFreq3 );
+
+ rb_ary_freeze( frequencies );
+ rb_iv_set( self, "@agility_frequencies", frequencies );
+
+ return Qtrue;
+}
+
+
/*
@@ 588,12 614,14 @@ init_ant_channel()
rb_attr( rant_cAntChannel, rb_intern("device_type"), 1, 0, 0 );
rb_attr( rant_cAntChannel, rb_intern("transmission_type"), 1, 0, 0 );
rb_attr( rant_cAntChannel, rb_intern("rf_frequency"), 1, 0, 0 );
+ rb_attr( rant_cAntChannel, rb_intern("agility_frequencies"), 1, 0, 0 );
rb_define_method( rant_cAntChannel, "set_channel_id", rant_channel_set_channel_id, -1 );
rb_define_method( rant_cAntChannel, "set_channel_period", rant_channel_set_channel_period, -1 );
rb_define_method( rant_cAntChannel, "set_channel_search_timeout",
rant_channel_set_channel_search_timeout, -1 );
rb_define_method( rant_cAntChannel, "set_channel_rf_freq", rant_channel_set_channel_rf_freq, 1 );
+ rb_define_method( rant_cAntChannel, "set_frequency_agility", rant_channet_set_frequency_agility, 3 );
rb_define_method( rant_cAntChannel, "open", rant_channel_open, -1 );
rb_define_method( rant_cAntChannel, "close", rant_channel_close, -1 );
@@ 48,6 48,8 @@ module Ant::ResponseCallbacks
Ant::Message::MESG_RADIO_TX_POWER_ID => :on_radio_tx_power,
+ Ant::Message::MESG_AUTO_FREQ_CONFIG_ID => :on_auto_freq_config,
+
# :TODO: There are many other MESG_ constants, but I think most or all of
# them are for the serial protocol.
}
@@ 227,6 229,13 @@ module Ant::ResponseCallbacks
end
+ ### Handle on_rx_ext_mesgs_enable response event.
+ def on_auto_freq_config( channel_num, data )
+ self.log_response_event( channel_num, data, "enabling frequency agility",
+ "Enabled frequency agility." )
+ end
+
+
### Handle capabilities response event.
def on_capabilities( channel_num, data )
std_opts = Ant::BitVector.new( data.bytes[2] )