{"id":13311776,"url":"https://github.com/aZholtikov/zh_syslog","last_synced_at":"2025-03-10T17:30:47.311Z","repository":{"id":249494810,"uuid":"828882967","full_name":"aZholtikov/zh_syslog","owner":"aZholtikov","description":"ESP32 ESP-IDF and ESP8266 RTOS SDK component for Syslog server UDP client.","archived":false,"fork":false,"pushed_at":"2024-07-21T09:44:00.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-14T08:29:43.270Z","etag":null,"topics":["component","esp-idf","esp32","esp8266","ietf","rtos-sdk","syslog","syslog-client","udp"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aZholtikov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-15T10:12:51.000Z","updated_at":"2025-02-06T10:52:42.000Z","dependencies_parsed_at":"2024-07-21T10:59:39.336Z","dependency_job_id":null,"html_url":"https://github.com/aZholtikov/zh_syslog","commit_stats":null,"previous_names":["azholtikov/zh_syslog"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aZholtikov%2Fzh_syslog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aZholtikov%2Fzh_syslog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aZholtikov%2Fzh_syslog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aZholtikov%2Fzh_syslog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aZholtikov","download_url":"https://codeload.github.com/aZholtikov/zh_syslog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242892594,"owners_count":20202563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component","esp-idf","esp32","esp8266","ietf","rtos-sdk","syslog","syslog-client","udp"],"created_at":"2024-07-29T18:02:29.634Z","updated_at":"2025-03-10T17:30:46.962Z","avatar_url":"https://github.com/aZholtikov.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESP32 ESP-IDF and ESP8266 RTOS SDK component for Syslog server UDP client\n\n## Tested on\n\n1. ESP8266 RTOS_SDK v3.4\n2. ESP32 ESP-IDF v5.2\n\n## Using\n\nIn an existing project, run the following command to install the component:\n\n```text\ncd ../your_project/components\ngit clone https://github.com/aZholtikov/zh_syslog.git\n```\n\nIn the application, add the component:\n\n```c\n#include \"zh_syslog.h\"\n```\n\n## Example\n\nSending messages:\n\n```c\n#include \"nvs_flash.h\"\n#include \"esp_netif.h\"\n#include \"esp_wifi.h\"\n#include \"esp_timer.h\"\n#include \"esp_event.h\"\n#include \"freertos/FreeRTOS.h\"\n#include \"freertos/event_groups.h\"\n#include \"zh_syslog.h\"\n\n#define WIFI_SSID \"ssid\"\n#define WIFI_PASS \"password\"\n#define WIFI_MAXIMUM_RETRY 5\n#define WIFI_RECONNECT_TIME 5\n#define WIFI_CONNECT_SUCCESS BIT0\n\n#define SYSLOG_IP \"192.168.1.2\"\n\nesp_timer_handle_t wifi_reconnect_timer = {0};\nuint8_t wifi_reconnect_retry_num = 0;\nEventGroupHandle_t event_group_handle = {0};\n\nvoid wifi_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);\n\nvoid app_main(void)\n{\n    esp_log_level_set(\"zh_syslog\", ESP_LOG_NONE);\n    nvs_flash_init();\n    esp_netif_init();\n    esp_event_loop_create_default();\n#ifdef CONFIG_IDF_TARGET_ESP8266\n    tcpip_adapter_init();\n#else\n    esp_netif_create_default_wifi_sta();\n#endif\n    wifi_init_config_t wifi_init_sta_config = WIFI_INIT_CONFIG_DEFAULT();\n    esp_wifi_init(\u0026wifi_init_sta_config);\n    wifi_config_t wifi_config = {\n        .sta.ssid = WIFI_SSID,\n        .sta.password = WIFI_PASS};\n    esp_wifi_set_mode(WIFI_MODE_STA);\n    esp_wifi_set_config(WIFI_IF_STA, \u0026wifi_config);\n#ifdef CONFIG_IDF_TARGET_ESP8266\n    esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, \u0026wifi_event_handler, NULL);\n    esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, \u0026wifi_event_handler, NULL);\n#else\n    esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, \u0026wifi_event_handler, NULL, NULL);\n    esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, \u0026wifi_event_handler, NULL, NULL);\n#endif\n    esp_wifi_start();\n    event_group_handle = xEventGroupCreate();\n    xEventGroupWaitBits(event_group_handle, WIFI_CONNECT_SUCCESS, pdTRUE, pdTRUE, portMAX_DELAY);\n    zh_syslog_init_config_t syslog_init_config = ZH_SYSLOG_INIT_CONFIG_DEFAULT();\n    memcpy(syslog_init_config.syslog_ip, SYSLOG_IP, strlen(SYSLOG_IP));\n    zh_syslog_init(\u0026syslog_init_config);\n    for (;;)\n    {\n        zh_syslog_send(ZH_USER, ZH_INFO, \"my_device\", \"my_application\", \"Message\");\n        vTaskDelay(5000 / portTICK_PERIOD_MS);\n    }\n}\n\nvoid wifi_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)\n{\n    switch (event_id)\n    {\n    case WIFI_EVENT_STA_START:\n        esp_wifi_connect();\n        break;\n    case WIFI_EVENT_STA_DISCONNECTED:\n        if (wifi_reconnect_retry_num \u003c WIFI_MAXIMUM_RETRY)\n        {\n            esp_wifi_connect();\n            ++wifi_reconnect_retry_num;\n        }\n        else\n        {\n            wifi_reconnect_retry_num = 0;\n            esp_timer_create_args_t wifi_reconnect_timer_args = {\n                .callback = (void *)esp_wifi_connect};\n            esp_timer_create(\u0026wifi_reconnect_timer_args, \u0026wifi_reconnect_timer);\n            esp_timer_start_once(wifi_reconnect_timer, WIFI_RECONNECT_TIME * 1000);\n        }\n        break;\n    case IP_EVENT_STA_GOT_IP:\n        wifi_reconnect_retry_num = 0;\n        xEventGroupSetBits(event_group_handle, WIFI_CONNECT_SUCCESS);\n        break;\n    default:\n        break;\n    }\n}\n```\n\nAny [feedback](mailto:github@azholtikov.ru) will be gladly accepted.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FaZholtikov%2Fzh_syslog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FaZholtikov%2Fzh_syslog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FaZholtikov%2Fzh_syslog/lists"}