index 042f56a36b703cd27b41bc8b4e2f77b24a66258f..c382b17d7c3c4378ea1d396d247d8226fc4f3195 100644 (file)
@@ -108,12 +108,13 @@ hence the need to send each line individually with `nc`. Another alternative is
## Embedded applications
-Embedded application are provided in the `embedded` folder for the following platforms:
+The following embedded applications are based on this tool
-- Espressif ESP8266 and ESP32 (send TIC JSON data over UDP)
-- Raspberry Pi Pico (basic demonstration stub)
-- ARM Mbed (not functional)
+- [esptic2udp](http://vcs.slashdirt.org/git/sw/ESP/esptic2udp.git) - Espressif ESP8266/ESP32 Enedis TIC data to JSON converter and UDP sender
+
+Stub applications are provided in the `embedded` folder for the following platforms:
-Only the Espressif variant is a fully fledged application, capable of logging to a remote UDP host.
+- Raspberry Pi Pico (basic demonstration stub): **picotic** gets TIC data on RX pin, outputs formatted JSON on UART TX
+- ARM Mbed (not functional)
-The others are very simple stubs that (ab)use the stdio interface provided by these platforms, as a starting point example.
+These are very simple stubs that (ab)use the stdio interface provided by these platforms, as a starting point example.
deleted file mode 100644
(file)
index
ce66cbf..0000000
+++ /dev/null
-build/
-sdkconfig
-sdkconfig.old
deleted file mode 100644
(file)
index
c80f2d4..0000000
+++ /dev/null
-# The following four lines of boilerplate have to be in your project's CMakeLists
-# in this exact order for cmake to work correctly
-cmake_minimum_required(VERSION 3.5)
-
-include($ENV{IDF_PATH}/tools/cmake/project.cmake)
-project(esptic)
deleted file mode 100644
(file)
index
8be1c8e..0000000
+++ /dev/null
-#
-# This is a project Makefile. It is assumed the directory this Makefile resides in is a
-# project subdirectory.
-#
-
-PROJECT_NAME := esptic
-
-include $(IDF_PATH)/make/project.mk
-
index 691746b8572e9b74e1d2946994f7170c86c8211a..e789e454a996152b62258f4b96bc6d715426e137 100644 (file)
# _esptic_
Implementation of tic2json for ESP8266/ESP32.
-Gets TIC data on RX pin, outputs formatted JSON over UDP.
+Gets TIC data on RX pin, sends formatted JSON over UDP.
-### Configure the project
-
-`idf.py menuconfig`
-
-* Under Component config -> esptic, set the following:
- * UART for receiving TIC frames and TIC baudrate
- * GPIO number for LED heartbeat and LED active state
- * WiFi SSID and password
- * Target UDP host and port
-* Under Component config -> tic2json, set TIC version
-
-### Build and Flash
-
-Build the project and flash it to the board:
-
-`idf.py flash`
-
-See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
-
-Tested working on ESP8266 and ESP32.
+This subproject now lives in a separate repository:
+http://vcs.slashdirt.org/git/sw/ESP/esptic2udp.git
deleted file mode 100644
(file)
index
ca71a30..0000000
+++ /dev/null
-execute_process(COMMAND make -C ${CMAKE_CURRENT_LIST_DIR}/src csources)
-idf_component_register(SRC_DIRS "src")
-target_compile_options(${COMPONENT_LIB} PRIVATE -DBAREBUILD -DPRINT2BUF)
-
-if(CONFIG_TIC2JSON_TICV01)
-add_definitions(-DTICV01)
-endif()
-if(CONFIG_TIC2JSON_TICV02)
-add_definitions(-DTICV02)
-endif()
deleted file mode 100644
(file)
index
2d5f8d8..0000000
+++ /dev/null
-menu "tic2json"
-
- choice
- prompt "TIC version"
- default TIC2JSON_TICV02
- config TIC2JSON_TICV01
- bool "01 (Historique)"
- config TIC2JSON_TICV02
- bool "02 (Standard)"
- endchoice
-
-endmenu
deleted file mode 100644
(file)
index
2a2a79f..0000000
+++ /dev/null
-COMPONENT_SRCDIRS := src
-CFLAGS += -DBAREBUILD -DPRINT2BUF
-
-ifdef CONFIG_TIC2JSON_TICV01
-CFLAGS += -DTICV01
-endif
-
-ifdef CONFIG_TIC2JSON_TICV02
-CFLAGS += -DTICV02
-endif
-
-$(COMPONENT_LIBRARY): csource
-
-csource:
- make -C $(COMPONENT_PATH)/$(COMPONENT_SRCDIRS) csources
-
-.PHONY: csource
deleted file mode 120000
(symlink)
index
d753b57..0000000
+++ /dev/null
-../../../../../src
\ No newline at end of file
deleted file mode 100644
(file)
index
afe29ee..0000000
+++ /dev/null
-set(COMPONENT_SRCS "main.c wifista.c")
-register_component()
-
deleted file mode 100644
(file)
index
e58081c..0000000
+++ /dev/null
-menu "esptic"
-
-config ESPTIC_UART_NUM
- int "TIC UART"
- default 0
- help
- UART peripheral to use for TIC input
-
-choice
- prompt "TIC baudrate"
- default ESPTIC_B9600
- config ESPTIC_B1200
- bool "1200 (Historique)"
- config ESPTIC_B9600
- bool "9600 (Standard)"
-endchoice
-
-config ESPTIC_BAUDRATE
- int
- default 1200 if ESPTIC_B1200
- default 9600
-
-config ESPTIC_LED_GPIO_NUM
- int "LED GPIO NUM"
- default 2
-
-config ESPTIC_LED_ACTIVE_HIGH
- bool "LED active high"
- help
- Set if LED is active high, unset otherwise
-
-config ESPTIC_LED_ACTIVE_STATE
- int
- default 1 if ESPTIC_LED_ACTIVE_HIGH
- default 0
-
-config ESPTIC_WIFI_SSID
- string "WiFi SSID"
- default "myssid"
- help
- SSID (network name) to connect to.
-
-config ESPTIC_WIFI_PASSWORD
- string "WiFi Password"
- default "mypassword"
- help
- WiFi password (WPA2) to use.
-
-config ESPTIC_UDP_HOST
- string "UDP remote hostname"
- default "myhost"
-
-config ESPTIC_UDP_PORT
- string "UDP remote port"
- default "8094"
-
-endmenu
-
deleted file mode 100644
(file)
index
44bd2b5..0000000
+++ /dev/null
-#
-# Main Makefile. This is basically the same as a component makefile.
-#
deleted file mode 100644
(file)
index
bbbed62..0000000
+++ /dev/null
-//
-// main.c
-// app stub for ESP8266/ESP32
-//
-// (C) 2021 Thibaut VARENE
-// License: GPLv2 - http://www.gnu.org/licenses/gpl-2.0.html
-//
-
-/**
- * @file
- * Receives TIC on RX, outputs JSON via UDP.
- * @note: The following memory usage was observed while running tic2json_main() as part of app_main(),
- * tested on ESP8266 in "Release" (-Os) build:
- * - TICV01: max stack 5400, max heap: 3764+80
- * - TICV02: max stack 5816, max heap: 3764+80
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "freertos/FreeRTOS.h"
-#include "freertos/task.h"
-#include "esp_vfs_dev.h"
-#include "esp_log.h"
-#include "driver/uart.h"
-#include "driver/gpio.h"
-
-#include "lwip/err.h"
-#include "lwip/sockets.h"
-#include "lwip/sys.h"
-#include "lwip/netdb.h"
-
-#include "../components/tic2json/src/tic2json.h"
-
-#define XSTR(s) STR(s)
-#define STR(s) #s
-
-#define LED_GPIO CONFIG_ESPTIC_LED_GPIO_NUM
-#define UDPBUFSIZE 1432 // avoid fragmentation
-
-#ifdef CONFIG_IDF_TARGET_ESP8266
- #define LED_GPIO_DIR GPIO_MODE_OUTPUT
-#else /* ESP32 variants */
- #define LED_GPIO_DIR GPIO_MODE_INPUT_OUTPUT
-#endif
-
-static const char * TAG = "esptic";
-static struct sockaddr_storage Gai_addr;
-static socklen_t Gai_addrlen;
-static int Gsockfd;
-
-void tic2json_main(FILE * yyin, int optflags, char * buf, size_t size, tic2json_framecb_t cb);
-void wifista_main(void);
-
-static int udp_setup(void)
-{
- struct addrinfo hints, *result, *rp;
- int ret;
-
- // obtain address(es) matching host/port
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_protocol = IPPROTO_UDP;
-
- ret = getaddrinfo(CONFIG_ESPTIC_UDP_HOST, CONFIG_ESPTIC_UDP_PORT, &hints, &result);
- if (ret) {
- ESP_LOGE(TAG, "getaddrinfo: %d", ret);
- return ESP_FAIL;
- }
-
- // try each address until one succeeds
- for (rp = result; rp; rp = rp->ai_next) {
- Gsockfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
- if (-1 != Gsockfd)
- break; // success
- }
-
- if (!rp) {
- ESP_LOGE(TAG, "Could not reach server");
- ret = ESP_FAIL;
- goto cleanup;
- }
-
- memcpy(&Gai_addr, rp->ai_addr, rp->ai_addrlen);
- Gai_addrlen = rp->ai_addrlen;
-
- ret = ESP_OK;
-
-cleanup:
- freeaddrinfo(result);
- return (ret);
-
-}
-
-static void ticframecb(char * buf, size_t size, bool valid)
-{
- if (valid)
- sendto(Gsockfd, buf, size, 0, (struct sockaddr *)&Gai_addr, Gai_addrlen);
-
- // blink after each complete frame
- gpio_set_level(LED_GPIO, !gpio_get_level(LED_GPIO));
-}
-
-static void tic_task(void *pvParameter)
-{
- FILE *yyin;
- static char buf[UDPBUFSIZE];
-
- yyin = fopen("/dev/uart/" XSTR(CONFIG_ESPTIC_UART_NUM), "r");
- if (!yyin) {
- ESP_LOGE(TAG, "Cannot open UART");
- abort();
- }
-
- while (1)
- tic2json_main(yyin, TIC2JSON_OPT_MASKZEROES|TIC2JSON_OPT_DICTOUT|TIC2JSON_OPT_LONGDATE, buf, UDPBUFSIZE, ticframecb);
-}
-
-void app_main(void)
-{
- BaseType_t ret;
-
- uart_config_t uart_config = {
- .baud_rate = CONFIG_ESPTIC_BAUDRATE,
- .data_bits = UART_DATA_7_BITS,
- .parity = UART_PARITY_EVEN,
- .stop_bits = UART_STOP_BITS_1,
- };
- ESP_ERROR_CHECK(uart_param_config(CONFIG_ESPTIC_UART_NUM, &uart_config));
-
- /* Install UART driver for interrupt-driven reads and writes */
- ESP_ERROR_CHECK(uart_driver_install(CONFIG_ESPTIC_UART_NUM,
- UART_FIFO_LEN*2, 0, 0, NULL, 0));
-
- /* Tell VFS to use UART driver */
- esp_vfs_dev_uart_use_driver(CONFIG_ESPTIC_UART_NUM);
-
- /* start wifi */
- wifista_main();
-
- /* setup UDP client */
- ESP_ERROR_CHECK(udp_setup());
-
- ESP_ERROR_CHECK(gpio_set_direction(LED_GPIO, LED_GPIO_DIR));
- gpio_set_level(LED_GPIO, CONFIG_ESPTIC_LED_ACTIVE_STATE);
-
- ret = xTaskCreate(&tic_task, "tic", 8192, NULL, 5, NULL);
- if (ret != pdPASS) {
- ESP_LOGE(TAG, "Failed to create tic task");
- abort();
- }
-
- ESP_LOGI(TAG, "Rock'n'roll");
-}
deleted file mode 100644
(file)
index
109c0cb..0000000
+++ /dev/null
-/* WiFi station Example - amended for unlimited retries
-
- This example code is in the Public Domain (or CC0 licensed, at your option.)
-
- Unless required by applicable law or agreed to in writing, this
- software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, either express or implied.
-*/
-#include <string.h>
-#include "freertos/FreeRTOS.h"
-#include "freertos/task.h"
-#include "freertos/event_groups.h"
-#include "esp_system.h"
-#include "esp_log.h"
-#include "esp_netif.h"
-#include "esp_event.h"
-#include "esp_wifi.h"
-#include "nvs.h"
-#include "nvs_flash.h"
-
-#include "lwip/err.h"
-#include "lwip/sys.h"
-
-/* The examples use WiFi configuration that you can set via project configuration menu
-
- If you'd rather not, just change the below entries to strings with
- the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid"
-*/
-#define EXAMPLE_ESP_WIFI_SSID CONFIG_ESPTIC_WIFI_SSID
-#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESPTIC_WIFI_PASSWORD
-
-/* FreeRTOS event group to signal when we are connected*/
-static EventGroupHandle_t s_wifi_event_group;
-
-/* The event group allows multiple bits for each event, but we only care being connected to the AP with an IP */
-#define WIFI_CONNECTED_BIT BIT0
-
-static const char *TAG = "wifi station";
-
-static void event_handler(void* arg, esp_event_base_t event_base,
- int32_t event_id, void* event_data)
-{
- if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
- esp_wifi_connect();
- } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
- esp_wifi_connect();
- ESP_LOGI(TAG, "retry to connect to the AP");
- } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
- ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
- ESP_LOGI(TAG, "got ip:%s", ip4addr_ntoa(&event->ip_info.ip));
- xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
- }
-}
-
-static void wifi_init_sta(void)
-{
- s_wifi_event_group = xEventGroupCreate();
-
- tcpip_adapter_init();
-
- ESP_ERROR_CHECK(esp_event_loop_create_default());
-
- wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
- ESP_ERROR_CHECK(esp_wifi_init(&cfg));
-
- ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL));
- ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL));
-
- wifi_config_t wifi_config = {
- .sta = {
- .ssid = EXAMPLE_ESP_WIFI_SSID,
- .password = EXAMPLE_ESP_WIFI_PASS
- },
- };
-
- /* Setting a password implies station will connect to all security modes including WEP/WPA.
- * However these modes are deprecated and not advisable to be used. Incase your Access point
- * doesn't support WPA2, these mode can be enabled by commenting below line */
-
- if (strlen((char *)wifi_config.sta.password))
- wifi_config.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
-
- ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
- ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
- ESP_ERROR_CHECK(esp_wifi_start() );
-
- ESP_LOGI(TAG, "wifi_init_sta finished.");
-
- /* Waiting until either the connection is established (WIFI_CONNECTED_BIT). */
- EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, WIFI_CONNECTED_BIT, pdFALSE, pdFALSE, portMAX_DELAY);
-
- /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
- * happened. */
- if (bits & WIFI_CONNECTED_BIT)
- ESP_LOGI(TAG, "connected to ap SSID:%s password:%s", EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
- else
- ESP_LOGE(TAG, "UNEXPECTED EVENT");
-
- ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler));
- ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler));
- vEventGroupDelete(s_wifi_event_group);
-}
-
-void wifista_main(void)
-{
- ESP_ERROR_CHECK(nvs_flash_init());
-
- ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
- wifi_init_sta();
-}
deleted file mode 100644
(file)
index
47c0b88..0000000
+++ /dev/null
-CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y