/*****************************************************************************
 * @file     msg.h
 * @version  2.15
 * @brief    Contains strings to be display in logger
 * @date	 5 May 2022
 ******************************************************************************/
#ifndef COMPONENTS_UTIL_INCLUDE_MSG_H_
#define COMPONENTS_UTIL_INCLUDE_MSG_H_
/*
 *  PART 1 - Strings
 */
/*
 * 	CAT. A - Messages
 */
#define MI_NAME							"Meridian Innovation"
#define MSG_APP_NAME					"SenXorTCP"
#define MSG_APP_VER						CONFIG_APP_PROJECT_VER
#define MSG_SXRLIB_VER					"4.4.26"
#define LINE							"=============================="
#define MSGTAG							"[INFO]"
#define MSG_APPNAME						"SenXorTCP Ver. "MSG_APP_VER" SenXorLib "MSG_SXRLIB_VER
#define MSG_INTRO						"2024 Meridian Innovation. For demonstration only."

/*
 * 	CAT. D - Debug
 */
//D-1. MCU
#define MCUTAG							"[Peripherals]"
#define MCU_INIT_INFO					"Initialising MCU Peripherals..."
#define MCU_INIT_DONE					"MCU Peripherals initialised."

//D-2 - MAIN
#define MTAG 							"[MAIN]"
#define MAIN_ALLO_BUFF					"Allocating buffer for program use..."
#define MAIN_ALLO_BUFF_DONE				"Buffers allocated."
#define MAIN_CHK_INFO					"Checking system capability..."
#define MAIN_CHK_PASS					"System capability test OK."
#define MAIN_ERR_ALLO_BUFF				"Unable to allocate buffer. Exiting program..."
#define MAIN_ERR_CHK_FAIL				"Self check failed. Program cannot be continue."
#define MAIN_ERR_INIT_QUEUE				"Unable to create queue. Exiting program..."
#define MAIN_ERR_SPIRAM_NOT_EN			"SPI RAM is not enabled. Please enable SPIRAM (PSRAM) and try again."
#define MAIN_ERR_SPIRAM_BSS_DIS			"Allocating variable in SPI RAM is not allowed.Please enable Allow .bss segement placed in external memory in sdkconfig."
#define MAIN_ERR_WIFI_NOT_SUP			"WiFi is not supported on this SOC."
#define MAIN_ERR_WIFI_SPIRAM_NOT_ALLOW	"WiFi and LwIP are not allowed to allocate buffers in SPI RAM. Please enable Try to allocate memories of WiFi and LwIP in SPIRAM firstly in sdkconfig."
#define MAIN_SYS_INFO					"Chip: %s @ %d MHz (%d core(s) Total)"
#define MAIN_TASK_INIT 					"Starting task... Running on core %d"
#define MAIN_FREE_RAM					"Free DRAM: %d bytes"
#define MAIN_FREE_SPIRAM				"Free external RAM: %d bytes"
#define MAIN_TOTAL_RAM					"Total DRAM: %d bytes"
#define MAIN_TOTAL_SPIRAM				"Total external RAM: %d bytes"
#define MAIN_IDF_VER					"Running ESP IDF %s "
#define MAIN_INIT_QUEUE					"Initialising queue..."
#define MAIN_WARN_CHK					"System capability test with warning. The program will proceed with limited functions."
#define MAIN_WARN_GDMA_NOT_SUPPORTED	"DMA not supported on this platform. All data transfer will be done by CPU."

//ADC
#define ADCTAG							"[ADC]"
#define ADC_ERR_RD_OBJ_NULL				"Object to hold the data cannot be null."
#define ADC_ERR_INVALID_HLE				"Invalid ADC Handle."
#define ADC_ERR_INVALID_MODE			"Invalid ADC mode."
#define ADC_INIT_INFO					"ADC Initialising..."
#define ADC_INFO						"ADC Unit: %d | Channel: %d"
#define ADC_INFO_USEULP					"Using ULP to control ADC."
#define ADC_MODE_0						"One shot mode"
#define ADC_MODE_1						"Continuous mode"
#define ADC_CALI_SME_INFO				"Calibration scheme %s."
#define ADC_CALI_INIT					"Initialising calibration scheme..."
#define ADC_CALI_DONE					"Calibration done."
#define ADC_WARN_CALI_NOT_SUPPORTED		"eFuse not burnt. Software calibration will not perform."

