Default light off.

Moved receive tasks to be handled by main tasks.
parent 2021e18c
......@@ -61,12 +61,6 @@ void app_main()
ESP_LOGI(TAG,"FATFS SHA256: %s", fs_sha256);
ESP_LOGI(TAG,"***************************************************");
/**
* @brief Set the log level for serial port printing.
*/
/**
* @brief Initialize wifi mesh.
*/
if(config_reader_get_mesh_type() == MESH_ROOT)
{
......
......@@ -60,7 +60,7 @@ void config_reader_module_init(void)
nvs_ok |= nvs_get_str(handle, "STA_SSID", sta_ssid, &ssid_len);
nvs_ok |= nvs_get_str(handle, "STA_PASS", sta_pass, &pass_len);
//if(nvs_ok != ESP_OK)
if(nvs_ok != ESP_OK)
{
config_reader_set_sta("Osteklokken", "hamsterpenis");
}
......
......@@ -36,7 +36,7 @@ strand_t* strand_right = &strands[1];
strand_t* strand_debug = &strands[2];
static light_mode_type_t light_mode = LIGHT_MODE_OFF;
static float strength = 1.f;
static pixelColor_t color = {.num = 0xFFFFFFFF};
static pixelColor_t color = {.num = 0x00000000};
static TickType_t next_update;
static uint16_t led_len_left;
......@@ -249,7 +249,7 @@ void light_control_step(void)
{
next_update = xTaskGetTickCount() + 5;
update_lengths();
bool refresh = false;
switch(light_mode)
{
......@@ -272,7 +272,7 @@ void light_control_step(void)
refresh = frequency_control_module_panel_step(&panel_left, &panel_right, color);
break;
case LIGHT_MODE_TETRIS:
refresh = tetris_light_control_module_step(&panel_left, &panel_right);
//refresh = tetris_light_control_module_step(&panel_left, &panel_right);
break;
case LIGHT_MODE_GAME_OF_LIFE:
refresh = gol_light_control_module_step(&panel_left, &panel_right);
......
......@@ -18,7 +18,7 @@ static light_mode_type_t local_mode = LIGHT_MODE_OFF;
static bool is_mode_global = true;
static TickType_t next_update = 0;
static float strength = 1.0F;
static pixelColor_t color = {.num = 0xFFFFFFFF};
static pixelColor_t color = {.num = 0x00000000};
__attribute__((unused)) static const char *TAG = "LIGHT_MANAGEMENT";
#define MODE_PUBLISH_INTERVAL 1000
......@@ -39,9 +39,9 @@ int light_management_module_init(void)
nvs_open("LED_EQ", NVS_READWRITE, &handle);
int nvs_read_ok = ESP_OK;
uint8_t _is_mode_global;
uint8_t _local_mode;
uint8_t _global_mode;
uint8_t _is_mode_global = true;
uint8_t _local_mode = LIGHT_MODE_OFF;;
uint8_t _global_mode = LIGHT_MODE_OFF;;
nvs_read_ok |= nvs_get_u8(handle, "is_mode_global", &_is_mode_global);
nvs_read_ok |= nvs_get_u8(handle, "local_mode", &_local_mode);
nvs_read_ok |= nvs_get_u8(handle, "global_mode", &_global_mode);
......
......@@ -10,7 +10,6 @@
__attribute__((unused)) static const char *TAG = "MESH MODULE NODE";
static void node_read_task(void *arg);
static void node_write_task(void *arg);
static QueueHandle_t node_send_queue = NULL;
......@@ -23,40 +22,33 @@ int mesh_node_module_init(void)
xTaskCreate(node_write_task, "node_write_task", 4 * 1024,
NULL, 20, NULL);
xTaskCreate(node_read_task, "node_read_task", 4* 1024,
NULL, 30, NULL);
return 0;
}
void node_read_task(void *arg)
void node_read_task(void)
{
uint8_t buf[1500];
mesh_data_t data;
data.data = malloc(1500);
data.size = 1500;
data.proto = MESH_PROTO_BIN;
data.tos = MESH_TOS_P2P;
data.data = buf;
data.size = 1500;
data.proto = MESH_PROTO_BIN;
data.tos = MESH_TOS_P2P;
int flag = 0;
mesh_addr_t src;
light_mesh_message_t light_mesh_msg;
ESP_LOGI(TAG,"Node read task is running");
while(1) {
if (!mesh_is_connected()) {
vTaskDelay(500 / portTICK_RATE_MS);
continue;
return;
}
data.size = 1500;
esp_mesh_recv(&root_addr, &data, portMAX_DELAY, &flag, NULL, 0);
if(esp_mesh_recv(&root_addr, &data, 0, &flag, NULL, 0) == ESP_ERR_MESH_TIMEOUT)
{
return;
}
protocol_module_esp_mesh_to_light_mesh(&light_mesh_msg, &root_addr, data.size, data.data);
message_handler_module_handle_message(&light_mesh_msg);
}
ESP_LOGW(TAG, "Note read task is exit");
free(data.data);
vTaskDelete(NULL);
}
void node_write_task(void *arg)
......@@ -81,8 +73,7 @@ void node_write_task(void *arg)
free(light_mesh_msg.payload);
if(mesh_is_connected())
{
mesh_opt_t opt;
esp_err_t ret = esp_mesh_send(NULL, &data, 0, NULL, 0);
esp_mesh_send(NULL, &data, 0, NULL, 0);
}
}
......
......@@ -3,3 +3,4 @@
int mesh_node_module_init(void);
void send_to_root(light_mesh_message_type_t message_type, void *payload, uint16_t payload_len);
void node_read_task(void);
\ No newline at end of file
......@@ -11,7 +11,6 @@
__attribute__((unused)) static const char *TAG = "MESH MODULE_ROOT";
static void root_receive_task(void *arg);
static void root_send_task(void *arg);
static QueueHandle_t root_send_queue = NULL;
......@@ -21,8 +20,6 @@ int mesh_root_module_init(void)
message_handle_module_init();
root_send_queue = xQueueCreate(QUEUE_LENGHT, sizeof(light_mesh_message_t));
esp_mesh_set_type(MESH_ROOT);
xTaskCreatePinnedToCore(root_receive_task, "root_receive_task", 2 * 1024,
NULL, 30, NULL, 0);
xTaskCreatePinnedToCore(root_send_task, "root_send_task", 2 * 1024,
NULL, 20, NULL, 0);
......@@ -30,46 +27,40 @@ int mesh_root_module_init(void)
}
void root_receive_task(void *arg)
void root_receive_task(void)
{
uint8_t buf[1500];
mesh_data_t data;
data.data = malloc(1500);
data.size = 1500;
data.proto = MESH_PROTO_BIN;
data.tos = MESH_TOS_DEF;
data.data = buf;
data.size = 1500;
data.proto = MESH_PROTO_BIN;
data.tos = MESH_TOS_DEF;
int flag = 0;
mesh_addr_t src;
light_mesh_message_t light_mesh_msg;
ESP_LOGI(TAG,"Root is running");
while(1) {
if (!mesh_is_started()) {
vTaskDelay(500 / portTICK_RATE_MS);
continue;
}
data.size = 1500;
esp_err_t ret = esp_mesh_recv(&src, &data, portMAX_DELAY, &flag, NULL, 0);
if(ret != ESP_OK)
{
ESP_LOGI(TAG, "Failed to recv: %s", esp_err_to_name(ret));
}
else
{
protocol_module_esp_mesh_to_light_mesh(&light_mesh_msg, &src, data.size, data.data);
message_handler_module_handle_message(&light_mesh_msg);
}
if (!mesh_is_started()) {
return;
}
ESP_LOGW(TAG, "Root receive is exit");
free(data.data);
vTaskDelete(NULL);
data.size = 1500;
esp_err_t ret = esp_mesh_recv(&src, &data, 0, &flag, NULL, 0);
if(ret == ESP_ERR_MESH_TIMEOUT)
{
return;
}
if(ret != ESP_OK)
{
ESP_LOGI(TAG, "Failed to recv: %s", esp_err_to_name(ret));
}
else
{
protocol_module_esp_mesh_to_light_mesh(&light_mesh_msg, &src, data.size, data.data);
message_handler_module_handle_message(&light_mesh_msg);
}
}
void root_send_task(void *arg)
{
esp_err_t ret = ESP_OK;
mesh_data_t data;
data.data = malloc(1500);
data.size = 1500;
......
......@@ -5,4 +5,5 @@
int mesh_root_module_init(void);
void send_to_node(light_mesh_message_type_t message_type, void *payload, uint16_t payload_len, uint8_t *node_addr);
void send_to_all(light_mesh_message_type_t message_type, void *payload, uint16_t payload_len);
void root_send_to_root(light_mesh_message_type_t message_type, void *payload, uint16_t payload_len);
\ No newline at end of file
void root_send_to_root(light_mesh_message_type_t message_type, void *payload, uint16_t payload_len);
void root_receive_task(void);
\ No newline at end of file
......@@ -13,6 +13,7 @@
#include "modules/mesh_module/mesh_module.h"
#include "modules/filesystem_sync_module/filesystem_sync_module.h"
#include "modules/firmware_sync_module/firmware_sync_module.h"
#include "modules/mesh_module/root/mesh_root_module.h"
#define delay_ms(ms) vTaskDelay((ms) / portTICK_RATE_MS)
......@@ -44,6 +45,7 @@ void master_task(void *taskdata)
{
vTaskDelayUntil(&last_wake_time, TASK_INTERVAL);
alive_led_module_step();
root_receive_task();
if(firmware_sync_module_get_receive_offset() == 0)
{
firmware_sync_module_send_data_step();
......@@ -59,6 +61,6 @@ void master_task(void *taskdata)
fft_module_step();
mesh_module_handle_disconnected_timeout();
}
//print_runtime_stats();
print_runtime_stats();
}
}
\ No newline at end of file
......@@ -10,6 +10,7 @@
#include "modules/runtime_stats/runtime_stats.h"
#include "modules/filesystem_sync_module/filesystem_sync_module.h"
#include "modules/firmware_sync_module/firmware_sync_module.h"
#include "modules/mesh_module/node/mesh_node_module.h"
#define delay_ms(ms) vTaskDelay((ms) / portTICK_RATE_MS)
......@@ -39,6 +40,7 @@ void node_task(void *taskdata)
{
vTaskDelayUntil(&last_wake_time, TASK_INTERVAL);
alive_led_module_step();
node_read_task();
firmware_sync_module_send_progress_step();
if(!firmware_sync_module_get_receive_offset())
{
......
......@@ -55,10 +55,10 @@ export default class WebSocketHandler extends React.Component {
}
getWSHost()
{
if(process.env.NODE_ENV)
{
return "192.168.201.154";
}
// if(process.env.NODE_ENV)
// {
// return "192.168.201.154";
// }
return window.location.hostname
}
render()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment