251 lines
7.8 KiB
C
251 lines
7.8 KiB
C
#ifndef CFG_H
|
|
#define CFG_H
|
|
#define MAX_WIFI_SSID (36)
|
|
#define MAX_WIFI_PASSWD (64)
|
|
#define MAX_MD5_STRING (36)
|
|
|
|
#include "esp_common.h"
|
|
|
|
#define RELEASE_VERSION (1)
|
|
|
|
#define ONLINE_PUBLISH (1)
|
|
#define TEST_LAN_PUBLISN (2)
|
|
#define TEST_WAN_PUBLISH (3)
|
|
#define TEST_COMMON_DEVICE (4)
|
|
|
|
#define SERVER_USED ONLINE_PUBLISH
|
|
|
|
#define FIRMWARE_VERSION "00000007"
|
|
#define FIRMWARE_VERSION_MCU "00000002"
|
|
#define USER_CFG_VERSION (0)
|
|
|
|
#if 0
|
|
#define NETEASE_ONLINE_MQTT_SERVER "link-iot.netease.im"
|
|
#define NETEASE_ONLINE_MQTT_PORT 8680
|
|
#define NETEASE_ONLINE_API_SERVER "https://api-iot.netease.im/iot/RegisterDevice"
|
|
|
|
#define NETEASE_MQTT_TEST_SERVER "mqtt-dev.netease.im"
|
|
#define NETEASE_MQTT_TEST_PORT 8883
|
|
#define NETEASE_API_TEST_SERVER "https://api-iot-dev.netease.im/RegisterDevice"
|
|
|
|
#define NETEASE_ONLINE_PRODUCT_KEY "3cfb69e088527ef73941b9b74ba1cd1b"
|
|
#define NETEASE_ONLINE_PRODUCT_SEC "ce3f33a99a86"
|
|
|
|
#define NETEASE_TEST_LAN_PRODUCT_KEY "c400b5654a73a5a1976c04910d79eebf"
|
|
#define NETEASE_TEST_LAN_PRODUCT_SEC "42955254d3d5"
|
|
|
|
#define NETEASE_TEST_WAN_PRODUCT_KEY "2c53832e7a05e6fcb52081ff3abce92c"
|
|
#define NETEASE_TEST_WAN_PRODUCT_SEC "8e92003eb2f9"
|
|
|
|
#define NETEASE_TEST_COMM_PRODUCT_KEY "46ab16f31749ac85076d50294efe2e03"
|
|
#define NETEASE_TEST_COMM_PRODUCT_SEC "eac46ba44c94"
|
|
#endif
|
|
|
|
/* define product key, device name , secret, just for demo */
|
|
#define PRODUCT_SECRET_USED 1
|
|
|
|
#if PRODUCT_SECRET_USED //using product secret
|
|
#define DEVICE_NAME "b4adc6ce61294be28dcf83ccc6752f65"
|
|
#if 0
|
|
#if (SERVER_USED == ONLINE_PUBLISH)
|
|
#define PRODUCT_KEY NETEASE_ONLINE_PRODUCT_KEY
|
|
#define PRODUCT_SECRET NETEASE_ONLINE_PRODUCT_SEC
|
|
#elif (SERVER_USED == TEST_LAN_PUBLISN)
|
|
#define PRODUCT_KEY NETEASE_TEST_LAN_PRODUCT_KEY
|
|
#define PRODUCT_SECRET NETEASE_TEST_LAN_PRODUCT_SEC
|
|
#elif (SERVER_USED == TEST_WAN_PUBLISH)
|
|
#define PRODUCT_KEY NETEASE_TEST_WAN_PRODUCT_KEY
|
|
#define PRODUCT_SECRET NETEASE_TEST_WAN_PRODUCT_SEC
|
|
#elif (SERVER_USED == TEST_COMMON_DEVICE)
|
|
#define PRODUCT_KEY NETEASE_TEST_COMM_PRODUCT_KEY
|
|
#define PRODUCT_SECRET NETEASE_TEST_COMM_PRODUCT_SEC
|
|
#else
|
|
#define PRODUCT_KEY NETEASE_ONLINE_PRODUCT_KEY
|
|
#define PRODUCT_SECRET NETEASE_ONLINE_PRODUCT_SEC
|
|
#endif
|
|
|
|
#if (SERVER_USED == ONLINE_PUBLISH)
|
|
#define NETEASE_MQTT_SERVER NETEASE_ONLINE_MQTT_SERVER
|
|
#define NETEASE_MQTT_PORT NETEASE_ONLINE_MQTT_PORT
|
|
#define NETEASE_API_SERVER NETEASE_ONLINE_API_SERVER
|
|
#else
|
|
#define NETEASE_MQTT_SERVER NETEASE_MQTT_TEST_SERVER
|
|
#define NETEASE_MQTT_PORT NETEASE_MQTT_TEST_PORT
|
|
#define NETEASE_API_SERVER NETEASE_API_TEST_SERVER
|
|
#endif
|
|
#endif
|
|
#else
|
|
#endif
|
|
|
|
#if 0
|
|
#if PRODUCT_SECRET_USED //using product secret
|
|
#if (MQTT_SERVER == MQTT_SERVER_ALIBABA)
|
|
#define PRODUCT_KEY "a1mgNcmyv0N"
|
|
#define DEVICE_NAME "mytestDevice3"
|
|
#define PRODUCT_SECRET "qHCMOWtZk5EJmHTW"
|
|
#else
|
|
//#define PRODUCT_KEY "fe416640c8e8a72734219e1847ad2547"
|
|
//#define DEVICE_NAME "123464"
|
|
//#define PRODUCT_SECRET "1ed09990d13a"
|
|
|
|
#ifndef ONLINE_PUBLISH
|
|
#define PRODUCT_KEY "c400b5654a73a5a1976c04910d79eebf" //"fe416640c8e8a72734219e1847ad2547"
|
|
#define PRODUCT_SECRET "42955254d3d5" //"1ed09990d13a"
|
|
#else
|
|
#define PRODUCT_KEY NETEASE_ONLINE_PRODUCT_KEY
|
|
#define PRODUCT_SECRET NETEASE_ONLINE_PRODUCT_SEC
|
|
#endif
|
|
#define DEVICE_NAME "b4adc6ce61294be28dcf83ccc6752f65"
|
|
|
|
#endif
|
|
#else
|
|
#if (MQTT_SERVER == MQTT_SERVER_ALIBABA)
|
|
#define PRODUCT_KEY "a1jc7l7KQjY"
|
|
#define DEVICE_NAME "mytestDevice1"
|
|
#define DEVICE_SECRET "khUFN53kYw5gzkshpTHwFPo0XGNp9uye"
|
|
#else
|
|
#if 0
|
|
#define PRODUCT_KEY "fe416640c8e8a72734219e1847ad2547"
|
|
#define DEVICE_NAME "b4adc6ce61294be28dcf83ccc6752f7b"
|
|
#define DEVICE_SECRET "86b03e03cf3f3c63a5c4ed8aa490acac"
|
|
#else
|
|
#define PRODUCT_KEY "fe416640c8e8a72734219e1847ad2547"
|
|
#define DEVICE_NAME "123457"
|
|
#define DEVICE_SECRET "c2ba57124c5cd9d28e726a3200d6afc1"
|
|
#endif
|
|
#endif
|
|
#endif
|
|
#endif
|
|
|
|
/* espressif Flash config */
|
|
#define RF_ADDR 0x1fc000 // more info see as gen_misc.sh step 5
|
|
// 0x1fc000 -> compile option 3: 2048KB(512KB + 512KB)
|
|
// 0x3fc000 -> compile option 4: 4096KB(512KB + 512KB)
|
|
// 0x1fc000 -> compile option 5: 2048KB(1024KB + 1024KB)
|
|
// 0x3fc000 -> compile option 6: 4096KB(1024KB + 1024KB)
|
|
#define SECTOR_SIZE 4096
|
|
#define PARAM_SAVE_DEVICENAME ((RF_ADDR - (16-0)*4096) / 4096)
|
|
#define PARAM_SAVE_DEVICESECRET ((RF_ADDR - (16-1)*4096) / 4096)
|
|
#define PARAM_SAVE_WIFIINFO ((RF_ADDR - (16-2)*4096) / 4096)
|
|
#define PARAM_SAVE_CONFIGURE ((RF_ADDR - (16-3)*4096) / 4096)
|
|
#define PARAM_SAVE_PRODUCTID ((RF_ADDR - (16-4)*4096) / 4096)
|
|
#define PARAM_SAVE_USERCFG ((RF_ADDR - (16-5)*4096) / 4096)
|
|
#define PARAM_SAVE_OTAINFO_TYPE ((RF_ADDR - (16-10)*4096) / 4096)
|
|
#define PARAM_SAVE_OTAINFO_WIFI ((RF_ADDR - (16-11)*4096) / 4096)
|
|
#define PARAM_SAVE_OTAINFO_MCU ((RF_ADDR - (16-12)*4096) / 4096)
|
|
|
|
enum{
|
|
MSG_DIRECTION_UART_UP,
|
|
MSG_DIRECTION_UART_DOWN,
|
|
MSG_DIRECTION_CLOUD_UP,
|
|
MSG_DIRECTION_CLOUD_DOWN,
|
|
MSG_DIRECTION_OTA_UP,
|
|
MSG_DIRECTION_OTA_DOWN,
|
|
MSG_DIRECTION_BDATA_UP,
|
|
MSG_DIRECTION_BDATA_DOWN,
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
char pSSID[MAX_WIFI_SSID];
|
|
char pPassword[MAX_WIFI_PASSWD];
|
|
} STA_WIFI_CONFIG, *PSTA_WIFI_CONFIG;
|
|
|
|
typedef struct
|
|
{
|
|
int authMode;
|
|
int svrPort;
|
|
char pPassword[MAX_WIFI_PASSWD];
|
|
} SOFTAP_WIFI_CONFIG, *PSOFTAP_WIFI_CONFIG;
|
|
|
|
typedef struct
|
|
{
|
|
char* ProductKey;
|
|
char* ProductSecury;
|
|
char* MQTTServer;
|
|
unsigned short MQTTPort;
|
|
char* HTTPSServer;
|
|
} SERVER_CFG, *PSERVER_CFG;
|
|
|
|
typedef struct
|
|
{
|
|
char* IPAddr;
|
|
char* Netmask;
|
|
char* Gatway;
|
|
char* DHCPStartIP;
|
|
char* DHCPEndIP;
|
|
} SOFTAP_DHCP, *PSOFTAP_DHCP;
|
|
|
|
typedef struct
|
|
{
|
|
char* pSSID;
|
|
char* pPassword;
|
|
} WIFIAP_CONFIG, *PWIFIAP_CONFIG;
|
|
|
|
typedef struct
|
|
{
|
|
unsigned short UDPSvrPort;
|
|
char* SoftAPFormat;
|
|
SOFTAP_DHCP softAPDHCP;
|
|
} SOFTAP_CONFIG, *PSOFTAP_CONFIG;
|
|
|
|
typedef struct
|
|
{
|
|
int Baud;
|
|
int DataBits;
|
|
int StopBits;
|
|
int Parity;
|
|
int FlowCtrl;
|
|
} UART_CFG, *PUART_CFG;
|
|
|
|
typedef struct
|
|
{
|
|
int Id;
|
|
int Func;
|
|
int Dir;
|
|
int PullUp;
|
|
int Interrupt;
|
|
} GPIO_ITEM, *PGPIO_ITEM;
|
|
|
|
typedef struct
|
|
{
|
|
int iSize;
|
|
PGPIO_ITEM pGpioCfg;
|
|
} GPIO_CFG, *PGPIO_CFG;
|
|
|
|
typedef struct
|
|
{
|
|
int UsedDefault;
|
|
int Version;
|
|
int FactoryMode;
|
|
int DeviceType;
|
|
char* DeviceName;
|
|
SERVER_CFG ServerCfg;
|
|
SOFTAP_CONFIG SoftAP;
|
|
WIFIAP_CONFIG WifiAP;
|
|
UART_CFG UART[2];
|
|
GPIO_CFG GPIO;
|
|
} USER_CONFIG, *PUSER_CONFIG;
|
|
|
|
typedef struct
|
|
{
|
|
char pCfgTagsInfo[MAX_MD5_STRING];
|
|
STA_WIFI_CONFIG staWifiCfg;
|
|
SOFTAP_WIFI_CONFIG softapWifiCfg;
|
|
} GLOGAL_CONFIG, *PGLOGAL_CONFIG;
|
|
|
|
void CfgInitEnv(void);
|
|
void ShowCfgConfigure(void);
|
|
GLOGAL_CONFIG * ne_get_cfg_data(void);
|
|
PUSER_CONFIG ne_cfg_get_user_cfg(void);
|
|
|
|
#define USR_CFG_FACTORY_MODE() (ne_cfg_get_user_cfg()->FactoryMode)
|
|
#define USR_CFG_DEVICE_TYPE() (ne_cfg_get_user_cfg()->DeviceType)
|
|
#define USR_CFG_DEVICE_NAME() (ne_cfg_get_user_cfg()->DeviceName)
|
|
#define USR_CFG_SERVER(key) (ne_cfg_get_user_cfg()->ServerCfg.key)
|
|
#define USR_CFG_WIFIAP(key) (ne_cfg_get_user_cfg()->WifiAP.key)
|
|
#define USR_CFG_SOFTAP(key) (ne_cfg_get_user_cfg()->SoftAP.key)
|
|
#define USR_CFG_SOFTAP_DHCP(key) (ne_cfg_get_user_cfg()->SoftAP.softAPDHCP.key)
|
|
#define USR_CFG_UART(id, key) (ne_cfg_get_user_cfg()->UART[id].key)
|
|
#endif
|