|
@@ -1,15 +1,29 @@
|
|
|
+#ifndef HTTP_SERVER_H
|
|
|
+#define HTTP_SERVER_H
|
|
|
+
|
|
|
#if defined HARDWARE_BT6706 || HARDWARE_BT6708
|
|
|
|
|
|
#include "lwip/api.h"
|
|
|
-
|
|
|
#include "mbedtls/ssl.h"
|
|
|
+
|
|
|
+#define HTTP_AUTH_ENABLE
|
|
|
|
|
|
#define SSL_TASK_PRIO ( configMAX_PRIORITIES - 3 )
|
|
|
#define FRAME_SIZE (1000)
|
|
|
|
|
|
+#define SEND_BUF_MAX_LEN 4000
|
|
|
+#define RECIVE_BUF_MAX_LEN 1500
|
|
|
+
|
|
|
+typedef enum
|
|
|
+{
|
|
|
+ ALL_ACCESS = 0,
|
|
|
+ TIME_ACCESS
|
|
|
+} ACCESS_TYPE_t;
|
|
|
+
|
|
|
typedef enum
|
|
|
{
|
|
|
COMMON_ANSWER = 0,
|
|
|
+ PARAMETER_ANSWER,
|
|
|
HISTORY_ANSWER,
|
|
|
UPS_HISTORY_ANSWER
|
|
|
|
|
@@ -26,6 +40,8 @@ struct http_state
|
|
|
{
|
|
|
char *file;
|
|
|
u32_t left;
|
|
|
+ u32_t reqnum;
|
|
|
+ void *locked;
|
|
|
};
|
|
|
|
|
|
struct fs_file {
|
|
@@ -35,10 +51,6 @@ struct fs_file {
|
|
|
|
|
|
void HTTP_Init();
|
|
|
|
|
|
-static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err);
|
|
|
-static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* @brief Выводим запросы в консоль
|
|
|
*/
|
|
@@ -47,7 +59,7 @@ void vTaskPrintHttp(void *pvParameters);
|
|
|
/**
|
|
|
* @brief Установка даты производства
|
|
|
*/
|
|
|
-void HTTP_Prodate(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
+void HTTP_Prodate(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
|
|
|
/**
|
|
|
* @brief Парсинг строки настроек
|
|
@@ -62,39 +74,79 @@ void HTTP_SetInfo(char *buf, uint16_t lenBuf);
|
|
|
/**
|
|
|
* @brief
|
|
|
*/
|
|
|
-int HTTP_SettingsPage(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
+char* HTTP_SetSettingsPage(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
|
|
|
/**
|
|
|
* @brief
|
|
|
*/
|
|
|
-int HTTP_InfoPage(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
+char* HTTP_SetInfoPage(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
|
|
|
+#ifdef HTTP_AUTH_ENABLE
|
|
|
+/**
|
|
|
+ * @brief
|
|
|
+ */
|
|
|
+char* HTTP_LoginPage(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief
|
|
|
+ */
|
|
|
+char* HTTP_LogoutPage(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
+#endif
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief
|
|
|
+ */
|
|
|
+char* HTTP_UpsHistoryPage(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief
|
|
|
+ */
|
|
|
+char* HTTP_HistoryPage(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief
|
|
|
+ */
|
|
|
+char* HTTP_Reset(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
|
|
|
-int HTTP_UpsHistoryPage(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
+/**
|
|
|
+ * @brief
|
|
|
+ */
|
|
|
+char* HTTP_Reboot(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
|
|
|
-int HTTP_HistoryPage(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
+/**
|
|
|
+ * @brief
|
|
|
+ */
|
|
|
+char* HTTP_Confirm(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
|
|
|
/**
|
|
|
* @brief Запуск/останов теста UPS
|
|
|
*/
|
|
|
-void HTTP_UPSTest(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
+char* HTTP_UPSTest(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
|
|
|
/**
|
|
|
* @brief Выклюение UPS
|
|
|
*/
|
|
|
-void HTTP_UPSshutdown(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
+char* HTTP_UPSshutdown(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
|
|
|
/**
|
|
|
* @brief Проверка пароля для перехода в режим bootloader
|
|
|
*/
|
|
|
-void HTTP_ConfirmBootPwd(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
+char* HTTP_ConfirmBootPwd(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
|
|
|
/**
|
|
|
* @brief Проверка пароля для входа в Web
|
|
|
*/
|
|
|
int HTTP_ConfirmWebPwd(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
|
|
|
-void HTTP_LOGIN(char *bufOut, uint16_t *lenBufOut);
|
|
|
+/**
|
|
|
+ * @brief
|
|
|
+ */
|
|
|
+char* HTTP_GetRequest(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief
|
|
|
+ */
|
|
|
+char* HTTP_NoFound(uint32_t reqNum, char *bufIn, char *bufOut, uint32_t lenBufIn, uint32_t *lenBufOut);
|
|
|
|
|
|
/**
|
|
|
* @brief
|
|
@@ -111,32 +163,6 @@ uint8_t GetParamValueInEnd(char *inStr, char *paramName, char *paramValue, uint8
|
|
|
|
|
|
void ClearParamString(char *inBuf);
|
|
|
|
|
|
-/**
|
|
|
- * @brief Замена символа в строке
|
|
|
- * @param *str - входная строка
|
|
|
- * @param sim1 - символ который надо заменить
|
|
|
- * @param sim2 - символ на который надо заменить
|
|
|
- */
|
|
|
-void HTTP_ReplaceSimbol(char *str, char sim1, char sim2);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-#ifdef __cplusplus
|
|
|
- extern "C" {
|
|
|
#endif
|
|
|
|
|
|
-
|
|
|
-void Cockie(void);
|
|
|
-void getAuthenticatedState(void);
|
|
|
-
|
|
|
-
|
|
|
-char* HTTP_SendHistory(uint16_t *Len);
|
|
|
-char* HTTP_SendLog(uint16_t *Len);
|
|
|
-char* AuthenticatedFalseRoutine(uint16_t* sendLen);
|
|
|
-char* AuthenticatedTrueRoutine(uint16_t* sendLen);
|
|
|
-
|
|
|
-#ifdef __cplusplus
|
|
|
-}
|
|
|
-#endif
|
|
|
-
|
|
|
-#endif
|
|
|
+#endif /* HTTP_SERVER_H */
|