Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
BasedOnStyle: WebKit
AlignAfterOpenBracket: AlwaysBreak
BinPackArguments: true
BinPackParameters: false
PenaltyBreakBeforeFirstCallParameter: 1
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlignEscapedNewlines: Left
AlignArrayOfStructures: None
PointerAlignment: Right
InsertBraces: true
BreakBeforeBraces: Linux
BreakBeforeBinaryOperators: None
KeepEmptyLinesAtTheStartOfBlocks: false
IndentCaseLabels: true
IndentWidth: 4
UseTab: Never
SortIncludes: false
ColumnLimit: 80
# Const always to left side.
QualifierAlignment: Left
---
Language: JavaScript
DisableFormat: true
...
10 changes: 2 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,17 @@ repos:
- id: remove-tabs
name: Remove tabs (4 spaces)
args: ["--whitespaces-count", "4"]
exclude: \.(yaml|yml|html|htm|sln|atsln|layout)$|Makefile|\.(mgw|mak|MAK)$|Dockerfile$
exclude: \.(c|h|yaml|yml|overlay|html|htm|sln|atsln|layout|rst)$|Makefile|\.(mgw|mak|MAK)|Dockerfile$
- id: remove-tabs
name: Remove tabs (2 spaces)
args: ["--whitespaces-count", "2"]
files: '.*\.(yaml|yml|html|htm)|Dockerfile$'
files: '.*\.(yaml|yml|overlay|html|htm)|Dockerfile$'

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.5
hooks:
- id: clang-format

# We might enable this in future.
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: ffb6a759a979008c0e6dff86e39f4745a2d9eac4 # v3.1.0
# hooks:
# - id: prettier

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ manifest:
revision: master
- name: zephyr
path: zephyr
revision: v3.7.0
revision: v3.7.1
remote: zephyrproject-rtos
west-commands: scripts/west-commands.yml
import:
Expand Down
94 changes: 0 additions & 94 deletions zephyr/.clang-format

This file was deleted.

2 changes: 1 addition & 1 deletion zephyr/include/bacnet-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef BACNET_PORTS_ZEPHYR_BACNET_CONFIG_H
#define BACNET_PORTS_ZEPHYR_BACNET_CONFIG_H

#if ! defined BACNET_CONFIG_H || ! BACNET_CONFIG_H
#if !defined BACNET_CONFIG_H || !BACNET_CONFIG_H
#error bacnet-config.h included outside of BACNET_CONFIG_H control
#endif

Expand Down
139 changes: 103 additions & 36 deletions zephyr/include/bacnet_settings/bacnet_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,122 @@
#include "bacnet/bacint.h"
#include "bacnet/wp.h"

/**
* @brief Callback data for WriteProperty restore iterator
* @param write_function The WriteProperty function to call
* @param context The context to pass to the WriteProperty function
* @return true if the WriteProperty succeeded
*/
typedef bool (*bacnet_settings_restore_callback)(
BACNET_WRITE_PROPERTY_DATA *wp_data, void *context);

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

void bacnet_settings_basic_store(BACNET_OBJECT_TYPE object_type, uint32_t object_instance,
BACNET_PROPERTY_ID object_property, BACNET_ARRAY_INDEX array_index,
uint8_t *application_data, int application_data_len);
void bacnet_settings_basic_store(
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_PROPERTY_ID object_property,
BACNET_ARRAY_INDEX array_index,
uint8_t *application_data,
int application_data_len);
bool bacnet_settings_write_property_store(BACNET_WRITE_PROPERTY_DATA *wp_data);
bool bacnet_settings_write_property_restore(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
write_property_function write_function);
bool bacnet_settings_write_property_restore(
bacnet_settings_restore_callback cb, void *context);

int bacnet_settings_value_get(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
BACNET_APPLICATION_DATA_VALUE *value);
bool bacnet_settings_value_set(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
BACNET_APPLICATION_DATA_VALUE *value);
bool bacnet_settings_value_parse(
const char *value_string,
uint16_t object_type,
uint32_t property_id,
BACNET_APPLICATION_DATA_VALUE *value);

int bacnet_settings_value_get(uint16_t object_type, uint32_t object_instance, uint32_t property_id,
uint32_t array_index, BACNET_APPLICATION_DATA_VALUE *value);
bool bacnet_settings_value_set(uint16_t object_type, uint32_t object_instance, uint32_t property_id,
uint32_t array_index, BACNET_APPLICATION_DATA_VALUE *value);
int bacnet_settings_real_get(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
float default_value,
float *value);
bool bacnet_settings_real_set(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
float value);

