diff --git a/libraries/AP_Beacon/AP_Beacon.cpp b/libraries/AP_Beacon/AP_Beacon.cpp index 4491ff3556..23c8e21724 100644 --- a/libraries/AP_Beacon/AP_Beacon.cpp +++ b/libraries/AP_Beacon/AP_Beacon.cpp @@ -14,6 +14,9 @@ */ #include "AP_Beacon.h" + +#if AP_BEACON_ENABLED + #include "AP_Beacon_Backend.h" #include "AP_Beacon_Pozyx.h" #include "AP_Beacon_Marvelmind.h" @@ -426,3 +429,5 @@ AP_Beacon *beacon() } } + +#endif diff --git a/libraries/AP_Beacon/AP_Beacon.h b/libraries/AP_Beacon/AP_Beacon.h index 6cb02b91c8..be7766d422 100644 --- a/libraries/AP_Beacon/AP_Beacon.h +++ b/libraries/AP_Beacon/AP_Beacon.h @@ -14,6 +14,10 @@ */ #pragma once +#include "AP_Beacon_config.h" + +#if AP_BEACON_ENABLED + #include #include #include @@ -148,3 +152,5 @@ private: namespace AP { AP_Beacon *beacon(); }; + +#endif // AP_BEACON_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_Backend.cpp b/libraries/AP_Beacon/AP_Beacon_Backend.cpp index 66ec41c230..ee2bb0c0b2 100644 --- a/libraries/AP_Beacon/AP_Beacon_Backend.cpp +++ b/libraries/AP_Beacon/AP_Beacon_Backend.cpp @@ -14,6 +14,9 @@ */ #include "AP_Beacon_Backend.h" + +#if AP_BEACON_ENABLED + // debug #include #include @@ -105,3 +108,5 @@ Vector3f AP_Beacon_Backend::correct_for_orient_yaw(const Vector3f &vector) vec_rotated.z = vector.z; return vec_rotated; } + +#endif // AP_BEACON_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_Backend.h b/libraries/AP_Beacon/AP_Beacon_Backend.h index b1355615b8..118faa6f8d 100644 --- a/libraries/AP_Beacon/AP_Beacon_Backend.h +++ b/libraries/AP_Beacon/AP_Beacon_Backend.h @@ -14,10 +14,13 @@ */ #pragma once +#include "AP_Beacon.h" + +#if AP_BEACON_ENABLED + #include #include #include -#include "AP_Beacon.h" class AP_Beacon_Backend { @@ -62,3 +65,5 @@ protected: AP_HAL::UARTDriver *uart; }; + +#endif // AP_BEACON_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_Marvelmind.cpp b/libraries/AP_Beacon/AP_Beacon_Marvelmind.cpp index 97a81212ea..423f383135 100644 --- a/libraries/AP_Beacon/AP_Beacon_Marvelmind.cpp +++ b/libraries/AP_Beacon/AP_Beacon_Marvelmind.cpp @@ -18,9 +18,12 @@ April 2017 */ +#include "AP_Beacon_Marvelmind.h" + +#if AP_BEACON_MARVELMIND_ENABLED + #include #include -#include "AP_Beacon_Marvelmind.h" #define AP_BEACON_MARVELMIND_POSITION_DATAGRAM_ID 0x0001 #define AP_BEACON_MARVELMIND_POSITIONS_DATAGRAM_ID 0x0002 @@ -386,3 +389,5 @@ void AP_Beacon_Marvelmind::order_stationary_beacons() } while(swapped); } } + +#endif // AP_BEACON_MARVELMIND_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_Marvelmind.h b/libraries/AP_Beacon/AP_Beacon_Marvelmind.h index ca4db7ebc7..eaa79e23d3 100644 --- a/libraries/AP_Beacon/AP_Beacon_Marvelmind.h +++ b/libraries/AP_Beacon/AP_Beacon_Marvelmind.h @@ -22,6 +22,8 @@ #include "AP_Beacon_Backend.h" +#if AP_BEACON_MARVELMIND_ENABLED + #define AP_BEACON_MARVELMIND_BUF_SIZE 255 class AP_Beacon_Marvelmind : public AP_Beacon_Backend @@ -101,3 +103,4 @@ private: bool beacon_position_initialized; }; +#endif // AP_BEACON_MARVELMIND_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_Nooploop.cpp b/libraries/AP_Beacon/AP_Beacon_Nooploop.cpp index 2bd1d819b9..6ddbe8aac3 100644 --- a/libraries/AP_Beacon/AP_Beacon_Nooploop.cpp +++ b/libraries/AP_Beacon/AP_Beacon_Nooploop.cpp @@ -13,9 +13,12 @@ along with this program. If not, see . */ +#include "AP_Beacon_Nooploop.h" + +#if AP_BEACON_NOOPLOOP_ENABLED + #include #include -#include "AP_Beacon_Nooploop.h" #include #include @@ -248,3 +251,5 @@ void AP_Beacon_Nooploop::parse_setting_frame0() } _anchor_pos_avail = true; } + +#endif // AP_BEACON_NOOPLOOP_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_Nooploop.h b/libraries/AP_Beacon/AP_Beacon_Nooploop.h index ab42713e0c..e903eb47fb 100644 --- a/libraries/AP_Beacon/AP_Beacon_Nooploop.h +++ b/libraries/AP_Beacon/AP_Beacon_Nooploop.h @@ -2,6 +2,8 @@ #include "AP_Beacon_Backend.h" +#if AP_BEACON_NOOPLOOP_ENABLED + #define NOOPLOOP_MSG_BUF_MAX 256 class AP_Beacon_Nooploop : public AP_Beacon_Backend @@ -56,3 +58,5 @@ private: bool _anchor_pos_avail; // flag indicates if we got anchor position or not uint32_t _last_request_setting_ms; // last time we sent request_setting0 packet to tag }; + +#endif // AP_BEACON_NOOPLOOP_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_Pozyx.cpp b/libraries/AP_Beacon/AP_Beacon_Pozyx.cpp index 9880d78355..467c69ae5f 100644 --- a/libraries/AP_Beacon/AP_Beacon_Pozyx.cpp +++ b/libraries/AP_Beacon/AP_Beacon_Pozyx.cpp @@ -13,8 +13,11 @@ along with this program. If not, see . */ -#include #include "AP_Beacon_Pozyx.h" + +#if AP_BEACON_POZYX_ENABLED + +#include #include #include @@ -157,3 +160,5 @@ void AP_Beacon_Pozyx::parse_buffer() last_update_ms = AP_HAL::millis(); } } + +#endif // AP_BEACON_POZYX_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_Pozyx.h b/libraries/AP_Beacon/AP_Beacon_Pozyx.h index 56d6ed46fb..8a324fba6c 100644 --- a/libraries/AP_Beacon/AP_Beacon_Pozyx.h +++ b/libraries/AP_Beacon/AP_Beacon_Pozyx.h @@ -2,6 +2,8 @@ #include "AP_Beacon_Backend.h" +#if AP_BEACON_POZYX_ENABLED + #define AP_BEACON_POZYX_MSG_LEN_MAX 20 // messages from uno/pozyx are no more than 20bytes #define AP_BEACON_POZYX_HEADER 0x01 // messages start with this character #define AP_BEACON_POZYX_MSGID_BEACON_CONFIG 0x02 // message contains anchor config information @@ -41,3 +43,5 @@ private: uint8_t linebuf_len = 0; uint32_t last_update_ms = 0; }; + +#endif // AP_BEACON_POZYX_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_SITL.cpp b/libraries/AP_Beacon/AP_Beacon_SITL.cpp index 8a353b2734..2e2971363c 100644 --- a/libraries/AP_Beacon/AP_Beacon_SITL.cpp +++ b/libraries/AP_Beacon/AP_Beacon_SITL.cpp @@ -13,11 +13,12 @@ along with this program. If not, see . */ +#include "AP_Beacon_SITL.h" + +#if AP_BEACON_SITL_ENABLED + #include -#if CONFIG_HAL_BOARD == HAL_BOARD_SITL - -#include "AP_Beacon_SITL.h" #include extern const AP_HAL::HAL& hal; @@ -110,4 +111,4 @@ void AP_Beacon_SITL::update(void) last_update_ms = now; } -#endif // CONFIG_HAL_BOARD +#endif // AP_BEACON_SITL_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_SITL.h b/libraries/AP_Beacon/AP_Beacon_SITL.h index 28a0f98760..b761dd97ab 100644 --- a/libraries/AP_Beacon/AP_Beacon_SITL.h +++ b/libraries/AP_Beacon/AP_Beacon_SITL.h @@ -2,7 +2,7 @@ #include "AP_Beacon_Backend.h" -#if CONFIG_HAL_BOARD == HAL_BOARD_SITL +#if AP_BEACON_SITL_ENABLED #include @@ -25,4 +25,4 @@ private: uint32_t last_update_ms; }; -#endif // CONFIG_HAL_BOARD +#endif // AP_BEACON_SITL_ENABLED diff --git a/libraries/AP_Beacon/AP_Beacon_config.h b/libraries/AP_Beacon/AP_Beacon_config.h new file mode 100644 index 0000000000..38d3533142 --- /dev/null +++ b/libraries/AP_Beacon/AP_Beacon_config.h @@ -0,0 +1,27 @@ +#pragma once + +#include + +#ifndef AP_BEACON_ENABLED +#define AP_BEACON_ENABLED 1 +#endif + +#ifndef AP_BEACON_BACKEND_DEFAULT_ENABLED +#define AP_BEACON_BACKEND_DEFAULT_ENABLED AP_BEACON_ENABLED +#endif + +#ifndef AP_BEACON_MARVELMIND_ENABLED +#define AP_BEACON_MARVELMIND_ENABLED AP_BEACON_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BEACON_NOOPLOOP_ENABLED +#define AP_BEACON_NOOPLOOP_ENABLED AP_BEACON_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BEACON_POZYX_ENABLED +#define AP_BEACON_POZYX_ENABLED AP_BEACON_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BEACON_SITL_ENABLED +#define AP_BEACON_SITL_ENABLED (AP_BEACON_BACKEND_DEFAULT_ENABLED && CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif