#ifndef __ALY_H
#define __ALY_H

#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include "esp_wifi.h"
#include "esp_system.h"
#include "nvs_flash.h"
#include "esp_event.h"
#include "esp_netif.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "freertos/queue.h"

#include "lwip/sockets.h"
#include "lwip/dns.h"
#include "lwip/netdb.h"

#include "esp_log.h"
#include "mqtt_client.h"
#include "os.h"
#include "cJSON.h"
//OTA
#include "esp_ota_ops.h"
#include "esp_http_client.h"
#include "esp_https_ota.h"
#include "esp_wifi.h"
#include "mqtt_client.h"
#include "string.h"
#include "nvs.h"
#include "nvs_flash.h"
#include <sys/socket.h>

//阿里云连接三元组
#define   Aliyun_host       "a1o6FKg9Pc7.iot-as-mqtt.cn-shanghai.aliyuncs.com"
#define   Aliyun_port       1883
#define   Aliyun_client_id  "a1o6FKg9Pc7.nFP00TvHvsNYzjLEewRU|securemode=2,signmethod=hmacsha256,timestamp=1707275697446|"
#define   Aliyun_username   "nFP00TvHvsNYzjLEewRU&a1o6FKg9Pc7"
#define   Aliyun_password   "65157fff3b7de41dc97b6ba224785426d1df4765fd342048d3c80bea0a72f6b0"

//自定义订阅与发布
#define   AliyunSubscribeTopic_user_get     "/a1o6FKg9Pc7/nFP00TvHvsNYzjLEewRU/user/get"
#define   AliyunPublishTopic_user_update    "/a1o6FKg9Pc7/nFP00TvHvsNYzjLEewRU/user/update"

//OTA相关
#define AliyunOTAInform                     "/ota/device/inform/a1o6FKg9Pc7/nFP00TvHvsNYzjLEewRU"
#define AliyunOTAupgrade                    "/ota/device/upgrade/a1o6FKg9Pc7/nFP00TvHvsNYzjLEewRU"
#define AliyunOTAprogress                   "/ota/device/progress/a1o6FKg9Pc7/nFP00TvHvsNYzjLEewRU"
#define AliyunOTAfirmware                   "/sys/a1o6FKg9Pc7/nFP00TvHvsNYzjLEewRU/thing/ota/firmware/get"
extern const uint8_t server_cert_pem_start[] asm("_binary_root_crt_start");
extern const uint8_t server_cert_pem_end[] asm("_binary_root_crt_end");
#define OTA_URL_SIZE 256

static const char *MQTT_TAG = "MQTT_EXAMPLE";

//MQTT测试发布数据
static char mqtt_publish_Testdata[] = "mqtt i am esp32";
static char mqtt_OTA_Data[]="{\"id\":\"001\",\"params\":{\"version\":\"1.0.1\"}}";



//进行阿里云连接
void user_mqtt_app_start(void);

//void Parse_Data(const char *Data);

//通过阿里云下发的topic进行对应的数据解析
void Get_ALY_Topic(const char *topic, const char *data);
#endif