int bacnet_settings_real_get(uint16_t object_type, uint32_t object_instance, uint32_t property_id,
uint32_t array_index, float default_value, float *value);
bool bacnet_settings_real_set(uint16_t object_type, uint32_t object_instance, uint32_t property_id,
uint32_t array_index, float value);
int bacnet_settings_unsigned_get(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
BACNET_UNSIGNED_INTEGER default_value,
BACNET_UNSIGNED_INTEGER *value);
bool bacnet_settings_unsigned_set(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
BACNET_UNSIGNED_INTEGER value);

int bacnet_settings_unsigned_get(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
BACNET_UNSIGNED_INTEGER default_value,
BACNET_UNSIGNED_INTEGER *value);
bool bacnet_settings_unsigned_set(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
BACNET_UNSIGNED_INTEGER value);
int bacnet_settings_signed_get(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
int32_t default_value,
int32_t *value);
bool bacnet_settings_signed_set(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
int32_t value);

int bacnet_settings_signed_get(uint16_t object_type, uint32_t object_instance, uint32_t property_id,
uint32_t array_index, int32_t default_value, int32_t *value);
bool bacnet_settings_signed_set(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index, int32_t value);
int bacnet_settings_characterstring_get(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
const char *default_value,
BACNET_CHARACTER_STRING *value);

int bacnet_settings_characterstring_get(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
const char *default_value, BACNET_CHARACTER_STRING *value);
bool bacnet_settings_characterstring_ansi_set(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
const char *cstring);

bool bacnet_settings_characterstring_ansi_set(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index,
const char *cstring);
int bacnet_settings_string_get(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
const char *default_value,
char *value,
size_t value_size);

int bacnet_settings_string_get(uint16_t object_type, uint32_t object_instance, uint32_t property_id,
uint32_t array_index, const char *default_value, char *value,
size_t value_size);
bool bacnet_settings_string_set(
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index,
const char *value);

bool bacnet_settings_string_set(uint16_t object_type, uint32_t object_instance,
uint32_t property_id, uint32_t array_index, const char *value);
bool bacnet_settings_init(void);

#ifdef __cplusplus
}
Expand Down
50 changes: 38 additions & 12 deletions zephyr/include/bacnet_settings/bacnet_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,59 @@

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <zephyr/settings/settings.h>

#define BACNET_STORAGE_VALUE_SIZE_MAX SETTINGS_MAX_VAL_LEN
#define BACNET_STORAGE_KEY_SIZE_MAX SETTINGS_MAX_NAME_LEN
#define BACNET_STORAGE_ARRAY_INDEX_NONE UINT32_MAX

typedef struct bacnet_storage_key_t {
uint16_t object_type;
uint32_t object_instance;
uint32_t property_id;
uint32_t array_index;
uint16_t object_type;
uint32_t object_instance;
uint32_t property_id;
uint32_t array_index;
} BACNET_STORAGE_KEY;

typedef int (*bacnet_storage_restore_callback)(
BACNET_STORAGE_KEY *key, const void *data, size_t data_size, void *context);

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

void bacnet_storage_init(void);
int bacnet_storage_init(void);

int bacnet_storage_load_callback_set(
bacnet_storage_restore_callback cb, void *context);
int bacnet_storage_load(void);

int bacnet_storage_handler_set(
const char *name, size_t len, settings_read_cb read_cb, void *cb_arg);
int bacnet_storage_handler_commit(void);
int bacnet_storage_handler_export(
int (*cb)(const char *name, const void *value, size_t val_len));

bool bacnet_storage_strtoul(const char *search_name, unsigned long *long_value);
bool bacnet_storage_strtol(const char *search_name, long *long_value);
bool bacnet_storage_strtof(const char *search_name, float *float_value);

void bacnet_storage_key_init(
BACNET_STORAGE_KEY *key,
uint16_t object_type,
uint32_t object_instance,
uint32_t property_id,
uint32_t array_index);
int bacnet_storage_key_parse(BACNET_STORAGE_KEY *key, size_t argc, char **argv);
int bacnet_storage_key_decode(const char *path, BACNET_STORAGE_KEY *key);
int bacnet_storage_key_encode(
char *buffer, size_t buffer_size, BACNET_STORAGE_KEY *key);

void bacnet_storage_key_init(BACNET_STORAGE_KEY *key, uint16_t object_type,
uint32_t object_instance, uint32_t property_id,
uint32_t array_index);
int bacnet_storage_key_encode(char *buffer, size_t buffer_size,
BACNET_STORAGE_KEY *key);
int bacnet_storage_set(BACNET_STORAGE_KEY *key, const void *data,
size_t data_size);
int bacnet_storage_set(
BACNET_STORAGE_KEY *key, const void *data, size_t data_size);
int bacnet_storage_get(BACNET_STORAGE_KEY *key, void *data, size_t data_size);
int bacnet_storage_delete(BACNET_STORAGE_KEY *key);

#ifdef __cplusplus
}
Expand Down
Loading