Browse Source

GCS_MAVLink: add route mask for blocking MAVlink forwading

mission-4.1.18
proficnc 9 years ago committed by Andrew Tridgell
parent
commit
c8b3c527f9
  1. 5
      libraries/GCS_MAVLink/GCS.h
  2. 3
      libraries/GCS_MAVLink/MAVLink_routing.cpp
  3. 5
      libraries/GCS_MAVLink/MAVLink_routing.h

5
libraries/GCS_MAVLink/GCS.h

@ -186,6 +186,11 @@ public:
*/ */
static void send_to_components(const mavlink_message_t* msg) { routing.send_to_components(msg); } static void send_to_components(const mavlink_message_t* msg) { routing.send_to_components(msg); }
/*
allow forwarding of packets / heartbeats to be blocked as required by some components to reduce traffic
*/
static void disable_channel_routing(mavlink_channel_t chan) { routing.no_route_mask |= (1U<<(chan-MAVLINK_COMM_0)); }
/* /*
search for a component in the routing table with given mav_type and retrieve it's sysid, compid and channel search for a component in the routing table with given mav_type and retrieve it's sysid, compid and channel
returns if a matching component is found returns if a matching component is found

3
libraries/GCS_MAVLink/MAVLink_routing.cpp

@ -259,6 +259,9 @@ void MAVLink_routing::handle_heartbeat(mavlink_channel_t in_channel, const mavli
// the routing table is full // the routing table is full
mask &= ~(1U<<(in_channel-MAVLINK_COMM_0)); mask &= ~(1U<<(in_channel-MAVLINK_COMM_0));
// mask out channels that do not want the heartbeat to be forwarded
mask &= ~no_route_mask;
// mask out channels that are known sources for this sysid/compid // mask out channels that are known sources for this sysid/compid
for (uint8_t i=0; i<num_routes; i++) { for (uint8_t i=0; i<num_routes; i++) {
if (routes[i].sysid == msg->sysid && routes[i].compid == msg->compid) { if (routes[i].sysid == msg->sysid && routes[i].compid == msg->compid) {

5
libraries/GCS_MAVLink/MAVLink_routing.h

@ -17,6 +17,8 @@
*/ */
class MAVLink_routing class MAVLink_routing
{ {
friend class GCS_MAVLINK;
public: public:
MAVLink_routing(void); MAVLink_routing(void);
@ -52,6 +54,9 @@ private:
uint8_t mavtype; uint8_t mavtype;
} routes[MAVLINK_MAX_ROUTES]; } routes[MAVLINK_MAX_ROUTES];
// a channel mask to block routing as required
uint8_t no_route_mask;
// learn new routes // learn new routes
void learn_route(mavlink_channel_t in_channel, const mavlink_message_t* msg); void learn_route(mavlink_channel_t in_channel, const mavlink_message_t* msg);

Loading…
Cancel
Save