//Bluetooth
#define BTTAG							"[BT]"

#define BLUFI_ERR_CALLBACK_REG_FAIL			"Fail to register BluFi callback. Error: %x"
#define BLUFI_ERR_PROFILE_INIT_FAIL			"Fail to initialise Bluetooth profile. Error: %x"
#define BLUFI_ERR_DEINIT_FAIL				"Fail to de-initialise BluFi. Error: %s"
#define BLUFI_ERR_DISABLE_FAIL				"Fail to disable BluFi. Error: %s"
#define BLUFI_ERR_INIT_FAIL					"Fail to initialise BluFi. Error: %s"
#define BLUFI_ERR_INIT_EN_FAIL				"Fail to enable BluFi. Error: %s"
#define BLUFI_ERR_EVENT						"An error in a BluFi event. Error code: %d"
#define BLUFI_ERR_EVENT_WLAN_MODE			"Invalid WiFi mode."

#define BLUFI_INFO_INIT						"BluFi initialising..."
#define BLUFI_INFO_DEINIT					"BluFi de-initialising..."
#define BLUFI_INFO_INIT_DONE				"BluFi initialised."
#define BLUFI_INFO_DEINIT_DONE				"BluFi de-initialised"
#define BLUFI_INFO_EVENT_CONNECT			"BluFi connected"
#define BLUFI_INFO_EVENT_DISCONNECT			"BluFi disconnected"
#define BLUFI_INFO_EVENT_REQ_TO_AP			"Receive a request to connect to WiFi"
#define BLUFI_INFO_EVENT_REQ_DIS_AP			"Receive a request to disconnect from WiFi"
#define BLUFI_INFO_EVENT_REQ_WLAN_STAT		"Receive a request to query WiFi status"
#define BLUFI_INFO_EVENT_REQ_SET_WLAN_MODE	"Receive a request to set WiFi mode. (Mode %d)"
#define BLUFI_INFO_EVENT_GATT_CLOSE			"Closing a GATT connection ..."
#define BLUFI_INFO_EVENT_GET_STA_BSSID		"Receive a request to query station BSSID"
#define BLUFI_INFO_EVENT_GET_STA_SSID		"Receive a request to query station SSID"
#define BLUFI_INFO_EVENT_GET_STA_STATUS		"Receive a request to query the configuration of station Mode WiFi"
#define BLUFI_INFO_EVENT_GET_STA_PWD		"Receive a request to query station password"
#define BLUFI_INFO_EVENT_GET_AP_STATUS		"Receive a request to query the configuration of AP Mode WiFi"
#define BLUFI_INFO_EVENT_GET_AP_SSID		"Receive a request to query AP SSID"
#define BLUFI_INFO_EVENT_GET_AP_PWD			"Receive a request to query AP password"
#define BLUFI_INFO_EVENT_GET_AP_AUTHMODE	"Receive a request to query AP authentication mode"
#define BLUFI_INFO_EVENT_GET_AP_CH			"Receive a request to query AP channel"
#define BLUFI_INFO_EVENT_GET_AP_MAXCON		"Receive a request to query AP maximum connection"
#define BLUFI_INFO_EVENT_GET_APSTA_STATUS	"Receive a request to query the configuration of AP and station Mode WiFi"
#define BLUFI_INFO_EVENT_GET_CUSTDATA		"Receive a custom data from client"


#define BT_ERR_CALLBACK_GAP_FAIL			"Fail to register BLE GAP callback. Error: %x"
#define BT_ERR_PROFILE_GAP_FAIL				"Fail to register BLE GAP profile. Error: %x"
#define BT_ERR_CTRL_INIT_FAIL				"Bluetooth controller initialised failed. (%s)"
#define BT_ERR_CTRL_INIT_EN					"Fail to enable Bluetooth controller (%s)"
#define BT_INFO_CTRL_INIT_DONE				"Bluetooth controller initialised."
#define BT_ERR_NOT_SUPPORTED				"Bluetooth cannot initialise because it is not supported in this system."
#define BT_ERR_NOT_ENABLED					"Bluetooth is disabled in sdkconfig."

