mgmt/osdp: Split CP and PD samples into dedicated directories
Split CP and PD samples into dedicated directories as the difference between the two are expected to grow with time. Also, do some refactoring. Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
This commit is contained in:
parent
8d012aace9
commit
c529b6fa8f
10 changed files with 84 additions and 45 deletions
|
@ -1,13 +0,0 @@
|
|||
#
|
||||
# Copyright (c) 2020 Siddharth Chandrasekaran <siddharth@embedjournal.com>
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.13.1)
|
||||
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
|
||||
|
||||
project(osdp_sample)
|
||||
|
||||
target_sources_ifdef(CONFIG_OSDP_MODE_PD app PRIVATE src/pd_main.c)
|
||||
target_sources_ifdef(CONFIG_OSDP_MODE_CP app PRIVATE src/cp_main.c)
|
|
@ -1,13 +1,18 @@
|
|||
.. _osdp-sample:
|
||||
|
||||
OSDP
|
||||
####
|
||||
Open Supervised Device Protocol (OSDP)
|
||||
######################################
|
||||
|
||||
OSDP describes the communication interface one or more Peripheral Devices (PD)
|
||||
to a Control Panel (CP). The specification describes the protocol
|
||||
implementation over a two-wire RS-485 multi-drop serial communication channel.
|
||||
Nevertheless, this protocol can be used to transfer secure byte stream over any
|
||||
physical channel in low memory embedded devices.
|
||||
Open Supervised Device Protocol (OSDP) is an IEC standard (IEC 60839-11-5)
|
||||
intended to improve interoperability among access control and security products.
|
||||
It supports Secure Channel (SC) for encrypted and authenticated communication
|
||||
between configured devices.
|
||||
|
||||
OSDP describes the communication protocol for interfacing one or more Peripheral
|
||||
Devices (PD) to a Control Panel (CP) over a two-wire RS-485 multi-drop serial
|
||||
communication channel. Nevertheless, this protocol can be used to transfer
|
||||
secure data over any stream based physical channel. Read more about `OSDP here
|
||||
<https://libosdp.gotomain.io/>`_..
|
||||
|
||||
Although OSDP is steered towards the Access and Security industries, it can be
|
||||
used as a general communication protocol for devices in a secure way without
|
||||
|
|
12
samples/subsys/mgmt/osdp/control_panel/CMakeLists.txt
Normal file
12
samples/subsys/mgmt/osdp/control_panel/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# Copyright (c) 2020 Siddharth Chandrasekaran <siddharth@embedjournal.com>
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.13.1)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(osdp_cp_sample)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
|
@ -9,3 +9,6 @@ CONFIG_LOG=y
|
|||
|
||||
# OSDP config
|
||||
CONFIG_OSDP=y
|
||||
CONFIG_OSDP_MODE_CP=y
|
||||
|
||||
CONFIG_OSDP_LOG_LEVEL=4
|
|
@ -1,8 +1,8 @@
|
|||
sample:
|
||||
description: OSDP Sample
|
||||
description: OSDP Control Panel Sample
|
||||
name: osdp
|
||||
tests:
|
||||
sample.mgmt.osdp:
|
||||
sample.mgmt.osdp.control_panel:
|
||||
tags: osdp
|
||||
filter: dt_compat_enabled_with_alias("gpio-leds", "led0") and CONFIG_SERIAL
|
||||
harness: osdp
|
|
@ -14,21 +14,16 @@
|
|||
|
||||
#if DT_NODE_HAS_STATUS(LED0_NODE, okay)
|
||||
#define LED0 DT_GPIO_LABEL(LED0_NODE, gpios)
|
||||
#define PIN DT_GPIO_PIN(LED0_NODE, gpios)
|
||||
#if DT_PHA_HAS_CELL(LED0_NODE, gpios, flags)
|
||||
#define LED0_PIN DT_GPIO_PIN(LED0_NODE, gpios)
|
||||
#define FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios)
|
||||
#endif
|
||||
#else
|
||||
#error "BOARD does not define a debug LED"
|
||||
#define LED0 ""
|
||||
#define PIN 0
|
||||
#endif
|
||||
|
||||
#ifndef FLAGS
|
||||
#define LED0_PIN 0
|
||||
#define FLAGS 0
|
||||
#endif
|
||||
|
||||
#define SLEEP_TIME_MS (5)
|
||||
#define SLEEP_TIME_MS (20)
|
||||
#define CNT_PER_SEC (1000 / SLEEP_TIME_MS)
|
||||
#define COMMAND_WAIT_TIME_SEC (10)
|
||||
#define COMMAND_WAIT_COUNT (COMMAND_WAIT_TIME_SEC * CNT_PER_SEC)
|
||||
|
@ -77,7 +72,7 @@ void main(void)
|
|||
return;
|
||||
}
|
||||
|
||||
ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
|
||||
ret = gpio_pin_configure(dev, LED0_PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
|
||||
if (ret < 0) {
|
||||
printk("Failed to configure gpio pin\n");
|
||||
return;
|
||||
|
@ -95,7 +90,7 @@ void main(void)
|
|||
if ((cnt % COMMAND_WAIT_COUNT) == 0) {
|
||||
osdp_cp_send_command(OSDP_PD_0, &pulse_output);
|
||||
}
|
||||
gpio_pin_set(dev, PIN, led_state);
|
||||
gpio_pin_set(dev, LED0_PIN, led_state);
|
||||
k_msleep(SLEEP_TIME_MS);
|
||||
cnt++;
|
||||
}
|
12
samples/subsys/mgmt/osdp/peripheral_device/CMakeLists.txt
Normal file
12
samples/subsys/mgmt/osdp/peripheral_device/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# Copyright (c) 2020 Siddharth Chandrasekaran <siddharth@embedjournal.com>
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.13.1)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(osdp_pd_sample)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
14
samples/subsys/mgmt/osdp/peripheral_device/prj.conf
Normal file
14
samples/subsys/mgmt/osdp/peripheral_device/prj.conf
Normal file
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# Copyright (c) 2020 Siddharth Chandrasekaran <siddharth@embedjournal.com>
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_LOG=y
|
||||
|
||||
# OSDP config
|
||||
CONFIG_OSDP=y
|
||||
CONFIG_OSDP_MODE_PD=y
|
||||
|
||||
CONFIG_OSDP_LOG_LEVEL=4
|
10
samples/subsys/mgmt/osdp/peripheral_device/sample.yaml
Normal file
10
samples/subsys/mgmt/osdp/peripheral_device/sample.yaml
Normal file
|
@ -0,0 +1,10 @@
|
|||
sample:
|
||||
description: OSDP Peripheral Device Sample
|
||||
name: osdp
|
||||
tests:
|
||||
sample.mgmt.osdp.peripheral_device:
|
||||
tags: osdp
|
||||
filter: dt_compat_enabled_with_alias("gpio-leds", "led0") and CONFIG_SERIAL
|
||||
harness: osdp
|
||||
integration_platforms:
|
||||
- frdm_k64f
|
|
@ -14,16 +14,17 @@
|
|||
|
||||
#if DT_NODE_HAS_STATUS(LED0_NODE, okay)
|
||||
#define LED0 DT_GPIO_LABEL(LED0_NODE, gpios)
|
||||
#define PIN DT_GPIO_PIN(LED0_NODE, gpios)
|
||||
#define LED0_PIN DT_GPIO_PIN(LED0_NODE, gpios)
|
||||
#define FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios)
|
||||
#else
|
||||
#error "BOARD does not define a debug LED"
|
||||
#define LED0 ""
|
||||
#define PIN 0
|
||||
#define LED0_PIN 0
|
||||
#define FLAGS 0
|
||||
#endif
|
||||
|
||||
#define SLEEP_TIME_MS 10
|
||||
#define SLEEP_TIME_MS (20)
|
||||
#define CNT_PER_SEC (1000 / SLEEP_TIME_MS)
|
||||
|
||||
int cmd_handler(struct osdp_cmd *p)
|
||||
{
|
||||
|
@ -44,7 +45,7 @@ void main(void)
|
|||
return;
|
||||
}
|
||||
|
||||
ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
|
||||
ret = gpio_pin_configure(dev, LED0_PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
|
||||
if (ret < 0) {
|
||||
printk("Failed to configure gpio pin\n");
|
||||
return;
|
||||
|
@ -59,7 +60,7 @@ void main(void)
|
|||
if (osdp_pd_get_cmd(&cmd) == 0) {
|
||||
cmd_handler(&cmd);
|
||||
}
|
||||
gpio_pin_set(dev, PIN, led_state);
|
||||
gpio_pin_set(dev, LED0_PIN, led_state);
|
||||
k_msleep(SLEEP_TIME_MS);
|
||||
cnt++;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue