KNX IoT
KNX IoT Point API stack implementation
|
knx /fp resource implementations More...
Go to the source code of this file.
Data Structures | |
struct | oc_group_object_table_t |
Group Object Table Resource (/fp/g) The payload is an array of objects. More... | |
struct | oc_group_rp_table_t |
Function point Recipient - Publisher Table Resource (/fp/r) (/fp/p) More... | |
Typedefs | |
typedef struct oc_group_object_table_t | oc_group_object_table_t |
Group Object Table Resource (/fp/g) The payload is an array of objects. More... | |
typedef struct oc_group_rp_table_t | oc_group_rp_table_t |
Function point Recipient - Publisher Table Resource (/fp/r) (/fp/p) More... | |
Enumerations | |
enum | oc_cflag_mask_t { OC_CFLAG_NONE = 0 , OC_CFLAG_COMMUNICATION , OC_CFLAG_READ = 1 << 3 , OC_CFLAG_WRITE , OC_CFLAG_INIT = 1 << 5 , OC_CFLAG_TRANSMISSION , OC_CFLAG_UPDATE } |
cflag masks More... | |
Functions | |
int | find_empty_slot_in_group_object_table (int id) |
find empty slot in group object table More... | |
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 .well-known/core?d=urn:knx:g.s. More... | |
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 More... | |
void | oc_cflags_as_string (char *buffer, oc_cflag_mask_t cflags) |
adds the communication flags a preallocated buffer More... | |
int | oc_core_add_publisher_entry (int index, oc_group_rp_table_t entry) |
add publisher entry More... | |
int | oc_core_add_recipient_entry (int index, oc_group_rp_table_t entry) |
add recipient entry More... | |
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 More... | |
int | oc_core_find_empty_slot_in_publisher_table (int id) |
find empty slot in recipient table More... | |
int | oc_core_find_empty_slot_in_recipient_table (int id) |
find empty slot in recipient table More... | |
int | oc_core_find_group_object_table_group_entry (int index, int entry) |
get group address of index, and entry (e.g. More... | |
int | oc_core_find_group_object_table_index (uint32_t group_address) |
find (first) index in the group address table More... | |
int | oc_core_find_group_object_table_number_group_entries (int index) |
retrieve the number of group address entries for index More... | |
int | oc_core_find_group_object_table_url (const char *url) |
find (first) index in the group address table via url More... | |
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. More... | |
int | oc_core_find_index_in_group_object_table_from_id (int id) |
find index belonging to the id More... | |
int | oc_core_find_index_in_publisher_table_from_id (int id) |
find index of id in publisher table More... | |
int | oc_core_find_index_in_recipient_table_from_id (int id) |
find index of id in recipient table More... | |
int | oc_core_find_next_group_object_table_index (uint32_t group_address, int cur_index) |
find next index in the group address table More... | |
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 More... | |
oc_group_object_table_t * | oc_core_get_group_object_table_entry (int index) |
retrieve the group object table entry More... | |
int | oc_core_get_group_object_table_total_size () |
retrieve the group object table total size, e.g. More... | |
oc_group_rp_table_t * | oc_core_get_publisher_table_entry (int index) |
retrieve the publisher table entry More... | |
int | oc_core_get_publisher_table_size () |
return the size of the publisher table More... | |
uint32_t | oc_core_get_recipient_ia (int index) |
retrieve the internal address of the recipient in the table More... | |
char * | oc_core_get_recipient_index_url_or_path (int index) |
get the destination (path or url) of the recipient table at index More... | |
oc_group_rp_table_t * | oc_core_get_recipient_table_entry (int index) |
retrieve the recipient table entry More... | |
int | oc_core_get_recipient_table_size () |
return the size of the recipient table More... | |
oc_cflag_mask_t | oc_core_group_object_table_cflag_entries (int index) |
retrieve the cflags from the entry table More... | |
int | oc_core_set_group_object_table (int index, oc_group_object_table_t entry) |
set an entry in the group object table More... | |
void | oc_create_knx_fp_resources (size_t device_index) |
Creation of the KNX feature point resources. More... | |
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 More... | |
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 More... | |
void | oc_delete_group_object_table () |
delete all entries of the Group Object Table (from persistent) storage More... | |
void | oc_delete_group_object_table_entry (int entry) |
delete entry of the Group Object Table does not make the change persistent More... | |
void | oc_delete_group_rp_table () |
delete all entries of the Recipient and Publisher Object Table (from persistent) storage More... | |
void | oc_dump_group_object_table_entry (int entry) |
dump the entry of the Group Object Table (to persistent) storage More... | |
uint32_t | oc_find_grpid_in_publisher_table (uint32_t group_address) |
find the grpid from the group_address in the publisher table More... | |
uint32_t | oc_find_grpid_in_recipient_table (uint32_t group_address) |
find the grpid from the group_address in the recipient table More... | |
void | oc_free_knx_fp_resources (size_t device_index) |
free the fp resources e.g. More... | |
void | oc_init_datapoints_at_initialization () |
initializes the data points at initialization e.g. More... | |
void | oc_load_group_object_table () |
load all entries of the Group Object Table (from persistent) storage More... | |
void | oc_load_group_object_table_entry (int entry) |
load the entry of the Group Object Table (from persistent) storage More... | |
void | oc_print_cflags (oc_cflag_mask_t cflags) |
print the communication flags to standard output communication flags in ASCII e.g. More... | |
void | oc_print_group_object_table_entry (int entry) |
print the entry in the Group Object Table More... | |
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 printed for each entry. More... | |
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 printed for each entry. More... | |
void | oc_register_group_multicasts () |
register the multicast addresses to listen to More... | |
int | oc_table_find_id_from_rep (oc_rep_t *object) |
find id (cbor key 0) in the response More... | |
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 5683 More... | |
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 More... | |
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 More... | |
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 More... | |
knx /fp resource implementations
Definition in file oc_knx_fp.h.
typedef struct oc_group_object_table_t oc_group_object_table_t |
Group Object Table Resource (/fp/g) The payload is an array of objects.
Example (JSON):
cflag translation
string | bit | value |
---|---|---|
c | 2 | 4 |
r | 3 | 8 |
w | 4 | 16 |
i | 5 | 32 |
t | 6 | 64 |
u | 7 | 128 |
Key translation
Json Key | Integer Value |
---|---|
id | 0 |
href | 11 |
ga | 7 |
cflag | 8 |
The structure stores the information. The structure will be used as an array. There are function to find
typedef struct oc_group_rp_table_t oc_group_rp_table_t |
Function point Recipient - Publisher Table Resource (/fp/r) (/fp/p)
the same table is used for recipient and publisher. the only difference is the confirmable/not confirmable flag. There will be 2 arrays of the structure to store the /fp/r or /fp/p data
Example (JSON): array of objects
Key translation
Json Key | Integer Value |
---|---|
id | 0 |
ia | 12 |
iid | 26 |
fid | 25 |
grpid | 13 |
path | 112 |
url | 10 |
ga | 7 |
non | - |
The structure stores the information. The structure will be used as an array. There are function to find:
enum oc_cflag_mask_t |
cflag masks
Group Object Table Resource (/fp/g)
Definition at line 37 of file oc_knx_fp.h.
int find_empty_slot_in_group_object_table | ( | int | id | ) |
find empty slot in group object table
id | the index |
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 .well-known/core?d=urn:knx:g.s.
[group-address]
request | The request |
device_index | The device index |
group_address | the parsed group address from the query option |
response_length | the response length |
matches | if there are matches |
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
href | the url to be checked if it belongs to the device |
discoverable | checks only discoverable devices, e.g. belonging to a function (/fp) |
device_index | The device index |
void oc_cflags_as_string | ( | char * | buffer, |
oc_cflag_mask_t | cflags | ||
) |
adds the communication flags a preallocated buffer
cflags in ASCII e.g. "w" "r" "i" "t" "u" without quotes if the flag does not exist, then a "." will be added instead
buffer | the string buffer to add the cflags too |
cflags | The communication flags |
int oc_core_add_publisher_entry | ( | int | index, |
oc_group_rp_table_t | entry | ||
) |
add publisher entry
index | The index in the table |
entry | The entry to be added |
int oc_core_add_recipient_entry | ( | int | index, |
oc_group_rp_table_t | entry | ||
) |
add recipient entry
index | The index in the table |
entry | The entry to be added |
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
index | the index in the recipient table |
group_address | the group address to check |
int oc_core_find_empty_slot_in_publisher_table | ( | int | id | ) |
find empty slot in recipient table
id | : supply 0 |
int oc_core_find_empty_slot_in_recipient_table | ( | int | id | ) |
find empty slot in recipient table
id | : supply 0 |
int oc_core_find_group_object_table_group_entry | ( | int | index, |
int | entry | ||
) |
get group address of index, and entry (e.g.
list)
index | the entry in the group address table |
entry | the entry in the list of addresses at index |
int oc_core_find_group_object_table_index | ( | uint32_t | group_address | ) |
find (first) index in the group address table
group_address | the group address |
int oc_core_find_group_object_table_number_group_entries | ( | int | index | ) |
retrieve the number of group address entries for index
index | the index in the group address table |
int oc_core_find_group_object_table_url | ( | const char * | url | ) |
find (first) index in the group address table via url
url | The url to find |
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.
index | the index in the table |
int oc_core_find_index_in_group_object_table_from_id | ( | int | id | ) |
find index belonging to the id
id | the identifier of the entry |
int oc_core_find_index_in_publisher_table_from_id | ( | int | id | ) |
find index of id in publisher table
id | index to find |
int oc_core_find_index_in_recipient_table_from_id | ( | int | id | ) |
find index of id in recipient table
id | index to find |
int oc_core_find_next_group_object_table_index | ( | uint32_t | group_address, |
int | cur_index | ||
) |
find next index in the group address table
group_address | the group address |
cur_index | the current index to start from. |
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
url | The url to find |
cur_index | The current index to start from. |
oc_group_object_table_t* oc_core_get_group_object_table_entry | ( | int | index | ) |
retrieve the group object table entry
Note that always the group object table is returned. regardless if the data is valid or not.
To check if the data is valid, please check if ga_len > 0, if ga_len <= 0 then the group object table does not contain an entry.
index | the index in the group object table |
int oc_core_get_group_object_table_total_size | ( | ) |
retrieve the group object table total size, e.g.
the number of entries that can be stored
oc_group_rp_table_t* oc_core_get_publisher_table_entry | ( | int | index | ) |
retrieve the publisher table entry
Note that always the group object table is returned. regardless if the data is valid or not.
To check if the data is valid, please check if ga_len > 0, if ga_len <= 0 then the group object table does not contain an entry.
index | the index in the publisher table |
int oc_core_get_publisher_table_size | ( | ) |
return the size of the publisher table
uint32_t oc_core_get_recipient_ia | ( | int | index | ) |
retrieve the internal address of the recipient in the table
index | the index number in the recipient table |
char* oc_core_get_recipient_index_url_or_path | ( | int | index | ) |
get the destination (path or url) of the recipient table at index
index | the index in the table |
oc_group_rp_table_t* oc_core_get_recipient_table_entry | ( | int | index | ) |
retrieve the recipient table entry
Note that always the group object table is returned. regardless if the data is valid or not.
To check if the data is valid, please check if ga_len > 0, if ga_len <= 0 then the group object table does not contain an entry.
index | the index in the recipient table |
int oc_core_get_recipient_table_size | ( | ) |
return the size of the recipient table
oc_cflag_mask_t oc_core_group_object_table_cflag_entries | ( | int | index | ) |
retrieve the cflags from the entry table
index | the index in the group object table |
int oc_core_set_group_object_table | ( | int | index, |
oc_group_object_table_t | entry | ||
) |
set an entry in the group object table
index | the index where to add the entry |
entry | the group object entry |
void oc_create_knx_fp_resources | ( | size_t | device_index | ) |
Creation of the KNX feature point resources.
device_index | index of the device to which the resource are to be created |
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
in | the endpoint to adapt |
group_nr | the group number |
iid | the installation id |
scope | the address scope |
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
create the multicast address from group and scope with a supplied port number
in | the endpoint to adapt |
group_nr | the group number |
iid | the installation id |
scope | the address scope |
port | the port to be used |
void oc_delete_group_object_table | ( | ) |
delete all entries of the Group Object Table (from persistent) storage
void oc_delete_group_object_table_entry | ( | int | entry | ) |
delete entry of the Group Object Table does not make the change persistent
entry | the index of the entry in the Group Object Table |
void oc_delete_group_rp_table | ( | ) |
delete all entries of the Recipient and Publisher Object Table (from persistent) storage
void oc_dump_group_object_table_entry | ( | int | entry | ) |
dump the entry of the Group Object Table (to persistent) storage
entry | the index of the entry in the Group Object Table |
uint32_t oc_find_grpid_in_publisher_table | ( | uint32_t | group_address | ) |
find the grpid from the group_address in the publisher table
group_address | The group_address from the group object table |
uint32_t oc_find_grpid_in_recipient_table | ( | uint32_t | group_address | ) |
find the grpid from the group_address in the recipient table
group_address | The group_address from the group object table |
void oc_free_knx_fp_resources | ( | size_t | device_index | ) |
free the fp resources e.g.
frees up all allocated memory.
device_index | index of the device to which the resource are to be freed. |
void oc_init_datapoints_at_initialization | ( | ) |
initializes the data points at initialization e.g.
sends out an read s-mode message when the I flag is set.
void oc_load_group_object_table | ( | ) |
load all entries of the Group Object Table (from persistent) storage
void oc_load_group_object_table_entry | ( | int | entry | ) |
load the entry of the Group Object Table (from persistent) storage
entry | the index of the entry in the Group Object Table |
void oc_print_cflags | ( | oc_cflag_mask_t | cflags | ) |
print the communication flags to standard output communication flags in ASCII e.g.
"w" "r" "i" "t" "u" without quotes
cflags | the communication flags |
void oc_print_group_object_table_entry | ( | int | entry | ) |
print the entry in the Group Object Table
entry | the index of the entry in the Group Object Table |
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 printed for each entry.
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 printed for each entry.
void oc_register_group_multicasts | ( | ) |
register the multicast addresses to listen to
The addresses are formed from:
for situation 1):
for situation 2):
function is called when the device is (re)started in run-time mode (e.g. state = "loaded")
int oc_table_find_id_from_rep | ( | oc_rep_t * | object | ) |
find id (cbor key 0) in the response
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 5683
group_nr | the group number (address) |
iid | the installation id |
scope | the address scope |
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
group_nr | the group number (address) |
iid | the installation id |
scope | the address scope |
port | the port |
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
group_nr | the group number (address) |
iid | the installation id |
scope | the address scope |
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
group_nr | the group number (address) |
iid | the installation id |
scope | the address scope |
port | the port |