From c6b93baf44cf4325b9d007c6ca11a5c41aaa418a Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 17 Oct 2023 13:55:17 +1100 Subject: [PATCH] AP_Beacon: fix example when Beacon not available simply print the fact that the beacon librar y isn't compiled in --- .../AP_Marvelmind_test/AP_Marvelmind_test.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libraries/AP_Beacon/examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp b/libraries/AP_Beacon/examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp index a3dae7a7f1..550899fbcc 100644 --- a/libraries/AP_Beacon/examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp +++ b/libraries/AP_Beacon/examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp @@ -16,7 +16,9 @@ void set_object_value_and_report(const void *object_pointer, const AP_HAL::HAL& hal = AP_HAL::get_HAL(); static AP_SerialManager serial_manager; +#if AP_BEACON_ENABLED AP_Beacon beacon; +#endif // try to set the object value but provide diagnostic if it failed void set_object_value_and_report(const void *object_pointer, @@ -31,14 +33,19 @@ void set_object_value_and_report(const void *object_pointer, void setup(void) { +#if AP_BEACON_ENABLED set_object_value_and_report(&beacon, beacon.var_info, "_TYPE", 2.0f); set_object_value_and_report(&serial_manager, serial_manager.var_info, "0_PROTOCOL", 13.0f); +#endif serial_manager.init(); +#if AP_BEACON_ENABLED beacon.init(); +#endif } void loop(void) { +#if AP_BEACON_ENABLED static int count = 0; beacon.update(); Vector3f pos; @@ -51,6 +58,10 @@ void loop(void) hal.scheduler->delay(1000); if (count == 3) exit(0); +#else + printf("Beacon not available\n"); + hal.scheduler->delay(1000); +#endif } AP_HAL_MAIN();