Skip to content

Commit

Permalink
AP_Beacon: fix example when Beacon not available
Browse files Browse the repository at this point in the history
simply print the fact that the beacon librar y isn't compiled in
  • Loading branch information
peterbarker committed Oct 17, 2023
1 parent 42d4b26 commit c6b93ba
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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();

0 comments on commit c6b93ba

Please sign in to comment.