/* 
 * File:   AudioConsole.h
 * Author: JF
 *
 * Created on February 20, 2025, 2:30 PM
 */

#ifndef AUDIOCONSOLE_H
#define	AUDIOCONSOLE_H

#include "define.h"
#include "AudioConsoleInterface.h"
#include "WiFiCtrl.h"
#include "BoardCfg.h"


#define AUDIO_CONSOLE_WAIT_FOR_WIFI_TIMEOUT 1000
#define AUDIO_CONSOLE_WAIT_FOR_CONNECT_TIMEOUT 10000
#define AUDIO_CONSOLE_STATUS_REQUEST_TIMEOUT 1000
#define AUDIO_CONSOLE_MAX_STATUS_RETRY 5
#define AUDIO_CONSOLE_VOLUME_INCREMENT 1



enum eAudioConsoleZone
{
    AUDIO_CONSOLE_SALON_ZONE,
    AUDIO_CONSOLE_CUISINE_ZONE
};



typedef struct eAVReceiverStatus
{
    bool MainPwrStatus;
    bool MainSleepStatus;
    bool IsMute;
    bool DataValid;
    bool ReceiverOnline;
    bool SyncZones;
    unsigned int MainVolume;
}AVReceiverStatus_t;

enum eAudioConsoleStates
{
    AUDIO_CONSOLE_INIT_STATE,
    AUDIO_CONSOLE_DISCONNECTED_STATE,
    AUDIO_CONSOLE_CONNECTING_STATE,
    AUDIO_CONSOLE_RUN_STATE,
    
    AUDIO_CONSOLE_MAX_STATE
};

enum eAudioConsoleSMEvents
{
    AUDIO_CONSOLE_SM_TICK_EVENT,
    AUDIO_CONSOLE_SM_CONNECTED_EVENT,
    AUDIO_CONSOLE_SM_DISCONNECTED_EVENT,
    AUDIO_CONSOLE_MAX_EVENT
};

int AudioConsoleInit();
void AudioConsoleTick();

int AudioConsoleSetIFConnectionStatus(bool Connected);
int AudioConsoleSetReceiverStatus(AVReceiverStatus_t *MainZone, AVReceiverStatus_t *Zone2);
int AudioConsoleSM(int Event);
int AudioConsoleDisconnected();

int RequestStatus();
int SendMainVolumeToMaster();
int SendZone2VolumeToMaster();
int SendLinkZ2VolumeToMaster(bool link);
int SendMainZonePwrToMaster(bool ON);
int SendZone2PwrToMaster(bool ON);
int AudioConsoleVolumeUp(int Zone);
int AudioConsoleVolumeDown(int Zone);
int LinkZ2BtnPressed();
int MainZonePwrBtnPressed();
int Zone2PwrBtnPressed();


#endif	/* AUDIOCONSOLE_H */

