KNX IoT
KNX IoT Point API stack implementation
oc_knx.h
Go to the documentation of this file.
1 /*
2 // Copyright (c) 2021 Cascoda Ltd
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
21 #ifndef OC_KNX_INTERNAL_H
22 #define OC_KNX_INTERNAL_H
23 
24 #include <stddef.h>
25 #include "oc_api.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
57 typedef struct oc_pase_t
58 {
59  oc_string_t id;
60  uint8_t salt[32];
61  uint8_t pa[65];
62  uint8_t pb[65];
63  uint8_t ca[32];
64  uint8_t cb[32];
65  uint8_t rnd[32];
66  int it;
68 
90 {
91  oc_string_t value;
92  uint32_t sia;
93  oc_string_t st;
94  uint32_t ga;
96 
101 typedef enum oc_lsm_state {
108 
113 typedef enum {
114  LSM_E_NOP = 0,
116  1,
118  LSM_E_UNLOAD = 4
120 
128 oc_lsm_state_t oc_a_lsm_state(size_t device_index);
129 
138 int oc_a_lsm_set_state(size_t device_index, oc_lsm_event_t new_state);
139 
147 
155 
164 typedef void (*oc_lsm_change_cb_t)(size_t device, oc_lsm_state_t lsm_state,
165  void *data);
166 
180 
181 bool oc_s_mode_notification_to_json(
182  char *buffer, size_t buffer_size,
183  oc_group_object_notification_t notification);
184 
196 bool oc_is_device_in_runtime(size_t device_index);
197 
204 void oc_knx_set_idevid(const char *idevid, int length);
205 
212 void oc_knx_set_ldevid(char *ldevid, int len);
213 
219 void oc_knx_set_fingerprint(uint64_t fingerprint);
220 
226 
232 
238 
246 void oc_knx_load_state(size_t device_index);
247 
273 int oc_reset_device(size_t device_index, int reset_value);
274 
291 void oc_create_knx_resources(size_t device);
292 
305 
306 #ifdef OC_SPAKE
311 void oc_initialise_spake_data(void);
312 #endif
313 
314 #ifdef __cplusplus
315 }
316 #endif
317 
318 #endif /* OC_KNX_INTERNAL_H */
Main API of the stack for client and server.
void oc_knx_dump_fingerprint()
dump the fingerprint value to storage
const char * oc_core_get_lsm_event_as_string(oc_lsm_event_t lsm_e)
convert the load state machine (lsm) event to string
oc_lsm_event_t
LSM event values.
Definition: oc_knx.h:113
@ LSM_E_NOP
(0) No operation
Definition: oc_knx.h:114
@ LSM_E_STARTLOADING
(1) Request to start the loading of the loadable part
Definition: oc_knx.h:115
@ LSM_E_UNLOAD
(4) cmd unload: state will be UNLOADED
Definition: oc_knx.h:118
@ LSM_E_LOADCOMPLETE
(2) cmd loading complete, state will be LOADED
Definition: oc_knx.h:117
void oc_create_knx_resources(size_t device)
Creation of the KNX device resources.
oc_lsm_state
LSM state machine values.
Definition: oc_knx.h:101
@ LSM_S_UNLOADED
(0) state is unloaded, e.g.
Definition: oc_knx.h:102
@ LSM_S_LOADCOMPLETING
(5) cmd unload: state will be UNLOADED
Definition: oc_knx.h:106
@ LSM_S_LOADING
(2) state loading.
Definition: oc_knx.h:104
@ LSM_S_UNLOADING
(4) state unloading loading.
Definition: oc_knx.h:105
@ LSM_S_LOADED
(1) state is LOADED, e.g.
Definition: oc_knx.h:103
void oc_knx_load_state(size_t device_index)
load the state of the device from persistent storage load data for:
int oc_knx_knx_ignore_smessage_from_self(bool ignore)
runtime switch to ignore s-mode messages send by ourselves.
oc_lsm_state_t oc_a_lsm_state(size_t device_index)
retrieve the current lsm state
int oc_reset_device(size_t device_index, int reset_value)
reset the device the reset value according to the specification:
const char * oc_core_get_lsm_state_as_string(oc_lsm_state_t lsm_s)
convert the load state machine (lsm) state to string
bool oc_is_device_in_runtime(size_t device_index)
checks if the device is in "run-time" mode run-time is:
void oc_knx_set_ldevid(char *ldevid, int len)
sets the ldevid
enum oc_lsm_state oc_lsm_state_t
LSM state machine values.
void(* oc_lsm_change_cb_t)(size_t device, oc_lsm_state_t lsm_state, void *data)
Callback invoked by the stack to inform the change of the lsm.
Definition: oc_knx.h:164
void oc_knx_set_idevid(const char *idevid, int length)
sets the idevid
struct oc_group_object_notification_t oc_group_object_notification_t
Group Object Notification (s-mode messages) Can be used for receiving messages or sending messages.
void oc_knx_load_fingerprint()
load the fingerprint value from storage
void oc_knx_set_fingerprint(uint64_t fingerprint)
sets the fingerprint value (of the loaded materials)
struct oc_pase_t oc_pase_t
Pase Resource Object.
int oc_a_lsm_set_state(size_t device_index, oc_lsm_event_t new_state)
retrieve the current lsm state
void oc_set_lsm_change_cb(oc_lsm_change_cb_t cb, void *data)
Set the load state machine change callback.
void oc_knx_increase_fingerprint()
increase the finger print value
Group Object Notification (s-mode messages) Can be used for receiving messages or sending messages.
Definition: oc_knx.h:90
uint32_t ga
group address
Definition: oc_knx.h:94
oc_string_t st
Service type code (write=w, read=r, response=rp)
Definition: oc_knx.h:93
uint32_t sia
(source id) sender individual address
Definition: oc_knx.h:92
oc_string_t value
generic value received.
Definition: oc_knx.h:91
Pase Resource Object.
Definition: oc_knx.h:58
uint8_t rnd[32]
rnd
Definition: oc_knx.h:65
uint8_t cb[32]
cb
Definition: oc_knx.h:64
uint8_t ca[32]
ca
Definition: oc_knx.h:63
oc_string_t id
recipient id
Definition: oc_knx.h:59
uint8_t salt[32]
salt
Definition: oc_knx.h:60
uint8_t pa[65]
pa
Definition: oc_knx.h:61
uint8_t pb[65]
pb
Definition: oc_knx.h:62