stash
This commit is contained in:
parent
8ffae0b66f
commit
3098c8f1ab
2 changed files with 54 additions and 50 deletions
|
@ -21,6 +21,7 @@
|
|||
#include "lux.h"
|
||||
|
||||
|
||||
|
||||
#define SNTP_SERVERS "0.pool.ntp.org", "1.pool.ntp.org", \
|
||||
"2.pool.ntp.org", "3.pool.ntp.org"
|
||||
|
||||
|
@ -252,7 +253,7 @@ void user_init(void) {
|
|||
sdk_wifi_set_opmode(wifi_mode);
|
||||
|
||||
if(wifi_sta_enable) {
|
||||
printf("try STA Mode\n");
|
||||
printf("try STA Mode: %s %s\n", wifi_sta_ssid, wifi_sta_password);
|
||||
struct sdk_station_config config;
|
||||
strcpy((char *) config.ssid, wifi_sta_ssid);
|
||||
strcpy((char *) config.password, wifi_sta_password);
|
||||
|
@ -289,7 +290,7 @@ void user_init(void) {
|
|||
}
|
||||
|
||||
if(wifi_ap_enable) {
|
||||
printf("try AP Mode\n");
|
||||
printf("try AP Mode: %s %s\n", wifi_ap_ssid, wifi_ap_password);
|
||||
/* Read and validate paramenters. */
|
||||
int8_t wifi_ap_ssid_hidden = 0;
|
||||
sysparam_get_int8("wifi_ap_ssid_hidden", &wifi_ap_ssid_hidden);
|
||||
|
@ -402,12 +403,12 @@ void user_init(void) {
|
|||
/* turn off LED */
|
||||
//gpio_enable(LED_PIN, GPIO_OUTPUT);
|
||||
//gpio_write(LED_PIN, true);
|
||||
xTaskCreate(&lux_task, "lux_task", 256, NULL, 2, NULL);
|
||||
xTaskCreate(&lux_task, "lux_task", 256, NULL, 1, NULL);
|
||||
|
||||
/* initialize tasks */
|
||||
xTaskCreate(&httpd_task, "&httpd_task", 2048, NULL, 2, NULL);
|
||||
xTaskCreate(&httpd_task, "httpd_task", 2048, NULL, 3, NULL);
|
||||
|
||||
xTaskCreate(&sntp_task, "SNTP", 512, NULL, 1, NULL);
|
||||
xTaskCreate(&sntp_task, "SNTP", 512, NULL, 2, NULL);
|
||||
}
|
||||
>>>>>>> 4b8d354 (basic webconf)
|
||||
}
|
||||
|
|
|
@ -11,9 +11,12 @@
|
|||
#include <string.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
|
||||
extern "C" {
|
||||
#include <sysparam.h>
|
||||
#include <lwipopts.h>
|
||||
}
|
||||
|
||||
#include <espressif/esp_common.h>
|
||||
|
||||
#include <lwip/tcp.h>
|
||||
|
@ -31,9 +34,10 @@ struct {
|
|||
} has_changed;
|
||||
|
||||
void websocket_task(void *pvParameter) {
|
||||
struct tcp_pcb *pcb = (struct tcp_pcb *) pvParameter;
|
||||
auto *pcb = (struct tcp_pcb *) pvParameter;
|
||||
|
||||
int connstarttime = xTaskGetTickCount();
|
||||
size_t connstarttime = xTaskGetTickCount();
|
||||
has_changed = {true, true, true};
|
||||
|
||||
for (;;) {
|
||||
if(pcb == NULL || pcb->state != ESTABLISHED) {
|
||||
|
@ -43,8 +47,8 @@ void websocket_task(void *pvParameter) {
|
|||
|
||||
|
||||
//Global Info
|
||||
if(has_changed.global){
|
||||
struct timeval tv;
|
||||
if(has_changed.global) {
|
||||
timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
int uptime = xTaskGetTickCount() * portTICK_PERIOD_MS / 1000;
|
||||
int heap = (int) xPortGetFreeHeapSize();
|
||||
|
@ -78,8 +82,8 @@ void websocket_task(void *pvParameter) {
|
|||
|
||||
|
||||
//Connection Info
|
||||
if(has_changed.connection){
|
||||
struct timeval tv;
|
||||
if(has_changed.connection) {
|
||||
timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
int connuptime = (xTaskGetTickCount() - connstarttime) * portTICK_PERIOD_MS / 1000;
|
||||
|
||||
|
@ -104,8 +108,7 @@ void websocket_task(void *pvParameter) {
|
|||
vTaskDelayMs(2000);
|
||||
}
|
||||
|
||||
|
||||
if(has_changed.wifi){
|
||||
if(has_changed.wifi) {
|
||||
uint8_t opmode = sdk_wifi_get_opmode();
|
||||
const char *opmode_str = "??";
|
||||
switch (opmode) {
|
||||
|
@ -136,7 +139,7 @@ void websocket_task(void *pvParameter) {
|
|||
if(opmode == SOFTAP_MODE || opmode == STATIONAP_MODE) {
|
||||
uint8_t hwaddr[6];
|
||||
sdk_wifi_get_macaddr(SOFTAP_IF, hwaddr);
|
||||
struct ip_info info;
|
||||
ip_info info;
|
||||
sdk_wifi_get_ip_info(SOFTAP_IF, &info);
|
||||
|
||||
char *apssid = NULL;
|
||||
|
@ -168,7 +171,7 @@ void websocket_task(void *pvParameter) {
|
|||
if(opmode == STATION_MODE || opmode == STATIONAP_MODE) {
|
||||
uint8_t hwaddr[6];
|
||||
sdk_wifi_get_macaddr(STATION_IF, hwaddr);
|
||||
struct ip_info info;
|
||||
ip_info info;
|
||||
sdk_wifi_get_ip_info(STATION_IF, &info);
|
||||
char *stassid = NULL;
|
||||
sysparam_get_string("wifi_sta_ssid", &stassid);
|
||||
|
|
Loading…
Reference in a new issue