mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-05-06 13:24:06 +00:00
@ -27,6 +27,8 @@
|
||||
#include "../httpserver/new_http.h"
|
||||
#include "common_math.h"
|
||||
|
||||
extern int DRV_SSDP_Active;
|
||||
|
||||
static const char* ssdp_group = "239.255.255.250";
|
||||
static int ssdp_port = 1900;
|
||||
|
||||
@ -325,6 +327,7 @@ static int DRV_SSDP_Service_Http(http_request_t* request){
|
||||
|
||||
void DRV_SSDP_Init()
|
||||
{
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_HTTP,"DRV_SSDP_Init");
|
||||
// like "e427ce1a-3e80-43d0-ad6f-89ec42e46363";
|
||||
sprintf(g_ssdp_uuid, "%08x-%04x-%04x-%04x-%04x%08x",
|
||||
(unsigned int)rand(),
|
||||
@ -338,6 +341,8 @@ void DRV_SSDP_Init()
|
||||
DRV_SSDP_CreateSocket_Receive();
|
||||
HTTP_RegisterCallback("/ssdp.xml", HTTP_GET, DRV_SSDP_Service_Http);
|
||||
//CMD_RegisterCommand("SSDPNotify", "", CMD_SSDP_Notify, "qqq", NULL);
|
||||
|
||||
DRV_SSDP_Active = 1;
|
||||
}
|
||||
|
||||
void DRV_SSDP_RunEverySecond() {
|
||||
@ -403,8 +408,10 @@ void DRV_SSDP_RunQuickTick() {
|
||||
}
|
||||
|
||||
|
||||
void DRV_SSDP_Shutdown()
|
||||
{
|
||||
void DRV_SSDP_Shutdown(){
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_HTTP,"DRV_SSDP_Shutdown");
|
||||
DRV_SSDP_Active = 0;
|
||||
|
||||
if(g_ssdp_socket_receive>=0) {
|
||||
close(g_ssdp_socket_receive);
|
||||
g_ssdp_socket_receive = -1;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
extern int DRV_SSDP_Active;
|
||||
|
||||
|
||||
void DRV_SSDP_RunEverySecond();
|
||||
void DRV_SSDP_RunQuickTick();
|
||||
void DRV_SSDP_Shutdown();
|
||||
void DRV_SSDP_Init();
|
||||
extern void DRV_SSDP_Init();
|
||||
extern void DRV_SSDP_RunEverySecond();
|
||||
extern void DRV_SSDP_RunQuickTick();
|
||||
extern void DRV_SSDP_Shutdown();
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
|
||||
|
||||
#include "driver/drv_ntp.h"
|
||||
#include "driver/drv_ssdp.h"
|
||||
|
||||
#ifdef PLATFORM_BEKEN
|
||||
void bg_register_irda_check_func(FUNCPTR func);
|
||||
@ -65,6 +66,8 @@ static int g_bPingWatchDogStarted = 0;
|
||||
|
||||
uint32_t idleCount = 0;
|
||||
|
||||
int DRV_SSDP_Active = 0;
|
||||
|
||||
#define LOG_FEATURE LOG_FEATURE_MAIN
|
||||
|
||||
|
||||
@ -122,19 +125,29 @@ int Time_getUpTimeSeconds() {
|
||||
|
||||
|
||||
static char scheduledDriverName[4][16];
|
||||
static int scheduledDelay[4] = {-1};
|
||||
static int scheduledDelay[4] = {-1, -1, -1, -1};
|
||||
static void ScheduleDriverStart(const char *name, int delay) {
|
||||
for (int i = 0; i < 4; i++){
|
||||
// if already scheduled, just change delay.
|
||||
if (!strcmp(scheduledDriverName[i], name)){
|
||||
scheduledDelay[i] = delay;
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; i++){
|
||||
// first empty slot
|
||||
if (scheduledDelay[i] == -1){
|
||||
scheduledDelay[i] = delay;
|
||||
strcpy(scheduledDriverName[i],name);
|
||||
strncpy(scheduledDriverName[i], name, 16);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Main_OnWiFiStatusChange(int code)
|
||||
{
|
||||
|
||||
// careful what you do in here.
|
||||
// e.g. creata socket? probably not....
|
||||
switch(code)
|
||||
{
|
||||
case WIFI_STA_CONNECTING:
|
||||
@ -166,8 +179,16 @@ void Main_OnWiFiStatusChange(int code)
|
||||
g_bHasWiFiConnected = 1;
|
||||
ADDLOGF_INFO("Main_OnWiFiStatusChange - WIFI_STA_CONNECTED\r\n");
|
||||
|
||||
if(bSafeMode == 0 && strlen(CFG_DeviceGroups_GetName())>0){
|
||||
ScheduleDriverStart("DGR",5);
|
||||
if(bSafeMode == 0){
|
||||
if(strlen(CFG_DeviceGroups_GetName())>0){
|
||||
ScheduleDriverStart("DGR",5);
|
||||
}
|
||||
// if SSDP should be active,
|
||||
// restart it now.
|
||||
if (DRV_SSDP_Active){
|
||||
ScheduleDriverStart("SSDP",5);
|
||||
//DRV_SSDP_Restart(); // this kills things
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@ -281,6 +302,7 @@ void Main_OnEverySecond()
|
||||
DRV_StopDriver(scheduledDriverName[i]);
|
||||
DRV_StartDriver(scheduledDriverName[i]);
|
||||
#endif
|
||||
scheduledDriverName[i][0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user