From 693a8981d9d7da28429054ad2536402dcf4c5394 Mon Sep 17 00:00:00 2001 From: maccoylton Date: Mon, 11 Nov 2019 18:24:44 +0000 Subject: [PATCH] Removed submodule --- .../esp-homekit-common-functions/LICENSE | 201 ------------------ .../esp-homekit-common-functions/README.md | 2 - .../button/button.c | 146 ------------- .../button/button.h | 14 -- .../button/component.mk | 8 - .../check_wifi/check_wifi.c | 43 ---- .../check_wifi/check_wifi.h | 3 - .../check_wifi/component.mk | 8 - .../custom_characteristics/component.mk | 10 - .../custom_characteristics.c | 160 -------------- .../custom_characteristics.h | 99 --------- .../http_post/component.mk | 8 - .../http_post/http_post.c | 130 ----------- .../http_post/http_post.h | 4 - .../http_post/https_post.c | 86 -------- .../led_codes/component.mk | 8 - .../led_codes/led_codes.c | 71 ------- .../led_codes/led_codes.h | 40 ---- .../ota/component.mk | 8 - .../ota/ota-api.c | 75 ------- .../ota/ota-api.h | 27 --- 21 files changed, 1151 deletions(-) delete mode 100644 components/esp-homekit-common-functions/LICENSE delete mode 100644 components/esp-homekit-common-functions/README.md delete mode 100644 components/esp-homekit-common-functions/button/button.c delete mode 100644 components/esp-homekit-common-functions/button/button.h delete mode 100644 components/esp-homekit-common-functions/button/component.mk delete mode 100644 components/esp-homekit-common-functions/check_wifi/check_wifi.c delete mode 100644 components/esp-homekit-common-functions/check_wifi/check_wifi.h delete mode 100644 components/esp-homekit-common-functions/check_wifi/component.mk delete mode 100644 components/esp-homekit-common-functions/custom_characteristics/component.mk delete mode 100644 components/esp-homekit-common-functions/custom_characteristics/custom_characteristics.c delete mode 100644 components/esp-homekit-common-functions/custom_characteristics/custom_characteristics.h delete mode 100644 components/esp-homekit-common-functions/http_post/component.mk delete mode 100644 components/esp-homekit-common-functions/http_post/http_post.c delete mode 100644 components/esp-homekit-common-functions/http_post/http_post.h delete mode 100644 components/esp-homekit-common-functions/http_post/https_post.c delete mode 100644 components/esp-homekit-common-functions/led_codes/component.mk delete mode 100644 components/esp-homekit-common-functions/led_codes/led_codes.c delete mode 100644 components/esp-homekit-common-functions/led_codes/led_codes.h delete mode 100644 components/esp-homekit-common-functions/ota/component.mk delete mode 100644 components/esp-homekit-common-functions/ota/ota-api.c delete mode 100644 components/esp-homekit-common-functions/ota/ota-api.h diff --git a/components/esp-homekit-common-functions/LICENSE b/components/esp-homekit-common-functions/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/components/esp-homekit-common-functions/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/components/esp-homekit-common-functions/README.md b/components/esp-homekit-common-functions/README.md deleted file mode 100644 index 9cfefd2..0000000 --- a/components/esp-homekit-common-functions/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# esp-homekit-common-functions -some common function for use in esp-homekit devices diff --git a/components/esp-homekit-common-functions/button/button.c b/components/esp-homekit-common-functions/button/button.c deleted file mode 100644 index ea441be..0000000 --- a/components/esp-homekit-common-functions/button/button.c +++ /dev/null @@ -1,146 +0,0 @@ -#include -#include -#include -#include "button.h" - - -typedef struct _button { - uint8_t gpio_num; - button_callback_fn callback; - - uint16_t debounce_time; - uint16_t long_press_time; - uint16_t double_press_time; - - uint8_t press_count; - ETSTimer press_timer; - uint32_t last_press_time; - uint32_t last_event_time; - - struct _button *next; -} button_t; - - -button_t *buttons = NULL; - - -static button_t *button_find_by_gpio(const uint8_t gpio_num) { - button_t *button = buttons; - while (button && button->gpio_num != gpio_num) - button = button->next; - - return button; -} - - -void button_intr_callback(uint8_t gpio) { - int last_event_elapsed =0; - int last_press_elapsed=0; - button_t *button = button_find_by_gpio(gpio); - if (!button) - return; - - uint32_t now = xTaskGetTickCountFromISR(); - last_event_elapsed =(now - button->last_event_time)*portTICK_PERIOD_MS; -/* printf ("button press gpio = %i last event elapsed = %i, portTICK_PERIOD_MS = %i, mow = %i, last event time %i \n", gpio, last_event_elapsed, portTICK_PERIOD_MS, now, button->last_event_time); */ - - if (last_event_elapsed < button->debounce_time) { - // debounce time, ignore events - return; - } - - button->last_event_time = now; - int gpio_value =gpio_read(button->gpio_num); -/* printf ("GPIO value is %i\n", gpio_value); */ - if (gpio_value == button_pressed_value ){ - button->last_press_time = now; -/* printf("Button depressed set button last press time to %i\n", now); */ - } else { -/* printf("Button released set button last press time to %i\n", now);*/ - last_press_elapsed = (now - button->last_press_time)*portTICK_PERIOD_MS; - if (last_press_elapsed > button->long_press_time) { - button->press_count = 0; -/* printf ("Long press button press gpio = %i last press elapsed = %i, portTICK_PERIOD_MS = %i, mow = %i, last press timme = %i\n", gpio, last_press_elapsed, portTICK_PERIOD_MS, now, button->last_press_time); */ - button->callback(button->gpio_num, button_event_long_press); - } else { -/* printf ("Not long press\n"); */ - button->press_count++; - if (button->press_count > 1) { -/* printf ("Press count >1, double press\n");*/ - button->press_count = 0; - sdk_os_timer_disarm(&button->press_timer); - - button->callback(button->gpio_num, button_event_double_press); - } else { -/* printf ("Press count not > 1, check for double press\n");*/ - sdk_os_timer_arm(&button->press_timer, button->double_press_time, 1); - } - } - } -} - - -void button_timer_callback(void *arg) { - button_t *button = arg; - -/* printf ("button timer callback\n");*/ - button->press_count = 0; - sdk_os_timer_disarm(&button->press_timer); - button->callback(button->gpio_num, button_event_single_press); -} - - -int button_create(const uint8_t gpio_num, button_callback_fn callback) { - button_t *button = button_find_by_gpio(gpio_num); - if (button) - return -1; - - button = malloc(sizeof(button_t)); - memset(button, 0, sizeof(*button)); - button->gpio_num = gpio_num; - button->callback = callback; - - // times in milliseconds - button->debounce_time = 50; - button->long_press_time = 1000; - button->double_press_time = 500; - - button->next = buttons; - buttons = button; - - gpio_set_pullup(button->gpio_num, true, true); - gpio_set_interrupt(button->gpio_num, GPIO_INTTYPE_EDGE_ANY, button_intr_callback); - - sdk_os_timer_disarm(&button->press_timer); - sdk_os_timer_setfn(&button->press_timer, button_timer_callback, button); - - return 0; -} - - -void button_delete(const uint8_t gpio_num) { - if (!buttons) - return; - - button_t *button = NULL; - if (buttons->gpio_num == gpio_num) { - button = buttons; - buttons = buttons->next; - } else { - button_t *b = buttons; - while (b->next) { - if (b->next->gpio_num == gpio_num) { - button = b->next; - b->next = b->next->next; - break; - } - } - } - - if (button) { - sdk_os_timer_disarm(&button->press_timer); - gpio_set_interrupt(button->gpio_num, GPIO_INTTYPE_EDGE_ANY, NULL); - } -} - - diff --git a/components/esp-homekit-common-functions/button/button.h b/components/esp-homekit-common-functions/button/button.h deleted file mode 100644 index 6cf600e..0000000 --- a/components/esp-homekit-common-functions/button/button.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -typedef enum { - button_event_single_press, - button_event_double_press, - button_event_long_press, -} button_event_t; -typedef void (*button_callback_fn)(uint8_t gpio_num, button_event_t event); - - -int button_create(uint8_t gpio_num, button_callback_fn callback); -void button_destroy(uint8_t gpio_num); - -extern int button_pressed_value; diff --git a/components/esp-homekit-common-functions/button/component.mk b/components/esp-homekit-common-functions/button/component.mk deleted file mode 100644 index c2daabc..0000000 --- a/components/esp-homekit-common-functions/button/component.mk +++ /dev/null @@ -1,8 +0,0 @@ -# Component makefile for button - -INC_DIRS += $(button_ROOT) - -button_INC_DIR = $(button_ROOT) -button_SRC_DIR = $(button_ROOT) - -$(eval $(call component_compile_rules,button)) diff --git a/components/esp-homekit-common-functions/check_wifi/check_wifi.c b/components/esp-homekit-common-functions/check_wifi/check_wifi.c deleted file mode 100644 index 920cd5b..0000000 --- a/components/esp-homekit-common-functions/check_wifi/check_wifi.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "check_wifi.h" - -bool wifi_connected; - -void checkWifiTask(void *pvParameters) -{ - uint8_t status ; - - wifi_connected = false; - - while (1) - { - status = sdk_wifi_station_get_connect_status(); - switch (status) - { - case STATION_WRONG_PASSWORD: - printf("WiFi: wrong password\n\r"); - break; - case STATION_NO_AP_FOUND: - printf("WiFi: AP not found\n\r"); - break; - case STATION_CONNECT_FAIL: - printf("WiFi: connection failed\r\n"); - break; - case STATION_GOT_IP: - wifi_connected = true; - break; - default: - printf("%s: status = %d\n\r", __func__, status); - break; - } - vTaskDelay(CHECK_INTERVAL / portTICK_PERIOD_MS); - } -} diff --git a/components/esp-homekit-common-functions/check_wifi/check_wifi.h b/components/esp-homekit-common-functions/check_wifi/check_wifi.h deleted file mode 100644 index 18c4164..0000000 --- a/components/esp-homekit-common-functions/check_wifi/check_wifi.h +++ /dev/null @@ -1,3 +0,0 @@ -#define CHECK_INTERVAL 36000000 - -void checkWifiTask(void *pvParameters); diff --git a/components/esp-homekit-common-functions/check_wifi/component.mk b/components/esp-homekit-common-functions/check_wifi/component.mk deleted file mode 100644 index 6c2303e..0000000 --- a/components/esp-homekit-common-functions/check_wifi/component.mk +++ /dev/null @@ -1,8 +0,0 @@ -# Component makefile for check_wifi - -INC_DIRS += $(check_wifi_ROOT) - -check_wifi_INC_DIR = $(check_wifi_ROOT) -check_wifi_SRC_DIR = $(check_wifi_ROOT) - -$(eval $(call component_compile_rules,check_wifi)) diff --git a/components/esp-homekit-common-functions/custom_characteristics/component.mk b/components/esp-homekit-common-functions/custom_characteristics/component.mk deleted file mode 100644 index 6f5cd62..0000000 --- a/components/esp-homekit-common-functions/custom_characteristics/component.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Component makefile for custom_characteristics - - -INC_DIRS += $(custom_characteristics_ROOT) - - -custom_characteristics_INC_DIR = $(custom_characteristics_ROOT) -custom_characteristics_SRC_DIR = $(custom_characteristics_ROOT) - -$(eval $(call component_compile_rules,custom_characteristics)) diff --git a/components/esp-homekit-common-functions/custom_characteristics/custom_characteristics.c b/components/esp-homekit-common-functions/custom_characteristics/custom_characteristics.c deleted file mode 100644 index 34dc05f..0000000 --- a/components/esp-homekit-common-functions/custom_characteristics/custom_characteristics.c +++ /dev/null @@ -1,160 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - - -void get_sysparam_info() { - uint32_t base_addr,num_sectors; - sysparam_iter_t sysparam_iter; - sysparam_status_t sysparam_status; - - sysparam_get_info(&base_addr, &num_sectors); - - printf ("get_sysparam_info - Sysparam base address %i, num_sectors %i\n", base_addr, num_sectors); - sysparam_status = sysparam_iter_start (&sysparam_iter); - while (sysparam_status==0){ - sysparam_status = sysparam_iter_next (&sysparam_iter); - if (sysparam_status==0){ - printf("get_sysparam_info - sysparam name: %s\n", sysparam_iter.key); - } - } - sysparam_iter_end (&sysparam_iter); -} - - -void save_characteristic_to_flash(homekit_characteristic_t *ch, homekit_value_t value){ - - sysparam_status_t status = SYSPARAM_OK; - bool bool_value; - int8_t int8_value; - int32_t int32_value; - float float_value; - char *string_value=NULL; - - printf ("Save characteristic to flash\n"); - switch (ch->format) { - case homekit_format_bool: - printf ("writing bool value to flash\n"); - status = sysparam_get_bool(ch->description, &bool_value); - if (status == SYSPARAM_OK && bool_value != ch->value.bool_value) { - status = sysparam_set_bool(ch->description, ch->value.bool_value); - } else if (status == SYSPARAM_NOTFOUND) { - status = sysparam_set_bool(ch->description, ch->value.bool_value); - } - break; - case homekit_format_uint8: - printf ("writing int8 value to flash\n"); - status = sysparam_get_int8(ch->description, &int8_value); - if (status == SYSPARAM_OK && int8_value != ch->value.int_value) { - status = sysparam_set_int8(ch->description, ch->value.int_value); - } else if (status == SYSPARAM_NOTFOUND) { - status = sysparam_set_int8(ch->description, ch->value.int_value); - } - break; - case homekit_format_uint16: - case homekit_format_uint32: - printf ("writing int32 value to flash\n"); - status = sysparam_get_int32(ch->description, &int32_value); - if (status == SYSPARAM_OK && int32_value != ch->value.int_value) { - status = sysparam_set_int32(ch->description, ch->value.int_value); - } else if (status == SYSPARAM_NOTFOUND) { - status = sysparam_set_int32(ch->description, ch->value.int_value); - } - break; - case homekit_format_string: - printf ("writing string value to flash\n"); - status = sysparam_get_string(ch->description, &string_value); - if (status == SYSPARAM_OK && !strcmp (string_value, ch->value.string_value)) { - status = sysparam_set_string(ch->description, ch->value.string_value); - } else if (status == SYSPARAM_NOTFOUND) { - status = sysparam_set_string(ch->description, ch->value.string_value); - } - free(string_value); - break; - case homekit_format_float: - printf ("writing float value to flash\n"); - status = sysparam_get_int32(ch->description, &int32_value); - float_value = int32_value * 1.00f / 100; - if (status == SYSPARAM_OK && float_value != ch->value.float_value) { - int32_value = (int)ch->value.float_value*100; - status = sysparam_set_int32(ch->description, int32_value); - } else if (status == SYSPARAM_NOTFOUND) { - int32_value = (int)ch->value.float_value*100; - status = sysparam_set_int32(ch->description, int32_value); - } - break; - case homekit_format_uint64: - case homekit_format_int: - case homekit_format_tlv: - default: - printf ("Unknown characteristic format in save_charactersitics_to_flash\n"); - } - if (status != SYSPARAM_OK){ - printf ("Error in sysparams error:%i writing characteristic\n", status); - } - -} - -void load_characteristic_from_flash (homekit_characteristic_t *ch){ - - - sysparam_status_t status = SYSPARAM_OK; - bool bool_value; - int8_t int8_value; - int32_t int32_value; - char *string_value = NULL; - printf ("Loading sysparam %s\n",ch->description); - switch (ch->format){ - case homekit_format_bool: - printf("Loading bool\n"); - status = sysparam_get_bool(ch->description, &bool_value); - if (status == SYSPARAM_OK ) { - ch->value.bool_value = bool_value; - } - break; - case homekit_format_uint8: - printf("Loading int8\n"); - status = sysparam_get_int8(ch->description, &int8_value); - if (status == SYSPARAM_OK) { - ch->value.int_value = int8_value; - } - break; - case homekit_format_uint16: - case homekit_format_uint32: - printf("Loading in32\n"); - status = sysparam_get_int32(ch->description, &int32_value); - if (status == SYSPARAM_OK ) { - ch->value.int_value = int32_value; - } - break; - case homekit_format_string: - printf("Loading string\n"); - status = sysparam_get_string(ch->description, &string_value); - if (status == SYSPARAM_OK) { - ch->value = HOMEKIT_STRING(string_value); - } - break; - case homekit_format_float: - printf("Loading float\n"); - status = sysparam_get_int32(ch->description, &int32_value); - if (status == SYSPARAM_OK ) { - ch->value.float_value = int32_value * 1.0f /100; - } - break; - case homekit_format_uint64: - case homekit_format_int: - case homekit_format_tlv: - default: - printf ("Unknown characteristic format in save_charactersitics_to_flash\n"); - } - if (status != SYSPARAM_OK){ - printf ("Error in sysparams error:%i loading characteristic\n", status); - } - - - -} diff --git a/components/esp-homekit-common-functions/custom_characteristics/custom_characteristics.h b/components/esp-homekit-common-functions/custom_characteristics/custom_characteristics.h deleted file mode 100644 index 3c3a3a4..0000000 --- a/components/esp-homekit-common-functions/custom_characteristics/custom_characteristics.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * HomeKit Custom Characteristics - * - * Copyright 2018 David B Brown (@maccoylton) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#ifndef __HOMEKIT_DBB_CUSTOM_CHARACTERISTICS__ -#define __HOMEKIT_DBB_CUSTOM_CHARACTERISTICS__ - -#define HOMEKIT_CUSTOM_UUID_DBB(value) (value"-4772-4466-80fd-a6ea3d5bcd55") - - -#define HOMEKIT_CHARACTERISTIC_CUSTOM_POLL_PERIOD HOMEKIT_CUSTOM_UUID_DBB("F0000001") -#define HOMEKIT_DECLARE_CHARACTERISTIC_CUSTOM_POLL_PERIOD(_value, ...) .type = HOMEKIT_CHARACTERISTIC_CUSTOM_POLL_PERIOD, \ -.description = "Poll Period", \ -.format = homekit_format_uint8, \ -.unit = homekit_unit_seconds, \ -.permissions = homekit_permissions_paired_read \ -| homekit_permissions_paired_write \ -| homekit_permissions_notify, \ -.min_value = (float[]) {1000}, \ -.max_value = (float[]) {10000}, \ -.min_step = (float[]) {1}, \ -.value = HOMEKIT_UINT8_(_value), \ -##__VA_ARGS__ - - -#define HOMEKIT_CHARACTERISTIC_CUSTOM_SQL_LOG HOMEKIT_CUSTOM_UUID_DBB("F0000002") -#define HOMEKIT_DECLARE_CHARACTERISTIC_CUSTOM_SQL_LOG(_value, ...) \ -.type = HOMEKIT_CHARACTERISTIC_CUSTOM_SQL_LOG, \ -.description = "SQL LOG", \ -.format = homekit_format_bool, \ -.permissions = homekit_permissions_paired_read \ -| homekit_permissions_paired_write \ -| homekit_permissions_notify, \ -.value = HOMEKIT_BOOL_(_value), \ -##__VA_ARGS__ - - -#define HOMEKIT_CHARACTERISTIC_CUSTOM_LPG_LEVEL HOMEKIT_CUSTOM_UUID_DBB("F0000003") -#define HOMEKIT_DECLARE_CHARACTERISTIC_CUSTOM_LPG_LEVEL(_value, ...) .type = HOMEKIT_CHARACTERISTIC_CUSTOM_LPG_LEVEL, \ -.description = "LPG Level", \ -.format = homekit_format_float, \ -.permissions = homekit_permissions_paired_read \ -| homekit_permissions_notify, \ -.min_value = (float[]) {0}, \ -.max_value = (float[]) {10000}, \ -.min_step = (float[]) {1}, \ -.value = HOMEKIT_FLOAT_(_value), \ -##__VA_ARGS__ - -#define HOMEKIT_CHARACTERISTIC_CUSTOM_METHANE_LEVEL HOMEKIT_CUSTOM_UUID_DBB("F0000004") -#define HOMEKIT_DECLARE_CHARACTERISTIC_CUSTOM_METHANE_LEVEL(_value, ...) .type = HOMEKIT_CHARACTERISTIC_CUSTOM_METHANE_LEVEL, \ -.description = "Methane Level", \ -.format = homekit_format_float, \ -.permissions = homekit_permissions_paired_read \ -| homekit_permissions_notify, \ -.min_value = (float[]) {0}, \ -.max_value = (float[]) {10000}, \ -.min_step = (float[]) {1}, \ -.value = HOMEKIT_FLOAT_(_value), \ -##__VA_ARGS__ - -#define HOMEKIT_CHARACTERISTIC_CUSTOM_AMMONIUM_LEVEL HOMEKIT_CUSTOM_UUID_DBB("F0000005") -#define HOMEKIT_DECLARE_CHARACTERISTIC_CUSTOM_AMMONIUM_LEVEL(_value, ...) .type = HOMEKIT_CHARACTERISTIC_CUSTOM_AMMONIUM_LEVEL, \ -.description = "Amonium Level", \ -.format = homekit_format_float, \ -.permissions = homekit_permissions_paired_read \ -| homekit_permissions_notify, \ -.min_value = (float[]) {0}, \ -.max_value = (float[]) {10000}, \ -.min_step = (float[]) {1}, \ -.value = HOMEKIT_FLOAT_(_value), \ -##__VA_ARGS__ - - -#endif - -void save_characteristic_to_flash (homekit_characteristic_t *ch, homekit_value_t value); - -void load_characteristic_from_flash (homekit_characteristic_t *ch); - -void get_sysparam_info(); - diff --git a/components/esp-homekit-common-functions/http_post/component.mk b/components/esp-homekit-common-functions/http_post/component.mk deleted file mode 100644 index d73d86d..0000000 --- a/components/esp-homekit-common-functions/http_post/component.mk +++ /dev/null @@ -1,8 +0,0 @@ -# Component makefile for http_post - -INC_DIRS += $(http_post_ROOT) - -http_post_INC_DIR = $(http_post_ROOT) -http_post_SRC_DIR = $(http_post_ROOT) - -$(eval $(call component_compile_rules,http_post)) diff --git a/components/esp-homekit-common-functions/http_post/http_post.c b/components/esp-homekit-common-functions/http_post/http_post.c deleted file mode 100644 index 88e0e7e..0000000 --- a/components/esp-homekit-common-functions/http_post/http_post.c +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include - -#include -#include -#include -#include -#include -#include - - -#define WEB_SERVER "192.168.1.2" -#define WEB_PORT "80" -#define WEB_URL "/esplogger/postsql.php" -char request[450]; -char details[150]; -float temperature; -float humidity; -float moisture; - -void http_post_task(void * pvParameters) -{ - int successes = 0, failures = 0; - printf("HTTP get task starting...\r\n"); - - while(1) { - // sdk_wifi_set_sleep_type(WIFI_SLEEP_NONE); - - printf ("Suspending http_post_task\n"); - vTaskSuspend( NULL ); - - printf ("Resumed http_post_task\n"); - - const struct addrinfo hints = { - .ai_family = AF_INET, - .ai_socktype = SOCK_STREAM, - }; - struct addrinfo *res; - - printf("Running DNS lookup for %s...\r\n", WEB_SERVER); - int err = getaddrinfo(WEB_SERVER, WEB_PORT, &hints, &res); - - if(err != 0 || res == NULL) { - printf("DNS lookup failed err=%d res=%p\r\n", err, res); - if(res) - freeaddrinfo(res); - vTaskDelay(1000 / portTICK_PERIOD_MS); - failures++; - continue; - } - /* Note: inet_ntoa is non-reentrant, look at ipaddr_ntoa_r for "real" code */ - struct in_addr *addr = &((struct sockaddr_in *)res->ai_addr)->sin_addr; - printf("DNS lookup succeeded. IP=%s\r\n", inet_ntoa(*addr)); - - int s = lwip_socket(res->ai_family, res->ai_socktype, 0); - if(s < 0) { - printf("... Failed to allocate socket\r\n"); - freeaddrinfo(res); - vTaskDelay(1000 / portTICK_PERIOD_MS); - failures++; - continue; - } - - printf("... allocated socket: %d \r\n", s); - - if(lwip_connect(s, res->ai_addr, res->ai_addrlen) != 0) { - lwip_close(s); - freeaddrinfo(res); - printf("... socket connect failed.\r\n"); - vTaskDelay(4000 / portTICK_PERIOD_MS); - failures++; - continue; - } - - printf("... connected\r\n"); - freeaddrinfo(res); - request[0] = "\0"; - // snprintf(details, 80, "{\"temp\": %.3f, \"hum\": %.3f, \"mois\": %.3f}\r\n", temperature, humidity, moisture); - - snprintf(details, 150, post_string); - snprintf(request, 450, "POST %s HTTP/1.0\r\n" - "Host: %s\r\n" - // "User-Agent: esp-open-rtos/0.1 esp8266\r\n" - "Content-type: application/x-www-form-urlencoded\r\n" - "Content-Length: %d\r\n\r\n" - "%s", WEB_URL, WEB_SERVER, strlen(details), details); - printf(request); - if (lwip_write(s, request, strlen(request)) < 0) { - printf("... socket send failed\r\n"); - lwip_close(s); - vTaskDelay(4000 / portTICK_PERIOD_MS); - failures++; - continue; - } - printf("... socket send success\r\n"); - - static char recv_buf[200]; - int r; - do { - printf("receiving..."); - bzero(recv_buf, 200); - r = lwip_read(s, recv_buf, 199); - if(r > 0) { - printf("%s", recv_buf); - } - } while(r > 0); - - printf("... done reading from socket. Last read return=%d errno=%d\r\n", r, errno); - if(r != 0) - failures++; - else - successes++; - lwip_close(s); - printf("successes = %d failures = %d\r\n", successes, failures); - // sdk_wifi_set_sleep_type(WIFI_SLEEP_LIGHT); - vTaskDelay(10000 / portTICK_PERIOD_MS); - printf("\r\nStarting again!\r\n"); - } -} - diff --git a/components/esp-homekit-common-functions/http_post/http_post.h b/components/esp-homekit-common-functions/http_post/http_post.h deleted file mode 100644 index 5a5d9df..0000000 --- a/components/esp-homekit-common-functions/http_post/http_post.h +++ /dev/null @@ -1,4 +0,0 @@ -void http_post_task (void * pvParameters ); - - -char post_string[150]; diff --git a/components/esp-homekit-common-functions/http_post/https_post.c b/components/esp-homekit-common-functions/http_post/https_post.c deleted file mode 100644 index bd816ee..0000000 --- a/components/esp-homekit-common-functions/http_post/https_post.c +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#define WEB_SERVER "192.168.1.2" -#define WEB_PORT 80 -#define WEB_URL "/esplogger/postsql.php" -#define POST_REQUEST "POST %s HTTP/1.0\r\nHost: %s\r\nContent-type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\n\r\n%s" - -char request[450]; -char details[150]; - - -void https_post_wolfssl_task(void * pvParameters) -{ - - - while (1) { - printf ("Suspending http_post_task\n"); - vTaskSuspend( NULL ); - printf ("Resumed http_post_task\n"); - - int sockfd; - - WOLFSSL_CTX* ctx; - - WOLFSSL* ssl; - - WOLFSSL_METHOD* method; - struct sockaddr_in servAddr; - - /* create and set up socket */ - - sockfd = socket(AF_INET, SOCK_STREAM, 0); - memset(&servAddr, 0, sizeof(servAddr)); - servAddr.sin_family = AF_INET; - servAddr.sin_port = htons(WEB_PORT); - - /* connect to socket */ - connect(sockfd, (struct sockaddr *) &servAddr, sizeof(servAddr)); - - /* initialize wolfssl library */ - - wolfSSL_Init(); - method = wolfTLSv1_2_client_method(); /* use TLS v1.2 */ - - /* make new ssl context */ - if ( (ctx = wolfSSL_CTX_new(method)) == NULL) { - printf("wolfSSL_CTX_new error"); - } - - /* make new wolfSSL struct */ - if ( (ssl = wolfSSL_new(ctx)) == NULL) { - printf("wolfSSL_new error"); - } - - /* Add cert to ctx */ - if (wolfSSL_CTX_load_verify_locations(ctx, "certs/ca-cert.pem", 0) !=SSL_SUCCESS) { - printf("Error loading certs/ca-cert.pem"); - } - - request[0] = "\0"; - snprintf(details, 150, post_string); - snprintf(request, 450, "POST %s HTTP/1.0\r\n" - "Host: %s\r\n" - "Content-type: application/x-www-form-urlencoded\r\n" - "Content-Length: %d\r\n\r\n" - "%s", WEB_URL, WEB_SERVER, strlen(details), details); - printf(request); - - - /* Connect wolfssl to the socket, server, then send message */ - wolfSSL_set_fd(ssl, sockfd); - wolfSSL_connect(ssl); - wolfSSL_write(ssl, request, strlen(request)); - - /* frees all data before client termination */ - wolfSSL_free(ssl); - wolfSSL_CTX_free(ctx); - wolfSSL_Cleanup(); - } -} diff --git a/components/esp-homekit-common-functions/led_codes/component.mk b/components/esp-homekit-common-functions/led_codes/component.mk deleted file mode 100644 index b39adc9..0000000 --- a/components/esp-homekit-common-functions/led_codes/component.mk +++ /dev/null @@ -1,8 +0,0 @@ -# Component makefile for led_codes - -INC_DIRS += $(led_codes_ROOT) - -led_codes_INC_DIR = $(led_codes_ROOT) -led_codes_SRC_DIR = $(led_codes_ROOT) - -$(eval $(call component_compile_rules,led_codes)) diff --git a/components/esp-homekit-common-functions/led_codes/led_codes.c b/components/esp-homekit-common-functions/led_codes/led_codes.c deleted file mode 100644 index 06fcf7e..0000000 --- a/components/esp-homekit-common-functions/led_codes/led_codes.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * LED Codes - * - * Copyright 2018 José A. Jiménez (@RavenSystem) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include "led_codes.h" - -#define DURATION_OFF 150 - -typedef struct led_params_t { - blinking_params_t blinking_params; - uint8_t gpio; - bool status; - ETSTimer timer; - uint8_t count; - uint32_t delay; -} led_params_t; - -led_params_t led_params; - -void led_code_run() { - led_params.status = !led_params.status; - - gpio_write(led_params.gpio, led_params.status); - - if (led_params.status != led_off_value) { - led_params.delay = (led_params.blinking_params.duration * 1000) + 90; - } else { - led_params.delay = DURATION_OFF; - led_params.count++; - - } - - sdk_os_timer_disarm(&led_params.timer); - - if (led_params.count < led_params.blinking_params.times) { - sdk_os_timer_arm(&led_params.timer, led_params.delay, 0); - } -} - -void led_code(uint8_t gpio, blinking_params_t blinking_params) { - led_params.gpio = gpio; - led_params.blinking_params = blinking_params; - - sdk_os_timer_disarm(&led_params.timer); - sdk_os_timer_setfn(&led_params.timer, led_code_run, NULL); - - led_params.status = led_off_value; - led_params.count = 0; - - led_code_run(); -} diff --git a/components/esp-homekit-common-functions/led_codes/led_codes.h b/components/esp-homekit-common-functions/led_codes/led_codes.h deleted file mode 100644 index 112b63f..0000000 --- a/components/esp-homekit-common-functions/led_codes/led_codes.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * LED Codes - * - * Copyright 2018 José A. Jiménez (@RavenSystem) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -typedef struct blinking_params_t { - uint8_t times; - uint8_t duration; -} blinking_params_t; - -extern int led_off_value; - -#define GENERIC_ERROR (blinking_params_t){6,0} -#define SENSOR_ERROR (blinking_params_t){5,0} -#define WIFI_CONNECTED (blinking_params_t){1,2} -#define IDENTIFY_ACCESSORY (blinking_params_t){1,3} -#define RESTART_DEVICE (blinking_params_t){2,2} -#define WIFI_CONFIG_RESET (blinking_params_t){2,0} -#define EXTRA_CONFIG_RESET (blinking_params_t){2,1} -#define FUNCTION_A (blinking_params_t){1,0} -#define FUNCTION_B (blinking_params_t){2,0} -#define FUNCTION_C (blinking_params_t){3,0} -#define FUNCTION_D (blinking_params_t){4,0} - -void led_code(uint8_t gpio, blinking_params_t blinking_params); diff --git a/components/esp-homekit-common-functions/ota/component.mk b/components/esp-homekit-common-functions/ota/component.mk deleted file mode 100644 index 861596a..0000000 --- a/components/esp-homekit-common-functions/ota/component.mk +++ /dev/null @@ -1,8 +0,0 @@ -# Component makefile for ota - -INC_DIRS += $(ota_ROOT) - -ota_INC_DIR = $(ota_ROOT) -ota_SRC_DIR = $(ota_ROOT) - -$(eval $(call component_compile_rules,ota)) diff --git a/components/esp-homekit-common-functions/ota/ota-api.c b/components/esp-homekit-common-functions/ota/ota-api.c deleted file mode 100644 index 5126078..0000000 --- a/components/esp-homekit-common-functions/ota/ota-api.c +++ /dev/null @@ -1,75 +0,0 @@ -#include //for printf -#include -#include - -#include -#include -#include -#include - -// the first function is the ONLY thing needed for a repo to support ota after having started with ota-boot -// in ota-boot the user gets to set the wifi and the repository details and it then installs the ota-main binary - -void ota_update(void *arg) { //arg not used - rboot_set_temp_rom(1); //select the OTA main routine - sdk_system_restart(); //#include - // there is a bug in the esp SDK such that if you do not power cycle the chip after serial flashing, restart is unreliable -} - -// this function is optional to couple Homekit parameters to the sysparam variables and github parameters -unsigned int ota_read_sysparam(char **manufacturer,char **serial,char **model,char **revision) { - sysparam_status_t status; - char *value; - - status = sysparam_get_string("ota_repo", &value); - if (status == SYSPARAM_OK) { - strchr(value,'/')[0]=0; - *manufacturer=value; - *model=value+strlen(value)+1; - } else { - *manufacturer="manuf_unknown"; - *model="model_unknown"; - } - status = sysparam_get_string("ota_version", &value); - if (status == SYSPARAM_OK) { - *revision=value; - } else *revision="0.0.0"; - - uint8_t macaddr[6]; - sdk_wifi_get_macaddr(STATION_IF, macaddr); - *serial=malloc(18); - sprintf(*serial,"%02X:%02X:%02X:%02X:%02X:%02X",macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]); - - unsigned int c_hash=0; - char version[16]; - char* rev=version; - char* dot; - strncpy(rev,*revision,16); - if ((dot=strchr(rev,'.'))) {dot[0]=0; c_hash= atoi(rev); rev=dot+1;} - if ((dot=strchr(rev,'.'))) {dot[0]=0; c_hash=c_hash*1000+atoi(rev); rev=dot+1;} - c_hash=c_hash*1000+atoi(rev); - //c_hash=c_hash*10 +configuration_variant; //possible future extension - printf("manuf=\'%s\' serial=\'%s\' model=\'%s\' revision=\'%s\' c#=%d\n",*manufacturer,*serial,*model,*revision,c_hash); - return c_hash; -} - - - - -#include -#include -#include - -static ETSTimer update_timer; - -void ota_set(homekit_value_t value) { - if (value.format != homekit_format_bool) { - printf("Invalid ota-value format: %d\n", value.format); - return; - } - if (value.bool_value) { - //make a distinct light pattern or other feedback to the user = call identify routine - sdk_os_timer_setfn(&update_timer, ota_update, NULL); - sdk_os_timer_arm(&update_timer, 500, 0); //wait 0.5 seconds to trigger the reboot so gui can update and events sent - } -} diff --git a/components/esp-homekit-common-functions/ota/ota-api.h b/components/esp-homekit-common-functions/ota/ota-api.h deleted file mode 100644 index fd4d2e0..0000000 --- a/components/esp-homekit-common-functions/ota/ota-api.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __HOMEKIT_CUSTOM_CHARACTERISTICS__ -#define __HOMEKIT_CUSTOM_CHARACTERISTICS__ - -#define HOMEKIT_CUSTOM_UUID(value) (value "-0e36-4a42-ad11-745a73b84f2b") - -#define HOMEKIT_SERVICE_CUSTOM_SETUP HOMEKIT_CUSTOM_UUID("000000FF") - -#define HOMEKIT_CHARACTERISTIC_CUSTOM_OTA_TRIGGER HOMEKIT_CUSTOM_UUID("F0000001") -#define HOMEKIT_DECLARE_CHARACTERISTIC_CUSTOM_OTA_TRIGGER(_value, ...) \ - .type = HOMEKIT_CHARACTERISTIC_CUSTOM_OTA_TRIGGER, \ - .description = "FirmwareUpdate", \ - .format = homekit_format_bool, \ - .permissions = homekit_permissions_paired_read \ - | homekit_permissions_paired_write \ - | homekit_permissions_notify, \ - .value = HOMEKIT_BOOL_(_value), \ - ##__VA_ARGS__ - -unsigned int ota_read_sysparam(char **manufacturer,char **serial,char **model,char **revision); - -void ota_update(void *arg); - -void ota_set(homekit_value_t value); - -#define API_OTA_TRIGGER HOMEKIT_CHARACTERISTIC_(CUSTOM_OTA_TRIGGER, false, .setter=ota_set) - -#endif