all user callbacks moved to one header UserCallbacks.h;
added callback notify current time obtained
This commit is contained in:
parent
37d410623c
commit
1484f63477
|
|
@ -86,9 +86,6 @@ typedef struct
|
|||
void (*HandlerRoutine)(char *VarData, void *arg);
|
||||
} dyn_var_handler_t;
|
||||
|
||||
void regHTTPPrintCustom(int (*print_handler)(httpd_req_t *req, char *buf, char *var, int arg));
|
||||
void regAfterPostHandlerCustom(HTTP_IO_RESULT (*post_handler)(httpd_req_t *req, const char *filename, char *PostData));
|
||||
|
||||
esp_err_t start_file_server(void);
|
||||
HTTP_IO_RESULT HTTPPostApp(httpd_req_t *req, const char *filename, char *PostData);
|
||||
int HTTPPrint(httpd_req_t *req, char* buf, char* var);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ typedef struct
|
|||
mqtt_client_t* GetMQTTHandlesPool(int idx);
|
||||
QueueHandle_t GetMQTTSendQueue(int idx);
|
||||
void ComposeTopic(char *topic, int idx, char *service_name, char *direct);
|
||||
void regUserEventHandler(void (*event_handler)(int idx, void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data), void* user_arg);
|
||||
void SystemDataHandler(char *data, uint32_t len, int idx);
|
||||
|
||||
mqtt_app_err_t PublicTestMQTT(int idx);
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@ void GetRFC3339Time(char *t);
|
|||
void StartTimeGet(void);
|
||||
|
||||
esp_err_t StartOTA(void);
|
||||
void regHookBeforeUpdate(void (*before_update)(void));
|
||||
char* GetAvailVersion();
|
||||
char* GetUpdateStatus();
|
||||
|
||||
|
|
|
|||
42
include/UserCallbacks.h
Normal file
42
include/UserCallbacks.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* 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 name: UserCallbacks.h
|
||||
* Project: webguiapp_ref_implement
|
||||
* Created on: 2023-04-22
|
||||
* Author: bogdan
|
||||
* Description:
|
||||
*/
|
||||
|
||||
#ifndef COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_
|
||||
#define COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_
|
||||
#include "HTTPServer.h"
|
||||
|
||||
//Callback for current time obtain notification
|
||||
void regTimeSyncCallback(void (*time_sync)(struct timeval *tv));
|
||||
|
||||
//Callback called just before OTA, aimed user can finish all job must finished on update and reboot
|
||||
void regHookBeforeUpdate(void (*before_update)(void));
|
||||
|
||||
//MQTT incoming data callback
|
||||
void regUserEventHandler(void (*event_handler)(int idx, void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data), void* user_arg);
|
||||
|
||||
//User handler of output '~var~' styled dynamic variables. Calls on give out files in response to GET requests.
|
||||
void regHTTPPrintCustom(int (*print_handler)(httpd_req_t *req, char *buf, char *var, int arg));
|
||||
|
||||
//User handler of variables 'var1=value1&var2=value2' styled in POST requests.
|
||||
void regAfterPostHandlerCustom(HTTP_IO_RESULT (*post_handler)(httpd_req_t *req, const char *filename, char *PostData));
|
||||
|
||||
|
||||
#endif /* COMPONENTS_WEBGUIAPP_INCLUDE_USERCALLBACKS_H_ */
|
||||
|
|
@ -34,6 +34,8 @@
|
|||
#include "esp_system.h"
|
||||
#include "driver/spi_master.h"
|
||||
|
||||
#include "UserCallbacks.h"
|
||||
|
||||
esp_err_t spi_device_polling_transmit_synchronized(spi_device_handle_t handle, spi_transaction_t *trans_desc);
|
||||
|
||||
bool GetUserAppNeedReset(void);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "LoRaWAN.h"
|
||||
#include "Helpers.h"
|
||||
#include "MQTT.h"
|
||||
#include "UserCallbacks.h"
|
||||
|
||||
static const char *TAG = "HTTPServerPost";
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "romfs.h"
|
||||
#include "esp_idf_version.h"
|
||||
#include "jWrite.h"
|
||||
#include "UserCallbacks.h"
|
||||
|
||||
static const char *TAG = "HTTPServerPrint";
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "Helpers.h"
|
||||
#include "NetTransport.h"
|
||||
#include "MQTT.h"
|
||||
#include "UserCallbacks.h"
|
||||
|
||||
#define MQTT_DEBUG_MODE 1
|
||||
|
||||
|
|
|
|||
12
src/SNTP.c
12
src/SNTP.c
|
|
@ -22,10 +22,19 @@
|
|||
#include "esp_sntp.h"
|
||||
#include "esp_timer.h"
|
||||
#include "NetTransport.h"
|
||||
#include "UserCallbacks.h"
|
||||
#define YEAR_BASE (1900) //tm structure base year
|
||||
|
||||
static uint32_t UpTime = 0;
|
||||
|
||||
//Pointer to extend user on time got callback
|
||||
static void (*time_sync_notif)(struct timeval *tv) = NULL;
|
||||
|
||||
void regTimeSyncCallback(void (*time_sync)(struct timeval *tv))
|
||||
{
|
||||
time_sync_notif = time_sync;
|
||||
}
|
||||
|
||||
static void initialize_sntp(void);
|
||||
|
||||
|
||||
|
|
@ -52,7 +61,8 @@ static void obtain_time(void *pvParameter)
|
|||
|
||||
static void time_sync_notification_cb(struct timeval *tv)
|
||||
{
|
||||
|
||||
if(time_sync_notif)
|
||||
time_sync_notif(tv);
|
||||
}
|
||||
|
||||
static void initialize_sntp(void)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user