/*
 * cToMita.h
 *
 *  Created on: 18. 2. 2022
 *      Author: filip
 */

#ifndef SRC_GEN_CTOMITA_H_
#define SRC_GEN_CTOMITA_H_

#include "BCDS_BSP_Board.h"
#include "BCDS_CmdProcessor.h"
#include "BCDS_WlanNetworkConfig.h"
#include "BCDS_WlanNetworkConnect.h"
#include "BCDS_Assert.h"
#include "XDK_Utils.h"
#include "XDK_WLAN.h"
#include "XDK_MQTT.h"
#include "XDK_Sensor.h"
#include "XDK_SNTP.h"
#include "XDK_ServalPAL.h"
#include "FreeRTOS.h"
#include "task.h"
#include "cToMita.h"

#define APP_MQTT_DATA_BUFFER_SIZE           UINT32_C(256)/**< macro for data size of incoming subscribed and published messages */
#define APP_MQTT_TOPIC                      "test"

#define WLAN_SSID                           "Skynet_2_4"

/**
 * WLAN_PSK is the WIFI router WPA/WPA2 password used at the Wifi network connection.
 * Make sure to update the WLAN_PSK constant according to your router password.
 */
#define WLAN_PSK                            "Vitk0vi247"

/**
 * WLAN_USERNAME is the Enterprise WIFI network username(unused if IS_ENTERPRISE_WIFI_SELECTED is false)
 */
#define WLAN_USERNAME                       "YourWifiUserName"

/**
 * IS_ENTERPRISE_WIFI_SELECTED is a boolean. If "true" then XDK device will connect to Enterprise WIFI Network and If "false" then XDK device will connect to Personal WIFI Network.
 */
#define IS_ENTERPRISE_WIFI_SELECTED         false

/**
 * WLAN_STATIC_IP is a boolean. If "true" then static IP will be assigned and if "false" then DHCP is used.
 */
#define WLAN_STATIC_IP                      false

/**
 * WLAN_IP_ADDR is the WIFI router WPA/WPA2 static IPv4 IP address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_IP_ADDR constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_IP_ADDR                        XDK_NETWORK_IPV4(0, 0, 0, 0)

/**
 * WLAN_GW_ADDR is the WIFI router WPA/WPA2 static IPv4 gateway address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_GW_ADDR constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_GW_ADDR                        XDK_NETWORK_IPV4(0, 0, 0, 0)

/**
 * WLAN_DNS_ADDR is the WIFI router WPA/WPA2 static IPv4 DNS address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_DNS_ADDR constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_DNS_ADDR                       XDK_NETWORK_IPV4(0, 0, 0, 0)

/**
 * WLAN_MASK is the WIFI router WPA/WPA2 static IPv4 mask address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_MASK constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_MASK                           XDK_NETWORK_IPV4(0, 0, 0, 0)

/* SNTP configurations ****************************************************** */

/**
 * SNTP_SERVER_URL is the SNTP server URL.
 */
#define SNTP_SERVER_URL                     "YourSNTPServerURL"

/**
 * SNTP_SERVER_PORT is the SNTP server port number.
 */
#define SNTP_SERVER_PORT                    UINT16_C(123)

/* MQTT server configurations *********************************************** */

/**
 * APP_MQTT_BROKER_HOST_URL is the MQTT broker host address URL.
 */
#define APP_MQTT_BROKER_HOST_URL            "192.168.0.108"

/**
 * APP_MQTT_BROKER_HOST_PORT is the MQTT broker host port.
 */
#define APP_MQTT_BROKER_HOST_PORT           UINT16_C(1883)

/**
 * APP_MQTT_CLIENT_ID is the device name
 */
#define APP_MQTT_CLIENT_ID                  "XDK42"

/**
 * APP_MQTT_USERNAME is the username for the connection to MQTT brocker.
 */
#define APP_MQTT_USERNAME                  	"YourUsername"

/**
 * APP_MQTT_PASSWORD is the Password for the connection to MQTT brocker.
 */
#define APP_MQTT_PASSWORD                  	"YourPassword"

/**
 * APP_MQTT_TOPIC is the topic to subscribe and publish
 */
#define APP_MQTT_TOPIC                      "test"

/**
 * APP_MQTT_SECURE_ENABLE is a macro to enable MQTT with security
 */
#define APP_MQTT_SECURE_ENABLE              0

/**
 * APP_MQTT_DATA_PUBLISH_PERIODICITY is time for MQTT to publish the sensor data
 */
#define APP_MQTT_DATA_PUBLISH_PERIODICITY   UINT32_C(1000)


void AppMQTTSubscribeCB(MQTT_SubscribeCBParam_T param);

static Retcode_T InspectAndActOnWlanNetworkStatus(void);

int mqttSub(int);

#endif /* SRC_GEN_CTOMITA_H_ */
