KNX IoT
KNX IoT Point API stack implementation
|
Example device implementing Function Block LSABExample code for Function Block LSAB. More...
#include "oc_api.h"
#include "oc_core_res.h"
#include "api/oc_knx_fp.h"
#include "port/oc_clock.h"
#include <signal.h>
#include "api/oc_knx_dev.h"
#include <stdio.h>
#include <unistd.h>
Go to the source code of this file.
Macros | |
#define | _WIN32_WINNT 0x8000 |
#define | btoa(x) ((x) ? "true" : "false") |
#define | GetCurrentDir getcwd |
#define | MY_NAME "Actuator (LSAB) 417" |
The name of the application. More... | |
#define | STATIC static |
Functions | |
int | app_init (void) |
function to set up the device. More... | |
void | factory_presets_cb (size_t device, void *data) |
initiate preset for device current implementation: device reset as command line argument More... | |
STATIC void | get_o_1_1 (oc_request_t *request, oc_interface_mask_t interfaces, void *user_data) |
get method for "p/o_1_1" resource. More... | |
void | handle_signal (int signal) |
handle Ctrl-C More... | |
void | hostname_cb (size_t device_index, oc_string_t host_name, void *data) |
set the host name on the device (application depended) More... | |
void | initialize_variables (void) |
initializes the global variables registers and starts the handler More... | |
int | main (int argc, char *argv[]) |
main application. More... | |
void | print_usage () |
print usage and quits More... | |
STATIC void | put_o_1_1 (oc_request_t *request, oc_interface_mask_t interfaces, void *user_data) |
Put method for "p/o_1_1" resource. More... | |
void | register_resources (void) |
register all the resources to the stack this function registers all application level resources: More... | |
void | reset_cb (size_t device_index, int reset_value, void *data) |
application reset More... | |
void | restart_cb (size_t device_index, void *data) |
restart the device (application depended) More... | |
void | swu_cb (size_t device, oc_separate_response_t *response, size_t binary_size, size_t offset, uint8_t *payload, size_t len, void *data) |
software update callback More... | |
Variables | |
bool | g_mystate = false |
the state of the dpa 417.61 More... | |
bool | g_reset = false |
reset the device (from startup) More... | |
volatile int | quit = 0 |
stop variable, used by handle_signal More... | |
Example device implementing Function Block LSAB
Example code for Function Block LSAB.
Implements data point 61: switch on/off. This implementation is a actuator, e.g. receives data and acts on it.
Support functions:
main:
Handlers for the implemented methods (get/post):
stack specific defines:
File specific defines:
Definition in file lsab_minimal_all.c.
#define MY_NAME "Actuator (LSAB) 417" |
The name of the application.
Definition at line 100 of file lsab_minimal_all.c.
int app_init | ( | void | ) |
function to set up the device.
sets the:
Definition at line 134 of file lsab_minimal_all.c.
References MY_NAME, oc_add_device(), oc_core_get_device_info(), and oc_init_platform().
void factory_presets_cb | ( | size_t | device, |
void * | data | ||
) |
initiate preset for device current implementation: device reset as command line argument
device | the device identifier of the list of devices |
data | the supplied data. |
Definition at line 377 of file lsab_minimal_all.c.
References g_reset.
STATIC void get_o_1_1 | ( | oc_request_t * | request, |
oc_interface_mask_t | interfaces, | ||
void * | user_data | ||
) |
get method for "p/o_1_1" resource.
function is called to initialize the return values of the GET method. initialization of the returned values are done from the global property values. Resource Description: This Resource describes a binary switch (on/off). The Property "value" is a boolean. A value of 'true' means that the switch is on. A value of 'false' means that the switch is off.
request | the request representation. |
interfaces | the interface used for this call |
user_data | the user data. |
Definition at line 185 of file lsab_minimal_all.c.
References oc_status_code(), and OC_STATUS_OK.
void handle_signal | ( | int | signal | ) |
handle Ctrl-C
signal | the captured signal |
Definition at line 522 of file lsab_minimal_all.c.
References quit.
Referenced by main().
void hostname_cb | ( | size_t | device_index, |
oc_string_t | host_name, | ||
void * | data | ||
) |
set the host name on the device (application depended)
device_index | the device identifier of the list of devices |
host_name | the host name to be set on the device |
data | the supplied data. |
Definition at line 428 of file lsab_minimal_all.c.
void initialize_variables | ( | void | ) |
initializes the global variables registers and starts the handler
Definition at line 485 of file lsab_minimal_all.c.
int main | ( | int | argc, |
char * | argv[] | ||
) |
main application.
initializes the global variables registers and starts the handler handles (in a loop) the next event. shuts down the stack
Definition at line 551 of file lsab_minimal_all.c.
References handle_signal().
void print_usage | ( | ) |
print usage and quits
Definition at line 534 of file lsab_minimal_all.c.
STATIC void put_o_1_1 | ( | oc_request_t * | request, |
oc_interface_mask_t | interfaces, | ||
void * | user_data | ||
) |
Put method for "p/o_1_1" resource.
The function has as input the request body, which are the input values of the PUT method. The input values (as a set) are checked if all supplied values are correct. If the input values are correct, they will be assigned to the global property values. Resource Description:
request | the request representation. |
interfaces | the used interfaces during the request. |
user_data | the supplied user data. |
Definition at line 292 of file lsab_minimal_all.c.
void register_resources | ( | void | ) |
register all the resources to the stack this function registers all application level resources:
URL Table
resource url | functional block/dpa | GET | PUT |
---|---|---|---|
p/o_1_1 | urn:knx:dpa.417.61 | Yes | Yes |
Definition at line 340 of file lsab_minimal_all.c.
void reset_cb | ( | size_t | device_index, |
int | reset_value, | ||
void * | data | ||
) |
application reset
device_index | the device identifier of the list of devices |
reset_value | the knx reset value |
data | the supplied data. |
Definition at line 396 of file lsab_minimal_all.c.
void restart_cb | ( | size_t | device_index, |
void * | data | ||
) |
restart the device (application depended)
device_index | the device identifier of the list of devices |
data | the supplied data. |
Definition at line 411 of file lsab_minimal_all.c.
void swu_cb | ( | size_t | device, |
oc_separate_response_t * | response, | ||
size_t | binary_size, | ||
size_t | offset, | ||
uint8_t * | payload, | ||
size_t | len, | ||
void * | data | ||
) |
software update callback
device | the device index |
response | the instance of an internal struct that is used to track the state of the separate response |
binary_size | the full size of the binary |
offset | the offset of the image |
payload | the image data |
len | the length of the image data |
data | the user data |
Definition at line 465 of file lsab_minimal_all.c.
bool g_mystate = false |
the state of the dpa 417.61
Definition at line 116 of file lsab_minimal_all.c.
bool g_reset = false |
reset the device (from startup)
Definition at line 118 of file lsab_minimal_all.c.
Referenced by factory_presets_cb().
volatile int quit = 0 |
stop variable, used by handle_signal
Definition at line 117 of file lsab_minimal_all.c.
Referenced by handle_signal().