sink sender
This commit is contained in:
@ -4,4 +4,5 @@ idf_component_register(SRCS "app_main.c"
|
|||||||
"counter.c"
|
"counter.c"
|
||||||
"timesync.c"
|
"timesync.c"
|
||||||
"sha256.c"
|
"sha256.c"
|
||||||
|
"sinkSender.c"
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
#include "counter.h"
|
#include "counter.h"
|
||||||
#include "timesync.h"
|
#include "timesync.h"
|
||||||
|
#include "sinkSender.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -45,6 +46,8 @@ void app_main(void)
|
|||||||
networkInit(isGpioForceProv());
|
networkInit(isGpioForceProv());
|
||||||
timesyncInit();
|
timesyncInit();
|
||||||
|
|
||||||
|
sinksenderInit();
|
||||||
|
|
||||||
/* Start main application now */
|
/* Start main application now */
|
||||||
while (1) {
|
while (1) {
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
|
@ -20,6 +20,7 @@ static const uint32_t COUNTER_FREQUENCY = 1e6;
|
|||||||
static xQueueHandle zeroCrossingQueue = NULL;
|
static xQueueHandle zeroCrossingQueue = NULL;
|
||||||
static const uint64_t QUEUE_MARKER = UINT64_MAX;
|
static const uint64_t QUEUE_MARKER = UINT64_MAX;
|
||||||
|
|
||||||
|
xQueueHandle minuteBufferQueue = NULL;
|
||||||
|
|
||||||
static t_minuteBuffer minuteBuffer;
|
static t_minuteBuffer minuteBuffer;
|
||||||
static uint32_t secondOfMinute;
|
static uint32_t secondOfMinute;
|
||||||
@ -61,6 +62,9 @@ static void counterZeroCrossingAveragerTask(void *arg) {
|
|||||||
|
|
||||||
if (settled) {
|
if (settled) {
|
||||||
ESP_LOGI(TAG, "handing over to sender");
|
ESP_LOGI(TAG, "handing over to sender");
|
||||||
|
if (minuteBufferQueue) {
|
||||||
|
xQueueSend(minuteBufferQueue, &minuteBuffer, portMAX_DELAY);
|
||||||
|
}
|
||||||
// sinkSenderSendMinute();
|
// sinkSenderSendMinute();
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "now it is settled");
|
ESP_LOGI(TAG, "now it is settled");
|
||||||
@ -97,6 +101,8 @@ void IRAM_ATTR counterZeroCrossingISR(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void counterInit() {
|
void counterInit() {
|
||||||
|
ESP_LOGI(TAG, "Initializing counter");
|
||||||
|
|
||||||
timer_config_t config = {
|
timer_config_t config = {
|
||||||
.divider = 80,
|
.divider = 80,
|
||||||
.counter_dir = TIMER_COUNT_UP,
|
.counter_dir = TIMER_COUNT_UP,
|
||||||
@ -109,6 +115,7 @@ void counterInit() {
|
|||||||
timer_start(TIMER_GROUP_0, 0);
|
timer_start(TIMER_GROUP_0, 0);
|
||||||
|
|
||||||
zeroCrossingQueue = xQueueCreate(20, sizeof(uint64_t));
|
zeroCrossingQueue = xQueueCreate(20, sizeof(uint64_t));
|
||||||
|
minuteBufferQueue = xQueueCreate(5, sizeof(t_minuteBuffer));
|
||||||
|
|
||||||
settled = false;
|
settled = false;
|
||||||
secondOfMinute = 0;
|
secondOfMinute = 0;
|
||||||
|
33
src/main/sinkSender.c
Normal file
33
src/main/sinkSender.c
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include "sinksender.h"
|
||||||
|
#include "sinkStruct.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include <esp_log.h>
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
|
#include <freertos/queue.h>
|
||||||
|
|
||||||
|
static const char *TAG = "ss";
|
||||||
|
|
||||||
|
|
||||||
|
extern xQueueHandle minuteBufferQueue;
|
||||||
|
|
||||||
|
static void sinksenderExecTask(void *arg) {
|
||||||
|
while (1) {
|
||||||
|
if (minuteBufferQueue) {
|
||||||
|
static t_minuteBuffer minuteBuffer;
|
||||||
|
if (xQueueReceive(minuteBufferQueue, &minuteBuffer, portMAX_DELAY) == pdPASS) {
|
||||||
|
ESP_LOGI(TAG, "Got a buffer from queue");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sinksenderInit() {
|
||||||
|
ESP_LOGI(TAG, "Initializing sink sender");
|
||||||
|
|
||||||
|
xTaskCreate(sinksenderExec, "sinksender_exec_task", 4096, NULL, 5, NULL);
|
||||||
|
}
|
9
src/main/sinkSender.h
Normal file
9
src/main/sinkSender.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef _SINKSENDER_H_
|
||||||
|
#define _SINKSENDER_H_
|
||||||
|
|
||||||
|
|
||||||
|
void sinksenderInit();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _SINKSENDER_H_
|
Reference in New Issue
Block a user