//JSON
#define JSONTAG							"[JSON]"
#define JSON_ERR_INPUT_NULL				"Input to JSON phaser is null."
#define JSON_ERR_NODE_NULL				"JSON Node is null."
#define JSON_INFO_NODE_NULL_HINT		"Please check whether the input to cJSON phaser contains a valid JSON string."
//LCD
#define LCDTAG 							"[LCD]"
#define LCD_DETAILS						"Resolution: %d x %d | Colour depth: %d bits | Pixel clock: %d Hz"
#define LCD_ERR_ALLO_BUFF				"Cannot allocate the buffer, terminating the task..."
#define LCD_ERR_NO_BUFF					"Cannot display image to LCD due to null buffers."
#define LCD_ERR_NO_RAM					"Not enough memory to hold the display buffer.\nConsider to reduce the size of buffer or add external memory if supported."
#define LCD_BUFF_INIT					"Display buffers allocated. Size: %d Bytes"
#define LCD_INIT_INFO					"LCD Initialising..."
#define LCD_INIT_DONE					"LCD Initialised."
#define LCD_TASK_INFO					"Display task started. Running in Core %d"



//D-4 - SPI
#define STAG 							"[SPI]"
#define SPI_AUTO_CS_EN 					"Auto chip select enabled. Pin assigned: %d."
#define SPI_AUTO_CS_DIS 				"Auto chip select disabled."
#define SPI_BUS_INIT 					"SPI bus initialised."
#define SPI_BUS_INIT_FAILED 			"SPI bus failed to initialised."
#define SPI_BUS_INFO					"MISO: PIN %d | MOSI: PIN %d | CLK: PIN %d"
#define SPI_CLK_SPD 					"Clock speed: %lu Hz."
#define SPI_DEV_ADD						"Added SPI device."
#define SPI_DEV_DEL 					"Removing existing SPI device..."
#define SPI_DMA_INIT					"Attached SPI to DMA.\nDMA TX channel: %d | DMA RX channel: %d "
#define SPI_ERR_BUFF_EPY				"Buffers empty"
#define SPI_ERR_CLK_SPD					"Invalid clock speed. (%lu Hz) Reverting to default clock speed (%d Hz)"
#define SPI_SPD_SEL						"Selecting SPI Clock (Present %lu) with %lu Hz..."
#define SPI_MODE_FLASH					"Flash accessing mode."

#define SPI_INIT_INFO					"SPI Initialising..."
#define SPI_WARN_CLKSPD					"Invalid clock speed. Using pre-configured SPI profile (%lu) (Speed: %lu Hz)"
#define SPI_WARN_DEV_EXISTS 			"A device had already attached to SPI. Removing the device for other use..."

//D-5 - GPIO
#define GPIOTAG 						"[GPIO]"
#define GPIO_INIT 						"GPIO initialised."
#define GPIO_INIT_INFO					"GPIO Initialising..."

//PWM
#define PWMTAG							"[PWM]"
#define PWMSYSCLK_TAG					"[PWM-SYSCLK]"
#define PWMSYSCLK_ERR_NOTEN				"Generating clock from board is not enabled.\nEnsure to supply a suitable clock to SenXor for it to work."
#define PWMSYSCLK_INIT					"Initialising PWM for generating sysclk..."
#define PWMSYSCLK_INFO					"Timer %d | Channel: %d | Output to : GPIO %d \nFrequency: %d Hz"
#define PWMSYSCLK_INTI_OK				"PWM initialised."
#define PWMSYSCLK_FREQ_OK				"Using default frequency: 3MHz"
#define PWMSYSCLK_WARN_PWM_LIB			"Supplying SenXor with clock %d Hz. Ensure to use a SenXorLib compatible with such clock frequency."

