TimJTi commented on code in PR #2228:
URL: https://github.com/apache/nuttx-apps/pull/2228#discussion_r1424512060


##########
include/system/settings.h:
##########
@@ -0,0 +1,346 @@
+/****************************************************************************
+ * apps/include/system/settings.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you 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.
+ *
+ ****************************************************************************/
+
+#ifndef UTILS_SETTINGS_H_
+#define UTILS_SETTINGS_H_
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <netinet/in.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <signal.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define VALID          0x600d /* "Magic" number to confirm storage is OK */
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+enum settings_type_e
+{
+  SETTING_EMPTY   = 0,
+  SETTING_INT,        /* INT32 */
+  SETTING_BOOL,
+  SETTING_FLOAT,
+  SETTING_STRING,
+  SETTING_IP_ADDR,
+  SETTING_BYTE,
+};
+
+typedef struct
+{
+  int    store_num;
+  size_t size;
+} storage_used_t;
+
+typedef struct
+{
+  char key[CONFIG_SYSTEM_SETTINGS_KEY_SIZE];
+  enum settings_type_e type;
+  union
+  {
+    int    i;
+    double f;
+    char   s[CONFIG_SYSTEM_SETTINGS_VALUE_SIZE];
+    struct in_addr ip;
+  } val;
+} setting_t;
+
+typedef struct
+{
+  char file[CONFIG_SYSTEM_SETTINGS_MAX_FILENAME];
+
+  int (*load_fn)(FAR char *file);
+  int (*save_fn)(FAR char *file);
+  int (*size_fn)(FAR storage_used_t *used);
+} storage_t;
+
+struct notify_s
+{
+  pid_t pid;
+  uint8_t signo;
+};
+
+enum storage_type_e
+{
+  STORAGE_BINARY = 0,
+  STORAGE_TEXT,
+  STORAGE_EEPROM,

Review Comment:
   @fjpanag I hear you. I am leaning more and more about how POSIX systems work 
so will take this on board, and it might be that the better solution is to 
improve the lower level drivers for EEPROM. They are strange things with 
peculiar needs, and I come from a bare-metal background not POSIX.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to