AP_Beacon: fix example when Beacon not available

simply print the fact that the beacon librar y isn't compiled in
This commit is contained in:
Peter Barker 2023-10-17 13:55:17 +11:00 committed by Peter Barker
parent 42d4b2671b
commit c6b93baf44
1 changed files with 11 additions and 0 deletions

View File

@ -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();