//D-6 - SenXor
#define SXRTAG 							"[SenXor]"
#define SXR_CAP_MODE_0					"Capture stopped."
#define SXR_CAP_MODE_1					"Capture a frame."
#define SXR_CAP_MODE_2					"Capture frames continuously."
#define SXR_CAP_NA						"Capturing mode unknown."
#define SXR_DATA_HEADER 				"FRAME - %d \n\r VDD %d mV | Die temperature %d mK \n Maximum temperature: %d mK | Minimum temperature: %d mK "
#define SXR_DATA_CAP 					"Pixel 80: %d mK | Pixel 2480: %d mK | Pixel 5039: %d mK \r"
#define SXR_DATA_CAP_DEG				"Pixel 80: %f C | Pixel 2480: %f C | Pixel 5039: %f C \r"
#define SXR_ERR							"Error while capturing frames. (Code: %ld)\r"
#define SXR_ERR_CONFIG_MODEL			"Expected SenXor type %d, but %d is connected.\n Please reconfigure and flash the program again.(0: Bobcat | 3: Cougar / Mini Cougar)"
#define SXR_ERR_INIT					"SenXor initialisation failed. The program will exit now."
#define SXR_ERR_TASK_FAIL_INIT			"SenXor task failed to initialised. The program will exit now."
#define SXR_FLASH_RD_DONE				"Finished reading SenXor's flash."
#define SXR_FLASH_RD_INIT				"Start reading SenXor's flash..."
#define SXR_FITLER_INIT				    "Initialising filters..."
#define SXR_FITLER_MODE_0				"Noise filter and rolling average are disabled."
#define SXR_FITLER_MODE_3				"Noise filter only"
#define SXR_FITLER_MODE_4				"Rolling average only."
#define SXR_FITLER_MODE_7				"Noise filter and rolling average are enabled."
#define SXR_FW_INFO						"Firmware info Version: %d (Build %d)"
#define SXR_REG_AVG						"Frame averaging (Register 0xB4): %d frame(s)"
#define SXR_REG_CAP_MODE				"Capturing mode (Register 0xB1): %d"
#define SXR_REG_FITLER					"Noise filter (Register 0xD0): %d"
#define SXR_REG_ROLL_AVG				"Rolling average strength (Register 0xD3): %d"
#define SXR_PROCESS_CALI				"Processing calibration data..."
#define SXR_PROCESS_CALI_DONE			"Finished processing."
#define SXR_PIX_CNT						"Total Pixel count: %lu "
#define SXR_INIT_DONE					"SenXor initialised."
#define SXR_PROD_INFO					"Production info Year: %d | Week: %d | Location: %d  SN: %lld"
#define SXR_SWMCU_INIT_DONE 			"SenXor registers mapped to MCU."
#define SXR_MODEL_BOBCAT				"Bobcat"
#define SXR_MODEL_COUGAR				"Cougar/Mini-Cougar"
#define SXR_MODEL_RAW					"Detected Module: %d"
#define SXR_NO_DATA						"Data not available."
#define SXR_TASK_INFO					"SenXor task started, running on core %d ."
#define SXR_WARN_RECR					"Attempting to recover..."

//D-7 - NVS
#define NVSTAG							"[NVS]"
#define NVS_CHIP_INFO					"Chip info:Chip ID: %XSize: %d"
#define NVS_ERASE_INFO					"Please wait while program is erasing the data from region 0x%.8X with length %d bytes..."
#define NVS_ERASE_DONE					"Partition erased."
#define NVS_ERR_ERASE					"Error while erasing data from FLASH: %s"
#define NVS_ERR_ERASE_LEN_NULL  		"Length of data is 0. Program will not erase anything from FLASH."
#define NVS_ERR_FULL					"No free space in NVS. Initiating erase operation..."
#define NVS_ERR_PART					"Unable to inspect partition properties with null partition object."
#define NVS_ERR_PART_NOT_EXIST			"No such partition."
#define NVS_ERR_INIT					"FLASH initialisation failed: %s "
#define NVS_ERR_HANDLE					"Error while opening the NVS Handle. (%s)"
#define NVS_ERR_HANDLE_NULL				"NVS Handler is NULL."
#define NVS_ERR_RD						"Error while reading data from FLASH: %s"
#define NVS_ERR_RD_NO_BUFF				"No buffer is provided for storing data. Program will not read anything from FLASH."
#define NVS_ERR_RD_NO_VAL				"Value not found."
#define NVS_ERR_WRITE					"Error while writing data to FLASH: %s"
#define NVS_ERR_WRITE_NO_DATA			"No data is provided. Program will not write anything to FLASH."
#define NVS_PART_INFO					"Partition info: Name: %s"
#define NVS_INIT						"Initialising NVS..."
#define NVS_INIT_DONE					"NVS initialised."
#define NVS_WRITE						"Please wait while the program is writing to flash"
#define	NVS_WRITE_DONE					"Write completed."

