AP_ADSB: callsign gen should use ICAO in hex

This commit is contained in:
Tom Pittenger 2016-07-12 12:49:45 -07:00
parent 69887e1646
commit 4c9642ac08

View File

@ -203,13 +203,12 @@ void AP_ADSB::update(void)
// if param changed then regenerate. This allows the param to be changed back to zero to trigger a re-generate // if param changed then regenerate. This allows the param to be changed back to zero to trigger a re-generate
if (out_state.cfg.ICAO_id_param == 0) { if (out_state.cfg.ICAO_id_param == 0) {
out_state.cfg.ICAO_id = genICAO(_my_loc); out_state.cfg.ICAO_id = genICAO(_my_loc);
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "ADSB: Generated ICAO_id: %d", out_state.cfg.ICAO_id);
} else { } else {
out_state.cfg.ICAO_id = out_state.cfg.ICAO_id_param; out_state.cfg.ICAO_id = out_state.cfg.ICAO_id_param;
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "ADSB: Using ICAO_id: %d", out_state.cfg.ICAO_id);
} }
out_state.cfg.ICAO_id_param_prev = out_state.cfg.ICAO_id_param; out_state.cfg.ICAO_id_param_prev = out_state.cfg.ICAO_id_param;
set_callsign("PING", true); set_callsign("PING", true);
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "ADSB: Using ICAO_id %d and Callsign %s", out_state.cfg.ICAO_id, out_state.cfg.callsign);
out_state.last_config_ms = 0; // send now out_state.last_config_ms = 0; // send now
} }
@ -645,7 +644,7 @@ void AP_ADSB::set_callsign(const char* str, bool append_icao)
if (append_icao) { if (append_icao) {
char str_icao[5]; char str_icao[5];
sprintf(str_icao, "%4d", out_state.cfg.ICAO_id % 10000); sprintf(str_icao, "%04X", out_state.cfg.ICAO_id % 0x10000);
out_state.cfg.callsign[4] = str_icao[0]; out_state.cfg.callsign[4] = str_icao[0];
out_state.cfg.callsign[5] = str_icao[1]; out_state.cfg.callsign[5] = str_icao[1];
out_state.cfg.callsign[6] = str_icao[2]; out_state.cfg.callsign[6] = str_icao[2];