forked from Archive/PX4-Autopilot
commander: add power button notification callback
This commit is contained in:
parent
7cb71af949
commit
73cb423db6
|
@ -303,6 +303,16 @@ static void answer_command(struct vehicle_command_s &cmd, unsigned result,
|
|||
/* publish vehicle status flags from the global variable status_flags*/
|
||||
static void publish_status_flags(orb_advert_t &vehicle_status_flags_pub);
|
||||
|
||||
|
||||
static int power_button_state_notification_cb(board_power_button_state_notification_e request)
|
||||
{
|
||||
// Note: this can be called from IRQ handlers
|
||||
if (request == PWR_BUTTON_REQUEST_SHUT_DOWN) {
|
||||
px4_shutdown_request(false, false);
|
||||
}
|
||||
return PWR_BUTTON_RESPONSE_SHUT_DOWN_PENDING;
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether autostart ID is in the reserved range for HIL setups
|
||||
*/
|
||||
|
@ -1378,6 +1388,10 @@ int commander_thread_main(int argc, char *argv[])
|
|||
PX4_WARN("Buzzer init failed");
|
||||
}
|
||||
|
||||
if (board_register_power_state_notification_cb(power_button_state_notification_cb) != 0) {
|
||||
PX4_ERR("Failed to register power notification callback");
|
||||
}
|
||||
|
||||
/* vehicle status topic */
|
||||
memset(&status, 0, sizeof(status));
|
||||
|
||||
|
|
Loading…
Reference in New Issue