//D-8 - WLAN
#define WLANTAG 				"[WiFi]"
#define WLAN_AP_INIT			"WiFi AP mode initialised."
#define WLAN_AP_JOIN			"A client is joined. AID = %d"
#define WLAN_AP_LEFT			"A client is left. AID = %d "
#define WLAN_AUTH_OPEN			"Unsecured"
#define WLAN_AUTH_NA			"Unknown security mode"
#define WLAN_AUTH_WEP			"WEP"
#define WLAN_AUTH_WPA			"WPA PSK"
#define WLAN_AUTH_WPA_WPA2		"WPA or WPA2 PSK"
#define WLAN_AUTH_WPA2			"WPA2 PSK"
#define WLAN_AUTH_WPA2_EN		"WPA2 Enterprise"
#define WLAN_AUTH_WPA3			"WPA3 PSK"
#define WLAN_AUTH_WPA3_WPA2		"WPA3 or WPA2 PSK"
#define WLAN_CLIENT_CONNECT		"%s joined. AID: %d"
#define WLAN_CLIENT_DISCONNECT	"%s left. AID: %d"
#define WLAN_DEINIT_OK			"WiFi is shutdown."
#define WLAN_ERR_AP_CONNECT		"Cannot connect to the AP. Program halted."
#define WLAN_ERR_AP_CONNECT_RTY "Cannot connect to the AP. Retrying... Attempt: %d / %d"
#define WLAN_ERR_AP_NO_PWD		"No password is required to connect to this access point. This means the traffic is unencrypted and it is vulnerable to cyber attack. Consider to use WPA2 or higher security with strong password."
#define WLAN_ERR_AP_NOT_ENPT	"UNENCRYPTED WIFI"
#define WLAN_ERR_AP_CONNECT_RTN	"Cannot connected to %s. Returning to AP mode..."
#define WLAN_ERR_AP_PWD_PARAM	"Parameter provided invalid password"
#define WLAN_ERR_AP_PWDLEN		"The length of password in AP mode must be greater than 8."
#define WLAN_ERR_EVT_NA			"Unknown WiFi event."
#define WLAN_ERR_SSID_NULL		"Incorrect SSID."
#define WLAN_ERR_NOT_CONN		"WiFi is disconnected from station."
#define WLAN_ERR_NOT_INIT		"WiFi is not initialised."
#define WLAN_ERR_NA				"Unexpected event."
#define WLAN_ERR_MODE			"Invalid WiFi mode. "
#define WLAN_INIT_INFO			"WiFi initialising..."
#define WLAN_INIT_DONE			"WiFi initialised."
#define WLAN_INFO				"Starting WiFi task..."
#define WLAN_INFO_AP			"Access point (AP) Mode"
#define WLAN_INFO_AP_AUTH		"Security: "
#define WLAN_INFO_AP_CH			"Channel: %d "
#define WLAN_INFO_AP_INIT		"Initialsing WiFi in AP mode..."
#define WLAN_INFO_AP_MAXCON		"Maximum client allowed: %d"
#define WLAN_INFO_AP_SSID		"AP SSID: %s "
#define WLAN_INFO_AP_STH		"Strength: %d dBm"
#define WLAN_INFO_STA_INIT		"Initialsing WiFi in station mode..."
#define WLAN_INFO_STA_INIT_DONE	"WiFi initialised in station mode."
#define WLAN_INFO_STA_CONNECTED	"Connected to a WiFi access point."
#define WLAN_INFO_STA_USEPARAM	"Using SSID other than sdkconfig. SSID: %s"

#define WLAN_INFO_USE_NVS		"Using configuration from NVS."
#define WLAN_IP_GET				"IP Obtained: "
#define WLAN_RST				"Restarting WiFi..."
#define WLAN_SCAN_START			"Start scanning for available AP..."
#define WLAN_SCAN_TOTALAP		"Total APs found: %u"
#define WLAN_STAT_CONNECT		"The device is connected to: %s ."
#define WLAN_STOP				"Disabling WiFi..."
#define WLAN_WARN_AP_SDKCFGPWD	"Using the pre-configurated password in sdkconfig."
#define WLAN_WARN_STA_SDKCFGSSID "Using the pre-configurated SSID in sdkconfig."
#define WLAN_WARN_EVTGRP_EXIST	"An event group already initialised. Using the existing one."
#define WLAN_WARN_DEINIT		"WiFi is de-initialised. A complete initialisation is required to restart WiFi."


