#pragma once
/*
 * phone.h — Off-hook GPIO monitor + ring control for PLIP (Phase D).
 *
 * On the ESP32-A1S dev kit: BOOT button (GPIO4 = KEY1) acts as the
 * off-hook stand-in (active LOW via INPUT_PULLUP, CONFIG_PLIP_HOOK_GPIO).
 * On the Si3210 PCB target: replace with the SLIC interrupt GPIO.
 *
 * Ring: drives audio_ring_start() / audio_stop().
 * Hook events: forwarded to hook_client_report().
 */

#include <stdbool.h>
#include "esp_err.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Initialise the off-hook GPIO and start the monitoring task.
 * hook_client_init() and audio_init() must have been called first. */
esp_err_t phone_init(void);

/* Signal the phone to start ringing (called externally if needed). */
void phone_ring_start(void);

/* Stop ringing. */
void phone_ring_stop(void);

/* Returns true if the handset is currently off-hook (picked up).
 * Safe to call from any task; backed by a volatile flag updated in phone_task. */
bool phone_is_offhook(void);

#ifdef __cplusplus
}
#endif
