Sun, 10 Sep 2023 17:29:15 +0200
Version 0.4.3. Attempt to fix the sunlight overflow of the APDS9930 sensor in the private part of the esp-idf-lib. Removed some error checks from functions that always return OK. Store light sensor registers in the state record and report the values in the json result string.
18
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Copyright (C) 2023 |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of the ESP32 iotbalkon application. |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * mbsePi-apps is distributed in the hope that it will be useful, but |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | #include "config.h" |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | #define NVSIO_Namespace "balkon" |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | static const char *TAG = "nvsio"; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | void nvsio_init(void) |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | esp_err_t err = ESP_OK; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | nvs_handle_t my_handle; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | err = nvs_open(NVSIO_Namespace, NVS_READWRITE, &my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | if (err != ESP_OK) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | ESP_LOGE(TAG, "Error (%s) opening NVS handle '%s'", esp_err_to_name(err), NVSIO_Namespace); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | } else { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | nvs_commit(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | nvs_close(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | uint8_t nvsio_read_u8(char *key) |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | nvs_handle_t my_handle; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | esp_err_t err; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | uint8_t val = 0; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | if (nvs_open(NVSIO_Namespace, NVS_READWRITE, &my_handle) == ESP_OK) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | err = nvs_get_u8(my_handle, key, &val); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | if (err == ESP_ERR_NVS_NOT_FOUND) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | err = nvs_set_u8(my_handle, key, 0); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | val = 0; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | nvs_commit(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | ESP_LOGI(TAG, "nvsio_read_u8(%s) created", key); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | if (err != ESP_OK) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | ESP_LOGE(TAG, "nvsio_read_u8(%s) Error (%s) opening NVS namespace '%s'", key, esp_err_to_name(err), NVSIO_Namespace); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | nvs_close(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | return val; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | void nvsio_write_u8(char *key, uint8_t val) |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | nvs_handle_t my_handle; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | esp_err_t err; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | uint8_t tmp; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | if (nvs_open(NVSIO_Namespace, NVS_READWRITE, &my_handle) == ESP_OK) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | err = nvs_get_u8(my_handle, key, &tmp); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | if (err == ESP_ERR_NVS_NOT_FOUND) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | nvs_set_u8(my_handle, key, val); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | nvs_commit(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | ESP_LOGI(TAG, "nvsio_write_u8(%s) created val %02x", key, val); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | } else if (err == ESP_OK && tmp != val) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | nvs_set_u8(my_handle, key, val); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | nvs_commit(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | ESP_LOGI(TAG, "nvsio_write_u8(%s) updated val %02x", key, val); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | nvs_close(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | uint32_t nvsio_read_u32(char *key) |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | nvs_handle_t my_handle; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | esp_err_t err; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | uint32_t val = 0; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | if (nvs_open(NVSIO_Namespace, NVS_READWRITE, &my_handle) == ESP_OK) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | err = nvs_get_u32(my_handle, key, &val); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | if (err == ESP_ERR_NVS_NOT_FOUND) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | err = nvs_set_u32(my_handle, key, 0); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | val = 0; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | nvs_commit(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | ESP_LOGI(TAG, "nvsio_read_u32(%s) created", key); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | if (err != ESP_OK) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | ESP_LOGE(TAG, "nvsio_read_u32(%s) Error (%s) opening NVS namespace '%s'", key, esp_err_to_name(err), NVSIO_Namespace); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | nvs_close(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | return val; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | void nvsio_write_u32(char *key, uint32_t val) |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | nvs_handle_t my_handle; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | esp_err_t err; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | uint32_t tmp; |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | if (nvs_open(NVSIO_Namespace, NVS_READWRITE, &my_handle) == ESP_OK) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | err = nvs_get_u32(my_handle, key, &tmp); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | if (err == ESP_ERR_NVS_NOT_FOUND) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | nvs_set_u32(my_handle, key, val); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | nvs_commit(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | ESP_LOGI(TAG, "nvsio_write_u32(%s) created val %08lx", key, val); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | } else if (err == ESP_OK && tmp != val) { |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | nvs_set_u32(my_handle, key, val); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | nvs_commit(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | ESP_LOGI(TAG, "nvsio_write_u32(%s) updated val %08lx", key, val); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | nvs_close(my_handle); |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | } |
12506716211c
Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 |