mirror of https://github.com/ArduPilot/ardupilot
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:
parent
42d4b2671b
commit
c6b93baf44
|
@ -16,7 +16,9 @@ void set_object_value_and_report(const void *object_pointer,
|
||||||
|
|
||||||
const AP_HAL::HAL& hal = AP_HAL::get_HAL();
|
const AP_HAL::HAL& hal = AP_HAL::get_HAL();
|
||||||
static AP_SerialManager serial_manager;
|
static AP_SerialManager serial_manager;
|
||||||
|
#if AP_BEACON_ENABLED
|
||||||
AP_Beacon beacon;
|
AP_Beacon beacon;
|
||||||
|
#endif
|
||||||
|
|
||||||
// try to set the object value but provide diagnostic if it failed
|
// try to set the object value but provide diagnostic if it failed
|
||||||
void set_object_value_and_report(const void *object_pointer,
|
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)
|
void setup(void)
|
||||||
{
|
{
|
||||||
|
#if AP_BEACON_ENABLED
|
||||||
set_object_value_and_report(&beacon, beacon.var_info, "_TYPE", 2.0f);
|
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);
|
set_object_value_and_report(&serial_manager, serial_manager.var_info, "0_PROTOCOL", 13.0f);
|
||||||
|
#endif
|
||||||
serial_manager.init();
|
serial_manager.init();
|
||||||
|
#if AP_BEACON_ENABLED
|
||||||
beacon.init();
|
beacon.init();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(void)
|
void loop(void)
|
||||||
{
|
{
|
||||||
|
#if AP_BEACON_ENABLED
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
beacon.update();
|
beacon.update();
|
||||||
Vector3f pos;
|
Vector3f pos;
|
||||||
|
@ -51,6 +58,10 @@ void loop(void)
|
||||||
hal.scheduler->delay(1000);
|
hal.scheduler->delay(1000);
|
||||||
if (count == 3)
|
if (count == 3)
|
||||||
exit(0);
|
exit(0);
|
||||||
|
#else
|
||||||
|
printf("Beacon not available\n");
|
||||||
|
hal.scheduler->delay(1000);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
AP_HAL_MAIN();
|
AP_HAL_MAIN();
|
||||||
|
|
Loading…
Reference in New Issue