KNX IoT
KNX IoT Point API stack implementation
|
Example device implementing Function Block LSSBExample code for Function Block LSSB Implements only data point 61: switch on/off This implementation is a sensor, e.g. 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 "Sensor (LSSB) 421.61" |
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_index, 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 | oc_add_s_mode_response_cb (char *url, oc_rep_t *rep, oc_rep_t *rep_value) |
s-mode response callback will be called when a response is received on an s-mode read request More... | |
void | print_usage () |
print usage and quits 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 421.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 LSSB
Example code for Function Block LSSB Implements only data point 61: switch on/off This implementation is a sensor, e.g.
transmits data
support functions:
main starts the stack, with the registered resources. can be compiled out with NO_MAIN
handlers for the implemented methods (get/post):
stack specific defines:
File specific defines:
Definition in file lssb_minimal_all.c.
#define MY_NAME "Sensor (LSSB) 421.61" |
The name of the application.
Definition at line 100 of file lssb_minimal_all.c.
int app_init | ( | void | ) |
function to set up the device.
sets the:
Definition at line 151 of file lssb_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_index, |
void * | data | ||
) |
initiate preset for device current implementation: device reset as command line argument
device_index | the device identifier of the list of devices |
data | the supplied data. |
Definition at line 347 of file lssb_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 202 of file lssb_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 504 of file lssb_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 397 of file lssb_minimal_all.c.
void initialize_variables | ( | void | ) |
initializes the global variables registers and starts the handler
Definition at line 454 of file lssb_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 535 of file lssb_minimal_all.c.
References handle_signal().
s-mode response callback will be called when a response is received on an s-mode read request
url | the url |
rep | the full response |
rep_value | the parsed value of the response |
Definition at line 129 of file lssb_minimal_all.c.
void print_usage | ( | ) |
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.421.61 | Yes | No |
Definition at line 313 of file lssb_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 366 of file lssb_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 380 of file lssb_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 434 of file lssb_minimal_all.c.
bool g_mystate = false |
the state of the dpa 421.61
Definition at line 116 of file lssb_minimal_all.c.
bool g_reset = false |
reset the device (from startup)
Definition at line 118 of file lssb_minimal_all.c.
Referenced by factory_presets_cb().
volatile int quit = 0 |
stop variable, used by handle_signal
Definition at line 117 of file lssb_minimal_all.c.
Referenced by handle_signal().