A module that handles response callbacks by logging them.
Mapping of response message IDs to handler methods
Log the response event by default.
# File lib/ant/response_callbacks.rb, line 110
def self::log_response_callback( channel_num, handler_method, message_id, data )
self.log.debug "Response for channel %d: %#0x (%s): %s" % [
channel_num,
message_id,
handler_method,
data.bytes[ 0..3 ].map {|b| "%#02x" % b }.join( ' ' )
]
end
Default callback hook – handles response callbacks.
# File lib/ant/response_callbacks.rb, line 97
def handle_response_callback( channel_num, message_id, data )
handler_method = HANDLER_METHODS[ message_id ] or
raise "Unhandled response message ID %p" % [ message_id ]
if self.respond_to?( handler_method )
self.public_send( handler_method, channel_num, data )
else
Ant::ResponseCallbacks.log_response_callback( channel_num, handler_method, message_id, data )
end
end
Log a success or an error message for a response event message.
# File lib/ant/response_callbacks.rb, line 204
def log_response_event( channel_num, data, err_desc, log_desc )
status = data.bytes[ 2 ]
if status.nonzero?
self.log.error "Error while %s: %#02x" % [ err_desc, status ]
else
self.log.info( log_desc )
end
end
Handle acknowledged_data response event.
# File lib/ant/response_callbacks.rb, line 257
def on_acknowledged_data( channel_num, data )
self.log_response_event( channel_num, data, "acknowledged_data", "Channel assigned." )
end
Handle active_search_sharing response event.
# File lib/ant/response_callbacks.rb, line 515
def on_active_search_sharing( channel_num, data )
self.log_response_event( channel_num, data, "active_search_sharing", "Channel assigned." )
end
Handle adv_burst_data response event.
# File lib/ant/response_callbacks.rb, line 437
def on_adv_burst_data( channel_num, data )
self.log_response_event( channel_num, data, "adv_burst_data", "Channel assigned." )
end
Handle antlib_config response event.
# File lib/ant/response_callbacks.rb, line 419
def on_antlib_config( channel_num, data )
self.log_response_event( channel_num, data, "antlib_config", "Channel assigned." )
end
Handle channel assignment event response messages.
# File lib/ant/response_callbacks.rb, line 167
def on_assign_channel( channel_num, data )
self.log_response_event( channel_num, data, "assigning channel", "Channel assigned." )
end
Handle auto_freq_config response event.
# File lib/ant/response_callbacks.rb, line 425
def on_auto_freq_config( channel_num, data )
self.log_response_event( channel_num, data, "auto_freq_config", "Channel assigned." )
end
Handle broadcast_data response event.
# File lib/ant/response_callbacks.rb, line 251
def on_broadcast_data( channel_num, data )
self.log_response_event( channel_num, data, "broadcast_data", "Channel assigned." )
end
Handle burst_data response event.
# File lib/ant/response_callbacks.rb, line 263
def on_burst_data( channel_num, data )
self.log_response_event( channel_num, data, "burst_data", "Channel assigned." )
end
Handle capabilities response event.
# File lib/ant/response_callbacks.rb, line 281
def on_capabilities( channel_num, data )
self.log_response_event( channel_num, data, "capabilities", "Channel assigned." )
end
Handle channel ID event response messages.
# File lib/ant/response_callbacks.rb, line 179
def on_channel_id( channel_num, data )
self.log_response_event( channel_num, data, "setting channel ID", "Channel ID set." )
end
Handle channel_mesg_period response events.
# File lib/ant/response_callbacks.rb, line 215
def on_channel_mesg_period( channel_num, data )
self.log_response_event( channel_num, data, "channel_mesg_period", "Channel period assigned." )
end
Handle redio frequency event response messages.
# File lib/ant/response_callbacks.rb, line 185
def on_channel_radio_freq( channel_num, data )
self.log_response_event( channel_num, data, "setting channel radio frequency",
"Channel radio frequency set." )
end
Handle channel_radio_tx_power response event.
# File lib/ant/response_callbacks.rb, line 359
def on_channel_radio_tx_power( channel_num, data )
self.log_response_event( channel_num, data, "channel_radio_tx_power", "Channel assigned." )
end
Handle channel_search_timeout response event.
# File lib/ant/response_callbacks.rb, line 221
def on_channel_search_timeout( channel_num, data )
self.log_response_event( channel_num, data, "channel_search_timeout", "Channel assigned." )
end
Handle channel_status response event.
# File lib/ant/response_callbacks.rb, line 269
def on_channel_status( channel_num, data )
self.log_response_event( channel_num, data, "channel_status", "Channel assigned." )
end
Handle channel close event response messages.
# File lib/ant/response_callbacks.rb, line 198
def on_close_channel( channel_num, data )
self.log_response_event( channel_num, data, "closing channel", "Channel closed." )
end
Handle config_adv_burst response event.
# File lib/ant/response_callbacks.rb, line 461
def on_config_adv_burst( channel_num, data )
self.log_response_event( channel_num, data, "config_adv_burst", "Channel assigned." )
end
Handle crypto_id_list_add response event.
# File lib/ant/response_callbacks.rb, line 311
def on_crypto_id_list_add( channel_num, data )
self.log_response_event( channel_num, data, "crypto_id_list_add", "Channel assigned." )
end
Handle crypto_id_list_config response event.
# File lib/ant/response_callbacks.rb, line 323
def on_crypto_id_list_config( channel_num, data )
self.log_response_event( channel_num, data, "crypto_id_list_config", "Channel assigned." )
end
Handle cube_cmd response event.
# File lib/ant/response_callbacks.rb, line 509
def on_cube_cmd( channel_num, data )
self.log_response_event( channel_num, data, "cube_cmd", "Channel assigned." )
end
Handle enable_led_flash response event.
# File lib/ant/response_callbacks.rb, line 407
def on_enable_led_flash( channel_num, data )
self.log_response_event( channel_num, data, "enable_led_flash", "Channel assigned." )
end
Handle encrypt_enable response event.
# File lib/ant/response_callbacks.rb, line 491
def on_encrypt_enable( channel_num, data )
self.log_response_event( channel_num, data, "encrypt_enable", "Channel assigned." )
end
Handle event_buffering_config response event.
# File lib/ant/response_callbacks.rb, line 443
def on_event_buffering_config( channel_num, data )
self.log_response_event( channel_num, data, "event_buffering_config", "Channel assigned." )
end
Handle event_filter_config response event.
# File lib/ant/response_callbacks.rb, line 467
def on_event_filter_config( channel_num, data )
self.log_response_event( channel_num, data, "event_filter_config", "Channel assigned." )
end
Handle ext_acknowledged_data response event.
# File lib/ant/response_callbacks.rb, line 347
def on_ext_acknowledged_data( channel_num, data )
self.log_response_event( channel_num, data, "ext_acknowledged_data", "Channel assigned." )
end
Handle ext_broadcast_data response event.
# File lib/ant/response_callbacks.rb, line 341
def on_ext_broadcast_data( channel_num, data )
self.log_response_event( channel_num, data, "ext_broadcast_data", "Channel assigned." )
end
Handle ext_burst_data response event.
# File lib/ant/response_callbacks.rb, line 353
def on_ext_burst_data( channel_num, data )
self.log_response_event( channel_num, data, "ext_burst_data", "Channel assigned." )
end
Handle ext_channel_radio_freq_id response event.
# File lib/ant/response_callbacks.rb, line 335
def on_ext_channel_radio_freq_id( channel_num, data )
self.log_response_event( channel_num, data, "ext_channel_radio_freq_id", "Channel assigned." )
end
Handle get_serial_num response event.
# File lib/ant/response_callbacks.rb, line 365
def on_get_serial_num( channel_num, data )
self.log_response_event( channel_num, data, "get_serial_num", "Channel assigned." )
end
Handle get_temp_cal response event.
# File lib/ant/response_callbacks.rb, line 371
def on_get_temp_cal( channel_num, data )
self.log_response_event( channel_num, data, "get_temp_cal", "Channel assigned." )
end
Handle high_duty_search_mode response event.
# File lib/ant/response_callbacks.rb, line 455
def on_high_duty_search_mode( channel_num, data )
self.log_response_event( channel_num, data, "high_duty_search_mode", "Channel assigned." )
end
Handle id_list_add response event.
# File lib/ant/response_callbacks.rb, line 305
def on_id_list_add( channel_num, data )
self.log_response_event( channel_num, data, "id_list_add", "Channel assigned." )
end
Handle id_list_config response event.
# File lib/ant/response_callbacks.rb, line 317
def on_id_list_config( channel_num, data )
self.log_response_event( channel_num, data, "id_list_config", "Channel assigned." )
end
Handle network key event response messages.
# File lib/ant/response_callbacks.rb, line 161
def on_network_key( channel_num, data )
self.log_response_event( channel_num, data, "setting network key", "Network key set" )
end
Handle nvm_crypto_key_ops response event.
# File lib/ant/response_callbacks.rb, line 521
def on_nvm_crypto_key_ops( channel_num, data )
self.log_response_event( channel_num, data, "nvm_crypto_key_ops", "Channel assigned." )
end
Handle channel open event response messages.
# File lib/ant/response_callbacks.rb, line 192
def on_open_channel( channel_num, data )
self.log_response_event( channel_num, data, "opening channel", "Channel opened." )
end
Handle open_rx_scan response event.
# File lib/ant/response_callbacks.rb, line 329
def on_open_rx_scan( channel_num, data )
self.log_response_event( channel_num, data, "open_rx_scan", "Channel assigned." )
end
Handle prox_search_config response event.
# File lib/ant/response_callbacks.rb, line 431
def on_prox_search_config( channel_num, data )
self.log_response_event( channel_num, data, "prox_search_config", "Channel assigned." )
end
Handle radio_config_always response event.
# File lib/ant/response_callbacks.rb, line 401
def on_radio_config_always( channel_num, data )
self.log_response_event( channel_num, data, "radio_config_always", "Channel assigned." )
end
Handle radio_cw_init response event.
# File lib/ant/response_callbacks.rb, line 275
def on_radio_cw_init( channel_num, data )
self.log_response_event( channel_num, data, "radio_cw_init", "Channel assigned." )
end
Handle radio_cw_mode response event.
# File lib/ant/response_callbacks.rb, line 233
def on_radio_cw_mode( channel_num, data )
self.log_response_event( channel_num, data, "radio_cw_mode", "Channel assigned." )
end
Handle radio_tx_power response event.
# File lib/ant/response_callbacks.rb, line 227
def on_radio_tx_power( channel_num, data )
self.log_response_event( channel_num, data, "radio_tx_power", "Channel assigned." )
end
Handle request response event.
# File lib/ant/response_callbacks.rb, line 245
def on_request( channel_num, data )
self.log_response_event( channel_num, data, "request", "Channel assigned." )
end
Handle event response messages.
# File lib/ant/response_callbacks.rb, line 131
def on_response_event( channel_num, data )
response_event = data.bytes[ 1 ]
self.handle_response_callback( channel_num, response_event, data )
end
Handle rx_ext_mesgs_enable response event.
# File lib/ant/response_callbacks.rb, line 395
def on_rx_ext_mesgs_enable( channel_num, data )
self.log_response_event( channel_num, data, "rx_ext_mesgs_enable", "Channel assigned." )
end
Handle script_cmd response event.
# File lib/ant/response_callbacks.rb, line 299
def on_script_cmd( channel_num, data )
self.log_response_event( channel_num, data, "script_cmd", "Channel assigned." )
end
Handle script_data response event.
# File lib/ant/response_callbacks.rb, line 293
def on_script_data( channel_num, data )
self.log_response_event( channel_num, data, "script_data", "Channel assigned." )
end
Handle sdu_config response event.
# File lib/ant/response_callbacks.rb, line 473
def on_sdu_config( channel_num, data )
self.log_response_event( channel_num, data, "sdu_config", "Channel assigned." )
end
Handle sdu_set_mask response event.
# File lib/ant/response_callbacks.rb, line 479
def on_sdu_set_mask( channel_num, data )
self.log_response_event( channel_num, data, "sdu_set_mask", "Channel assigned." )
end
Handle serial_num_set_channel_id response event.
# File lib/ant/response_callbacks.rb, line 389
def on_serial_num_set_channel_id( channel_num, data )
self.log_response_event( channel_num, data, "serial_num_set_channel_id", "Channel assigned." )
end
Handle set_crypto_info response event.
# File lib/ant/response_callbacks.rb, line 503
def on_set_crypto_info( channel_num, data )
self.log_response_event( channel_num, data, "set_crypto_info", "Channel assigned." )
end
Handle set_crypto_key response event.
# File lib/ant/response_callbacks.rb, line 497
def on_set_crypto_key( channel_num, data )
self.log_response_event( channel_num, data, "set_crypto_key", "Channel assigned." )
end
Handle set_lp_search_timeout response event.
# File lib/ant/response_callbacks.rb, line 377
def on_set_lp_search_timeout( channel_num, data )
self.log_response_event( channel_num, data, "set_lp_search_timeout", "Channel assigned." )
end
Handle set_search_ch_priority response event.
# File lib/ant/response_callbacks.rb, line 449
def on_set_search_ch_priority( channel_num, data )
self.log_response_event( channel_num, data, "set_search_ch_priority", "Channel assigned." )
end
Handle set_tx_search_on_next response event.
# File lib/ant/response_callbacks.rb, line 383
def on_set_tx_search_on_next( channel_num, data )
self.log_response_event( channel_num, data, "set_tx_search_on_next", "Channel assigned." )
end
Handle stacklimit response event.
# File lib/ant/response_callbacks.rb, line 287
def on_stacklimit( channel_num, data )
self.log_response_event( channel_num, data, "stacklimit", "Channel assigned." )
end
Handle startup response messages.
# File lib/ant/response_callbacks.rb, line 138
def on_startup_mesg( channel_num, data )
reason = case data.bytes[ 0 ]
when Ant::RESET_POR
"RESET_POR"
when Ant::RESET_SUSPEND
"RESET_SUSPEND "
when Ant::RESET_SYNC
"RESET_SYNC "
when Ant::RESET_CMD
"RESET_CMD "
when Ant::RESET_WDT
"RESET_WDT "
when Ant::RESET_RST
"RESET_RST "
else
"UNKNOWN REASON"
end
self.log.info "Reset complete: %s" % [ reason ]
end
Handle system_reset response event.
# File lib/ant/response_callbacks.rb, line 239
def on_system_reset( channel_num, data )
self.log_response_event( channel_num, data, "system_reset", "Channel assigned." )
end
Handle channel unassignment event response messages.
# File lib/ant/response_callbacks.rb, line 173
def on_unassign_channel
self.log_response_event( channel_num, data, "unassigning channel", "Channel unassigned." )
end
Handle user_config_page response event.
# File lib/ant/response_callbacks.rb, line 485
def on_user_config_page( channel_num, data )
self.log_response_event( channel_num, data, "user_config_page", "Channel assigned." )
end
Handle version number response messages.
# File lib/ant/response_callbacks.rb, line 125
def on_version( channel_num, data )
self.log.info "ANT Version %s" % [ data ]
end
Handle xtal_enable response event.
# File lib/ant/response_callbacks.rb, line 413
def on_xtal_enable( channel_num, data )
self.log_response_event( channel_num, data, "xtal_enable", "Channel assigned." )
end