implemented example of using user defined variables
This commit is contained in:
parent
e7e2c513b7
commit
54eaadf551
|
|
@ -1 +1 @@
|
|||
Subproject commit e8150202106520873416794e0bce0f505b8d79d2
|
||||
Subproject commit 4ec665e5d97a3762a403291ea6978210554c5bad
|
||||
|
|
@ -60,5 +60,6 @@ esp_err_t ResetInitAppConfig(void);
|
|||
|
||||
void LoadDefaultReset(void);
|
||||
void DelayedRestart(void);
|
||||
void RegAppVariables(void);
|
||||
|
||||
#endif /* MAIN_INCLUDE_APPCONFIGURATION_H_ */
|
||||
|
|
|
|||
|
|
@ -24,11 +24,8 @@
|
|||
|
||||
#include "webguiapp.h"
|
||||
#include "esp_err.h"
|
||||
#include "jRead.h"
|
||||
#include "jWrite.h"
|
||||
#include "AppConfiguration.h"
|
||||
|
||||
#define EXPECTED_MAX_DATA_RESPONSE_SIZE (2048)
|
||||
#include "SystemApplication.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
|
@ -71,6 +68,7 @@ int key2;
|
|||
#define DATA_MESSAGE_TYPE_REQUEST (2)
|
||||
#define DATA_MESSAGE_TYPE_RESPONSE (3)
|
||||
|
||||
/*
|
||||
typedef struct
|
||||
{
|
||||
char *inputDataBuffer;
|
||||
|
|
@ -89,6 +87,7 @@ typedef struct
|
|||
} parsedData;
|
||||
int err_code;
|
||||
} data_message_t;
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ void app_main(void)
|
|||
regUserEventHandler(&UserMQTTEventHndlr, (void*)my_context_data);
|
||||
regTimeSyncCallback(&TimeObtainHandler);
|
||||
|
||||
RegAppVariables();
|
||||
|
||||
WebGuiAppInit();
|
||||
if (GetUserAppNeedReset())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
#define STORAGE_NAMESPACE "storage"
|
||||
#define TAG "AppConfiguration"
|
||||
|
||||
static APP_CONFIG AppConfig;
|
||||
APP_CONFIG AppConfig;
|
||||
|
||||
void UserAppInit(void)
|
||||
{
|
||||
|
|
|
|||
49
main/src/RestApiHandlersApp.c
Normal file
49
main/src/RestApiHandlersApp.c
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*! Copyright 2023 Bogdan Pilyugin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* \file RestApiHandlersApp.c
|
||||
* \version 1.0
|
||||
* \date 2023-08-17
|
||||
* \author Bogdan Pilyugin
|
||||
* \brief
|
||||
* \details
|
||||
* \copyright Apache License, Version 2.0
|
||||
*/
|
||||
|
||||
#include "Application.h"
|
||||
#include "SystemApplication.h"
|
||||
|
||||
extern APP_CONFIG AppConfig;
|
||||
|
||||
static void funct_time(char *argres, int rw)
|
||||
{
|
||||
time_t now;
|
||||
time(&now);
|
||||
snprintf(argres, MAX_DYNVAR_LENGTH, "%d", (int) now);
|
||||
}
|
||||
|
||||
const rest_var_t ApplicationVariables[] =
|
||||
{
|
||||
/*FUNCTIONS*/
|
||||
{ 0, "mytime", &funct_time, VAR_FUNCT, R, 0, 0 },
|
||||
{ 0, "myvar", &AppConfig.test, VAR_INT, R, 0, 0 }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
void RegAppVariables(void)
|
||||
{
|
||||
SetAppVars((rest_var_t*)ApplicationVariables, sizeof(ApplicationVariables) / sizeof(rest_var_t));
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user