mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Send mavlink heartbeat every second
This commit is contained in:
parent
2a5ba97b48
commit
c13c7799f6
@ -212,14 +212,14 @@ int mavlink_parse(struct slip_decode_state *state)
|
||||
if (packet_length==9){
|
||||
if (state->mavlink_payload[5]==MAVLINK_MSG_ID_RADIO){
|
||||
// we can assume that radio status packets arrive without corruption
|
||||
last_radio_rssi=(1.0*state->mavlink_payload[6+5]-state->mavlink_payload[6+8])/1.9;
|
||||
last_radio_rssi=(1.0*state->mavlink_payload[10]-state->mavlink_payload[13])/1.9;
|
||||
last_radio_temperature=-999; // doesn't get reported
|
||||
last_radio_rxpackets=-999; // doesn't get reported
|
||||
if (config.debug.mavlink||gettime_ms()-last_rssi_time>30000) {
|
||||
INFOF("Link budget = %+ddB, remote link budget = %+ddB, buffer space = %d",
|
||||
INFOF("Link budget = %+ddB, remote link budget = %+ddB, buffer space = %d%%",
|
||||
last_radio_rssi,
|
||||
(int)((1.0*state->mavlink_payload[6+6]-state->mavlink_payload[6+9])/1.9),
|
||||
state->mavlink_payload[6+7]);
|
||||
(int)((1.0*state->mavlink_payload[11]-state->mavlink_payload[14])/1.9),
|
||||
state->mavlink_payload[12]);
|
||||
last_rssi_time=gettime_ms();
|
||||
}
|
||||
}
|
||||
|
@ -497,9 +497,6 @@ overlay_interface_init(const char *name, struct in_addr src_addr, struct in_addr
|
||||
be safe on the RFD900 radios, and that also allows us to receive RSSI reports inline */
|
||||
interface->slip_decode_state.encapsulator=SLIP_FORMAT_MAVLINK;
|
||||
interface->alarm.poll.events=POLLIN|POLLOUT;
|
||||
// Queue a hearbeat now
|
||||
interface->tx_bytes_pending=0;
|
||||
mavlink_heartbeat(interface->txbuffer,&interface->tx_bytes_pending);
|
||||
watch(&interface->alarm);
|
||||
|
||||
break;
|
||||
@ -734,11 +731,17 @@ static void write_stream_buffer(overlay_interface *interface){
|
||||
int total_written=0;
|
||||
while ((interface->tx_bytes_pending>0 || interface->tx_packet) &&
|
||||
(bytes_allowed>0 || interface->throttle_burst_write_size==0)) {
|
||||
|
||||
if (interface->tx_bytes_pending==0 && interface->tx_packet){
|
||||
// TODO firmware heartbeat packets
|
||||
// prepare a new link layer packet in txbuffer
|
||||
if (mavlink_encode_packet(interface))
|
||||
break;
|
||||
if (interface->next_heartbeat <= now){
|
||||
// Queue a hearbeat now
|
||||
mavlink_heartbeat(interface->txbuffer,&interface->tx_bytes_pending);
|
||||
interface->next_heartbeat = now+1000;
|
||||
}else{
|
||||
// prepare a new link layer packet in txbuffer
|
||||
if (mavlink_encode_packet(interface))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int bytes = interface->tx_bytes_pending;
|
||||
@ -783,8 +786,6 @@ static void write_stream_buffer(overlay_interface *interface){
|
||||
} else {
|
||||
// Nothing to write, so clear POLLOUT flag
|
||||
interface->alarm.poll.events&=~POLLOUT;
|
||||
// try to empty another packet from the queue ASAP
|
||||
overlay_queue_schedule_next(gettime_ms());
|
||||
}
|
||||
watch(&interface->alarm);
|
||||
}
|
||||
|
@ -329,13 +329,12 @@ int overlay_rhizome_saw_advertisements(int i, struct decode_context *context, st
|
||||
WHY("Error parsing manifest body");
|
||||
goto next;
|
||||
}
|
||||
const char *id=alloca_tohex_bid(m->cryptoSignPublic);
|
||||
|
||||
/* trim manifest ID to a prefix for ease of debugging
|
||||
(that is the only use of this */
|
||||
if (config.debug.rhizome_ads){
|
||||
long long version = rhizome_manifest_get_ll(m, "version");
|
||||
DEBUGF("manifest id=%s version=%lld", id, version);
|
||||
DEBUGF("manifest id=%s version=%lld", alloca_tohex_bid(m->cryptoSignPublic), version);
|
||||
}
|
||||
|
||||
/* Crude signature presence test */
|
||||
@ -352,11 +351,10 @@ int overlay_rhizome_saw_advertisements(int i, struct decode_context *context, st
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (rhizome_ignore_manifest_check(m->cryptoSignPublic,
|
||||
crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)){
|
||||
if (rhizome_ignore_manifest_check(m->cryptoSignPublic, RHIZOME_MANIFEST_ID_BYTES)){
|
||||
/* Ignoring manifest that has caused us problems recently */
|
||||
if (config.debug.rhizome_ads)
|
||||
DEBUGF("Ignoring manifest with errors: %s", id);
|
||||
DEBUGF("Ignoring manifest with errors: %s", alloca_tohex_bid(m->cryptoSignPublic));
|
||||
goto next;
|
||||
}
|
||||
|
||||
@ -366,13 +364,13 @@ int overlay_rhizome_saw_advertisements(int i, struct decode_context *context, st
|
||||
/* Don't waste any time on this manifest in future attempts for at least
|
||||
a minute. */
|
||||
rhizome_queue_ignore_manifest(m->cryptoSignPublic,
|
||||
crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES, 60000);
|
||||
RHIZOME_MANIFEST_ID_BYTES, 60000);
|
||||
goto next;
|
||||
}
|
||||
/* Manifest is okay, so see if it is worth storing */
|
||||
|
||||
// are we already fetching this bundle [or later]?
|
||||
rhizome_manifest *mf=rhizome_fetch_search(id, crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES);
|
||||
rhizome_manifest *mf=rhizome_fetch_search(m->cryptoSignPublic, RHIZOME_MANIFEST_ID_BYTES);
|
||||
if (mf && mf->version >= m->version)
|
||||
goto next;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user