//D-10 Serial processor
#define SPTAG 					"[SERIAL_PRO]"
#define SP_INFO					"Initialising serial processor..."
#define SP_CMD_CMD_GET			"Command obtained: %s"
#define SP_CMD_INFO				"Packet to be serialised: %s"
#define SP_CMD_INVALID			"Invalid command."
#define SP_CMD_RREG_INFO		"SenXor register reading mode."
#define SP_CMD_RWREG_REGADDR	"Register address: %X"
#define SP_CMD_WREG_INFO		"SenXor register writing mode."
#define SP_CMD_WREG_VAL			"Value: %X"
#define SP_CRC_GET				"CRC Obtained: %s"
#define SP_DATA_GET				"Data obtained: %s"
#define SP_ERR_CMD_INVALID		"Invalid command."
#define SP_ERR_INPACK_EMT		"Incoming packet is empty."
#define SP_ERR_INPACK_INVALID	"Invalid incoming packet."
#define SP_ERR_DATALEN_INVALID	"Invalid data length."
#define SP_ERR_TIMEOUT			"Serial processor timeout."
#define SP_LEN_GET				"Buffer length determined: %d"
#define SP_START				"Start processing incoming packets."
#define SP_STATE_START			"STAGE 1 - Command verification"
#define SP_STATE_GETLEN			"STAGE 2 - Getting command length."
#define SP_STATE_COMPLEN		"STAGE 3 - Computing data length..."
#define SP_STATE_GETCMD			"STAGE 4 - Getting command..."
#define SP_STATE_GETDATA		"STAGE 5 - Getting data..."
#define SP_STATE_GETCRC			"STAGE 6 - Getting CRC..."
#define SP_STATE_PREMSG			"STAGE 7 - Start processing message."
#define SP_RST					"Resetting serial processor..."

//D-11 REST
#define RSTTAG					"[REST]"
#define RSTSER_DEINIT_OK		"REST server has been stopped."
#define RSTSER_INFO				"Initialising REST server"
#define RSTSER_INIT_OK			"REST server initialised"
#define RSTSER_ERR				"REST server failed to initialise. Error: %s"
#define RSTSER_ERR_DEINIT		"REST server failed to stop. Error: %s"
#define RSTSER_ERR_HANDLE_NULL	"REST server handler is null."
#define RSTSER_ERR_PATH_NULL	"Server's root path cannot be empty."

//D-12 SPIFFS
#define SPIFFS_TAG				"[SPIFFS]"
#define SPIFFS_INIT_DONE		"SPIFFS initialised: (%s)"
#define SPIFFS_ERR_INIT			"SPIFFS failed to initialise: (%s)"
#define SPIFFS_ERR_GETPART		"Failed to get SPIFFS partition information. Error: (%s)"
#define SPIFFS_PART_INFO		"Partition size: Total: %d bytes. Used: %d bytes"

//D-13 mDNS
#define MDNS_TAG				"[mDNS]"
#define MDNS_INIT_DONE			"mDNS initialised"
#define MDNS_HSTNAME			"mDNS hostname: %s"
#define MDNS_ERR_INIT			"mDNS failed to initialise: (%s)"
#define MDNS_ERR_UNINIT			"mDNS is not initialised"
//D-14 Temperature sensor
#define TSTAG					"[TEMP SENSOR]"
#define TS_VAL					"Internal temperature: %f C"

//D-15 Battery
#define BATTAG					"[BATTERY TASK]"
#define BATRPT_ERR_ISR_INIT		"Cannot attach battery input pins to ISR. Battery reporting task will not be started.\Error: %s"
#define BATRPT_INIT				"Initialising battery reporting task..."
#define BATRPT_INIT_DONE		"battery reporting task initialised."
#define BATRPT_PIN_INIT			"Initialising GPIO pins for battery reporting task.\nCharging: %d | PG: %d"
#define BATRPT_STA_BATTERY		"Battery"
#define BATRPT_STA_CHARGING		"Charging"
#define BATRPT_STA_CHARGED		"Charged"
#endif /* COMPONENTS_UTIL_INCLUDE_MSG_H_ */
