KNX IoT
KNX IoT Point API stack implementation
oc_knx_fp.h
Go to the documentation of this file.
1 /*
2 // Copyright (c) 2021-2022 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 */
20 #ifndef OC_KNX_FP_INTERNAL_H
21 #define OC_KNX_FP_INTERNAL_H
22 
23 #include <stddef.h>
24 #include "oc_helpers.h"
25 #include "oc_ri.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
37 typedef enum {
40  1 << 2,
41  OC_CFLAG_READ = 1 << 3,
43  1 << 4,
44  OC_CFLAG_INIT = 1 << 5,
46  1 << 6,
48  1 << 7,
50 
58 
68 void oc_cflags_as_string(char *buffer, oc_cflag_mask_t cflags);
69 
119 {
120  int id;
121  oc_string_t href;
123  int ga_len;
124  uint32_t *ga;
126 
175 typedef struct oc_group_rp_table_t
176 {
177  int id;
178  int ia;
179  int64_t iid;
180  int64_t fid;
181  uint32_t grpid;
182  oc_string_t path;
183  oc_string_t url;
184  oc_string_t at;
186  uint32_t *ga;
187  int ga_len;
188  bool non;
189  int mt;
191 
199 
207 
214 
223 
231 
246 
254 
280 
290 uint32_t oc_find_grpid_in_publisher_table(uint32_t group_address);
291 
301 uint32_t oc_find_grpid_in_recipient_table(uint32_t group_address);
302 
309 
317 
324 int oc_core_find_group_object_table_index(uint32_t group_address);
325 
334  int cur_index);
335 
343 
351 int oc_core_find_next_group_object_table_url(const char *url, int cur_index);
352 
360 
368 
376 
385 
392 
399 
406 
412 
420 
426 
433 
443  uint32_t group_address);
444 
452 
459 uint32_t oc_core_get_recipient_ia(int index);
460 
467 
482 
490 
498 
507 
514 
529 
545 
553 
567  size_t device_index,
568  uint32_t group_address,
569  size_t *response_length,
570  int matches);
571 
583 bool oc_belongs_href_to_resource(oc_string_t href, bool discoverable,
584  size_t device_index);
585 
592 void oc_create_knx_fp_resources(size_t device_index);
593 
601 void oc_free_knx_fp_resources(size_t device_index);
602 
614  uint32_t group_nr, int64_t iid,
615  int scope);
616 
639  uint32_t group_nr,
640  int64_t iid,
641  int scope, int port);
642 
654 void subscribe_group_to_multicast(uint32_t group_nr, int64_t iid, int scope);
655 
667 void subscribe_group_to_multicast_with_port(uint32_t group_nr, int64_t iid,
668  int scope, int port);
669 
680 void unsubscribe_group_to_multicast(uint32_t group_nr, int64_t iid, int scope);
681 
693 void unsubscribe_group_to_multicast_with_port(uint32_t group_nr, int64_t iid,
694  int scope, int port);
695 
696 #ifdef __cplusplus
697 }
698 #endif
699 
700 #endif /* OC_KNX_FP_INTERNAL_H */
generic helpers
oc_endpoint_t oc_create_multicast_group_address(oc_endpoint_t in, uint32_t group_nr, int64_t iid, int scope)
create the group multi cast address using the default port 5683
uint32_t oc_core_get_recipient_ia(int index)
retrieve the internal address of the recipient in the table
struct oc_group_object_table_t oc_group_object_table_t
Group Object Table Resource (/fp/g) The payload is an array of objects.
oc_group_rp_table_t * oc_core_get_recipient_table_entry(int index)
retrieve the recipient table entry
int oc_table_find_id_from_rep(oc_rep_t *object)
find id (cbor key 0) in the response
oc_cflag_mask_t
cflag masks
Definition: oc_knx_fp.h:37
@ OC_CFLAG_READ
8 false = Group Object value cannot be read.
Definition: oc_knx_fp.h:41
@ OC_CFLAG_COMMUNICATION
false = Group Object value cannot read or written.
Definition: oc_knx_fp.h:39
@ OC_CFLAG_INIT
32 false = Disable read after initialization.
Definition: oc_knx_fp.h:44
@ OC_CFLAG_WRITE
16 false = Group Object value cannot be written.
Definition: oc_knx_fp.h:42
@ OC_CFLAG_NONE
Communication.
Definition: oc_knx_fp.h:38
@ OC_CFLAG_UPDATE
128 false = Group Object value is not updated.
Definition: oc_knx_fp.h:47
@ OC_CFLAG_TRANSMISSION
64 false = Group Object value is not transmitted.
Definition: oc_knx_fp.h:45
void oc_cflags_as_string(char *buffer, oc_cflag_mask_t cflags)
adds the communication flags a preallocated buffer
struct oc_group_rp_table_t oc_group_rp_table_t
Function point Recipient - Publisher Table Resource (/fp/r) (/fp/p)
void oc_load_group_object_table_entry(int entry)
load the entry of the Group Object Table (from persistent) storage
int oc_core_find_empty_slot_in_recipient_table(int id)
find empty slot in recipient table
uint32_t oc_find_grpid_in_publisher_table(uint32_t group_address)
find the grpid from the group_address in the publisher table
void subscribe_group_to_multicast(uint32_t group_nr, int64_t iid, int scope)
subscribe to a multicast address, defined by group number and installation id using the default port ...
int oc_core_get_publisher_table_size()
return the size of the publisher table
int oc_core_find_group_object_table_number_group_entries(int index)
retrieve the number of group address entries for index
int oc_core_get_group_object_table_total_size()
retrieve the group object table total size, e.g.
void oc_register_group_multicasts()
register the multicast addresses to listen to
bool oc_belongs_href_to_resource(oc_string_t href, bool discoverable, size_t device_index)
checks if the href (url) belongs to the device
int find_empty_slot_in_group_object_table(int id)
find empty slot in group object table
void oc_delete_group_object_table()
delete all entries of the Group Object Table (from persistent) storage
int oc_core_find_index_in_recipient_table_from_id(int id)
find index of id in recipient table
int oc_print_reduced_group_recipient_table(void)
Prints a reduced version of the entries of the group recipient table: Only id, iid and grpid are prin...
void oc_delete_group_object_table_entry(int entry)
delete entry of the Group Object Table does not make the change persistent
int oc_core_find_index_in_publisher_table_from_id(int id)
find index of id in publisher table
void oc_dump_group_object_table_entry(int entry)
dump the entry of the Group Object Table (to persistent) storage
int oc_core_set_group_object_table(int index, oc_group_object_table_t entry)
set an entry in the group object table
void oc_load_group_object_table()
load all entries of the Group Object Table (from persistent) storage
int oc_core_find_group_object_table_index(uint32_t group_address)
find (first) index in the group address table
int oc_core_find_group_object_table_group_entry(int index, int entry)
get group address of index, and entry (e.g.
void oc_free_knx_fp_resources(size_t device_index)
free the fp resources e.g.
void subscribe_group_to_multicast_with_port(uint32_t group_nr, int64_t iid, int scope, int port)
subscribe to a multicast address, defined by group number and installation id
oc_string_t oc_core_find_group_object_table_url_from_index(int index)
find the url (of the resource) that in the group object table entry.
int oc_core_find_group_object_table_url(const char *url)
find (first) index in the group address table via url
int oc_core_add_recipient_entry(int index, oc_group_rp_table_t entry)
add recipient entry
void unsubscribe_group_to_multicast(uint32_t group_nr, int64_t iid, int scope)
unsubscribe to a multicast address, defined by group number and installation id
void oc_create_knx_fp_resources(size_t device_index)
Creation of the KNX feature point resources.
bool oc_add_points_in_group_object_table_to_response(oc_request_t *request, size_t device_index, uint32_t group_address, size_t *response_length, int matches)
add points to the well-known core discovery response when the request has query option ....
void oc_delete_group_rp_table()
delete all entries of the Recipient and Publisher Object Table (from persistent) storage
char * oc_core_get_recipient_index_url_or_path(int index)
get the destination (path or url) of the recipient table at index
int oc_core_find_index_in_group_object_table_from_id(int id)
find index belonging to the id
void oc_print_group_object_table_entry(int entry)
print the entry in the Group Object Table
oc_group_object_table_t * oc_core_get_group_object_table_entry(int index)
retrieve the group object table entry
int oc_print_reduced_group_publisher_table(void)
Prints a reduced version of the entries of the group publisher table: Only id, iid and grpid are prin...
oc_cflag_mask_t oc_core_group_object_table_cflag_entries(int index)
retrieve the cflags from the entry table
void unsubscribe_group_to_multicast_with_port(uint32_t group_nr, int64_t iid, int scope, int port)
unsubscribe to a multicast address, defined by group number and installation id and port
int oc_core_add_publisher_entry(int index, oc_group_rp_table_t entry)
add publisher entry
uint32_t oc_find_grpid_in_recipient_table(uint32_t group_address)
find the grpid from the group_address in the recipient table
bool oc_core_check_recipient_index_on_group_address(int index, uint32_t group_address)
checks if the group address is part of the recipient table at index
int oc_core_find_next_group_object_table_index(uint32_t group_address, int cur_index)
find next index in the group address table
void oc_print_cflags(oc_cflag_mask_t cflags)
print the communication flags to standard output communication flags in ASCII e.g.
oc_group_rp_table_t * oc_core_get_publisher_table_entry(int index)
retrieve the publisher table entry
int oc_core_get_recipient_table_size()
return the size of the recipient table
int oc_core_find_empty_slot_in_publisher_table(int id)
find empty slot in recipient table
oc_endpoint_t oc_create_multicast_group_address_with_port(oc_endpoint_t in, uint32_t group_nr, int64_t iid, int scope, int port)
create the group multi cast address with port
void oc_init_datapoints_at_initialization()
initializes the data points at initialization e.g.
int oc_core_find_next_group_object_table_url(const char *url, int cur_index)
find next index in the group address table via url
resource internals
the endpoint information
Definition: oc_endpoint.h:78
Group Object Table Resource (/fp/g) The payload is an array of objects.
Definition: oc_knx_fp.h:119
oc_cflag_mask_t cflags
contents of cflags as bitmap
Definition: oc_knx_fp.h:122
int ga_len
length of the array of ga identifiers
Definition: oc_knx_fp.h:123
int id
contents of id
Definition: oc_knx_fp.h:120
uint32_t * ga
array of group addresses (unsigned integers)
Definition: oc_knx_fp.h:124
oc_string_t href
contents of href
Definition: oc_knx_fp.h:121
Function point Recipient - Publisher Table Resource (/fp/r) (/fp/p)
Definition: oc_knx_fp.h:176
oc_string_t at
Access token id.
Definition: oc_knx_fp.h:184
oc_string_t url
contents of url
Definition: oc_knx_fp.h:183
int ga_len
length of the array of group addresses identifiers
Definition: oc_knx_fp.h:187
int ia
contents of ia (individual address)
Definition: oc_knx_fp.h:178
int mt
The number of maximum retransmissions for CON & NON requests.
Definition: oc_knx_fp.h:189
uint32_t grpid
the multicast group id
Definition: oc_knx_fp.h:181
int id
contents of id
Definition: oc_knx_fp.h:177
uint32_t * ga
array of integers
Definition: oc_knx_fp.h:186
oc_string_t path
contents of path, default path = ".knx"
Definition: oc_knx_fp.h:182
int64_t iid
contents of installation id
Definition: oc_knx_fp.h:179
bool non
true = non-confirmable unicast request, default = false
Definition: oc_knx_fp.h:188
int64_t fid
contents of fabric id
Definition: oc_knx_fp.h:180
parsed entry of a cbor object This represents a link list of response values one can iterate over the...
Definition: oc_rep.h:1642
request information structure
Definition: oc_ri.h:412