├── firmwares
└── .gitkeep
├── images
├── z2m.png
├── back_2xAAA.png
├── back_DC_5-9V.png
├── dimensions.png
├── front_side.png
├── z2m_exposes.png
├── front_side_rgb.png
├── z2m_dashboard.gif
├── fix_error_rings.png
└── battery_no_handset.png
├── CC2530DB
├── settings
│ └── GenericApp.reggroups
└── GenericApp.eww
├── Source
├── version.h
├── preinclude.h
├── OSAL_App.c
├── zcl_app.h
├── zcl_app_data.c
├── zcl_app.c
└── hal_board_cfg.h
├── hardware
├── BOM_Zintercom.csv
├── Gerber_Zintercom.zip
├── Gerber_Zintercom_rgb.zip
├── Schematic_Zintercom.png
├── Домофон zintercom.docx
└── Schematic_Zintercom_rgb.png
├── .gitmodules
├── .clang-format
├── .release-it.yml
├── .github
└── FUNDING.yml
├── ver.py
├── .gitignore
├── README-RGB.md
├── .vscode
└── c_cpp_properties.json
├── README.md
├── converters
└── DIYRuZ_Zintercom.js
└── LICENSE
/firmwares/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/images/z2m.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/images/z2m.png
--------------------------------------------------------------------------------
/CC2530DB/settings/GenericApp.reggroups:
--------------------------------------------------------------------------------
1 | group = "io", "P0"
2 | group = "Unnamed2", "P1"
3 |
--------------------------------------------------------------------------------
/Source/version.h:
--------------------------------------------------------------------------------
1 | extern const uint8 zclApp_DateCode[];
2 | extern const char zclApp_DateCodeNT[];
--------------------------------------------------------------------------------
/images/back_2xAAA.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/images/back_2xAAA.png
--------------------------------------------------------------------------------
/images/back_DC_5-9V.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/images/back_DC_5-9V.png
--------------------------------------------------------------------------------
/images/dimensions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/images/dimensions.png
--------------------------------------------------------------------------------
/images/front_side.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/images/front_side.png
--------------------------------------------------------------------------------
/images/z2m_exposes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/images/z2m_exposes.png
--------------------------------------------------------------------------------
/images/front_side_rgb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/images/front_side_rgb.png
--------------------------------------------------------------------------------
/images/z2m_dashboard.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/images/z2m_dashboard.gif
--------------------------------------------------------------------------------
/hardware/BOM_Zintercom.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/hardware/BOM_Zintercom.csv
--------------------------------------------------------------------------------
/images/fix_error_rings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/images/fix_error_rings.png
--------------------------------------------------------------------------------
/hardware/Gerber_Zintercom.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/hardware/Gerber_Zintercom.zip
--------------------------------------------------------------------------------
/images/battery_no_handset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/images/battery_no_handset.png
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "zstack-lib"]
2 | path = zstack-lib
3 | url = https://github.com/diyruz/zstack-lib.git
4 |
--------------------------------------------------------------------------------
/hardware/Gerber_Zintercom_rgb.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/hardware/Gerber_Zintercom_rgb.zip
--------------------------------------------------------------------------------
/hardware/Schematic_Zintercom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/hardware/Schematic_Zintercom.png
--------------------------------------------------------------------------------
/hardware/Домофон zintercom.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/hardware/Домофон zintercom.docx
--------------------------------------------------------------------------------
/hardware/Schematic_Zintercom_rgb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xyzroe/Zintercom/HEAD/hardware/Schematic_Zintercom_rgb.png
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | ---
2 | # We'll use defaults from the LLVM style, but with 4 columns indentation.
3 | BasedOnStyle: LLVM
4 | IndentWidth: 4
5 | ColumnLimit: 180
--------------------------------------------------------------------------------
/.release-it.yml:
--------------------------------------------------------------------------------
1 | git:
2 | requireCleanWorkingDir: false
3 | github:
4 | release: true
5 | assets: ["firmwares/DIY_*.hex", "converters/DIY_*.js"]
6 | draft: false
7 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: xyzroe
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12 | polar: # Replace with a single Polar username
13 | buy_me_a_coffee: xyzroe
14 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
15 |
--------------------------------------------------------------------------------
/ver.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime
2 | from os.path import dirname, join
3 | cwd = dirname(__file__)
4 | now = datetime.now()
5 | dt_string = now.strftime("%d/%m/%Y %H:%M")
6 | print("date and time =", dt_string)
7 | with open(join(cwd, './Source/version.c'), 'w') as f:
8 | chars = ["'{0}'".format(char) for char in dt_string]
9 | f.write("""
10 | #ifndef ZCL_APP_VERSION_H
11 | #define ZCL_APP_VERSION_H
12 |
13 | #ifdef __cplusplus
14 | extern "C" {
15 | #endif
16 |
17 | """
18 | )
19 | f.write('#include "version.h"\n')
20 | code = """const uint8 zclApp_DateCode[] = {{ {0}, {1} }};\n""".format(len(chars), ', '.join(chars))
21 | f.write(code)
22 | code = """const char zclApp_DateCodeNT[] = \"{0}\";\n""".format(dt_string)
23 | f.write(code)
24 | f.write("""
25 | #ifdef __cplusplus
26 | }
27 | #endif
28 |
29 | #endif /* ZCL_APP_VERSION_H */
30 | """)
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # IAR C-STAT and C-RUN
2 | # Comment this out if you use C-Stat or C-Run to compile/analyze your project
3 | *.ewt
4 |
5 | # IAR Debugger files
6 | *.ewd
7 |
8 |
9 | # IAR Settings
10 | **/settings/*.crun
11 | **/settings/*.dbgdt
12 | **/settings/*.cspy
13 | **/settings/*.cspy.*
14 | **/settings/*.xcl
15 | **/settings/*.dni
16 | **/settings/*.wsdt
17 | **/settings/*.wspos
18 |
19 | # IAR Debug Exe
20 | **/CoordinatorEB/Exe/
21 |
22 | # IAR Debug List
23 | **/CoordinatorEB/List
24 |
25 | # IAR Debug Obj
26 | **/CoordinatorEB/Obj/*.pbd
27 | **/CoordinatorEB/Obj/*.pbd.*
28 | **/CoordinatorEB/Obj/*.pbi
29 | **/CoordinatorEB/Obj/*.pbi.*
30 | **/CoordinatorEB/Obj/*.r51
31 |
32 | # Log files
33 | **.log
34 |
35 | # IAR backup files
36 | Backup*
37 |
38 | # IAR .dep files
39 | *.dep
40 |
41 | # Compiled Binaries
42 | *.bin
43 | *.elf
44 | *.map
45 |
46 | # Trash files
47 | *.bak
48 |
49 | # CC2530DB
50 |
51 | CC2530DB/CHDTECH_DEV*
52 |
53 | CC2530DB/Zintercom*
54 |
55 | Source/version.c
56 | !.vscode/
57 | .vscode/settings.json
58 | firmwares/*
59 |
60 |
--------------------------------------------------------------------------------
/README-RGB.md:
--------------------------------------------------------------------------------
1 | # Zintercom
2 |
3 | ## Firmware options
4 | Each firmware version has 6 variants.
5 | For different zigbee modules and power supply.
6 |
7 | - EndDevice - for battery power
8 | - Router - for external power
9 |
10 |
11 | - PA1 - for E18-MS1PA1 module
12 | - PA2 - for E18-MS1PA2 module
13 | - no suffix - for E18-MS1 module
14 |
15 | ## Using battery as power supply
16 | The firmware for the battery has the following differences.
17 | - The device is mostly asleep.
18 | - Wakes up once every 30 minutes (parameter - time_report) and sends a report.
19 | - Zigbee commands are only executed when the device wakes up.
20 | - RGB lights up for 2 seconds after changing the mode with the button.
21 | - When the "no sound" mode is turned on, the constant consumption is 3 mA. In this mode AAA batteries will last 1-2 months.
22 |
23 | ## RGB Software
24 | Release 2.0.0 support new RGB hardware and legacy hardware with one Led.
25 |
26 | ## RGB Hardware
27 | Schematics and PCB - https://oshwlab.com/Utyf/zcom
28 |
29 | 
30 |
31 | 
32 |
33 |
34 | ### Files to reproduce
35 | * [Gerbers](https://github.com/diyruz/Zintercom/tree/master/hardware)
36 | * [Firmware](https://github.com/diyruz/Zintercom/releases)
37 |
--------------------------------------------------------------------------------
/CC2530DB/GenericApp.eww:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $WS_DIR$\GenericApp.ewp
5 |
6 |
7 |
8 | ALL
9 |
10 | GenericApp
11 | Zintercom_Router
12 |
13 |
14 | GenericApp
15 | Zintercom_Router_PA1
16 |
17 |
18 | GenericApp
19 | Zintercom_Router_PA2
20 |
21 |
22 | GenericApp
23 | Zintercom_EndDevice
24 |
25 |
26 | GenericApp
27 | Zintercom_EndDevice_PA1
28 |
29 |
30 | GenericApp
31 | Zintercom_EndDevice_PA2
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [{
3 | "name": "Mac",
4 | "forcedInclude": ["${workspaceRoot}/source/preinclude.h"],
5 | "defines": ["HAL_BOARD_TARGET", "HAL_I2C=TRUE", "HAL_I2C_MASTER"],
6 | "includePath": [
7 | "${workspaceRoot}",
8 | "${workspaceRoot}/BME280_driver",
9 | "${workspaceRoot}/Source",
10 | "${workspaceRoot}/zstack-lib",
11 | "${env:ZSTACK_PATH}/Components/mac/include/",
12 | "${env:ZSTACK_PATH}/Components/mt",
13 | "${env:ZSTACK_PATH}/Components/zmac",
14 | "${env:ZSTACK_PATH}/Components/zmac/f8w",
15 | "${env:ZSTACK_PATH}/Components/osal/include",
16 | "${env:ZSTACK_PATH}/Components/stack/af",
17 | "${env:ZSTACK_PATH}/Components/stack/bdb",
18 | "${env:ZSTACK_PATH}/Components/stack/sec",
19 | "${env:ZSTACK_PATH}/Components/stack/sys",
20 | "${env:ZSTACK_PATH}/Components/stack/zdo",
21 | "${env:ZSTACK_PATH}/Components/stack/GP",
22 | "${env:ZSTACK_PATH}/Components/stack/nwk",
23 | "${env:ZSTACK_PATH}/Components/stack/zcl",
24 | "${env:ZSTACK_PATH}/Components/hal/target/CC2530EB/",
25 | "${env:ZSTACK_PATH}/Components/hal/include/",
26 | "${env:ZSTACK_PATH}/Components/services/saddr/",
27 | "${env:ZSTACK_PATH}/Components/services/sdata/",
28 | "${env:ZSTACK_PATH}/Projects/zstack/ZMain/TI2530DB",
29 | "${env:ZSTACK_PATH}/Projects/zstack/HomeAutomation/Source"
30 | ],
31 | "intelliSenseMode": "clang-x64",
32 | "compilerPath": "/usr/bin/clang",
33 | "cStandard": "c99",
34 | "cppStandard": "c++17"
35 | }],
36 | "version": 4
37 | }
--------------------------------------------------------------------------------
/Source/preinclude.h:
--------------------------------------------------------------------------------
1 | #define TC_LINKKEY_JOIN
2 | #define NV_INIT
3 | #define NV_RESTORE
4 |
5 | #define TP2_LEGACY_ZC
6 | // patch sdk
7 | //#define ZDSECMGR_TC_ATTEMPT_DEFAULT_KEY TRUE
8 |
9 | #define NWK_AUTO_POLL
10 | #define MULTICAST_ENABLED FALSE
11 |
12 | #define ZCL_READ
13 | #define ZCL_WRITE
14 | #define ZCL_BASIC
15 | #define ZCL_IDENTIFY
16 | #define ZCL_REPORTING_DEVICE
17 | #define ZCL_ON_OFF
18 |
19 | #define DISABLE_GREENPOWER_BASIC_PROXY
20 | #define BDB_FINDING_BINDING_CAPABILITY_ENABLED 1
21 | #define BDB_REPORTING TRUE
22 |
23 |
24 | #define HAL_BUZZER FALSE
25 | #define HAL_KEY TRUE
26 | #define ISR_KEYINTERRUPT
27 |
28 |
29 |
30 | #define HAL_LED TRUE
31 | #define HAL_LCD FALSE
32 |
33 | #define BLINK_LEDS TRUE
34 |
35 |
36 | #if !defined(HAL_BOARD_TARGET) && !defined(HAL_BOARD_CHDTECH_DEV)
37 | #error "Board type must be defined"
38 | #endif
39 |
40 | #if defined( ZIC_BATTERY_MODE )
41 | #define POWER_SAVING
42 | #endif
43 |
44 | #if defined( HAL_BOARD_TARGET )
45 | // Income ring - P0_0
46 | #define KEY_INCOME_PORT HAL_KEY_PORT0
47 | #define HAL_KEY_P0_INPUT_PINS BV(0)
48 | #define HAL_KEY_P0_INPUT_PINS_EDGE HAL_KEY_RISING_EDGE
49 | // Button - P2_0
50 | #define KEY1_PORT HAL_KEY_PORT2
51 | #define HAL_KEY_P2_INPUT_PINS BV(0)
52 | #define HAL_KEY_P2_INPUT_PINS_EDGE HAL_KEY_FALLING_EDGE
53 | #define INT_HEAP_LEN 2200//2256
54 | #elif defined( HAL_BOARD_CHDTECH_DEV )
55 | // Income ring - P0_1
56 | #define KEY_INCOME_PORT HAL_KEY_PORT0
57 | #define HAL_KEY_P0_INPUT_PINS BV(1)
58 | #define HAL_KEY_P0_INPUT_PINS_EDGE HAL_KEY_FALLING_EDGE
59 | // Button - P2_0
60 | #define KEY1_PORT HAL_KEY_PORT2
61 | #define HAL_KEY_P2_INPUT_PINS BV(0)
62 | #define HAL_KEY_P2_INPUT_PINS_EDGE HAL_KEY_FALLING_EDGE
63 | #define DO_DEBUG_UART
64 | #define INT_HEAP_LEN 2060
65 | #endif
66 |
67 | #define BTN_HOLD_TIME 2000
68 | #define FACTORY_RESET_HOLD_TIME_LONG 10000
69 |
70 | #if defined( DO_DEBUG_UART )
71 | #define HAL_UART_ISR 0
72 | #define HAL_UART TRUE
73 | #define HAL_UART_DMA 1
74 | #endif
75 |
76 | #include "hal_board_cfg.h"
77 |
--------------------------------------------------------------------------------
/Source/OSAL_App.c:
--------------------------------------------------------------------------------
1 | #include "OSAL.h"
2 | #include "OSAL_Tasks.h"
3 | #include "ZComDef.h"
4 | #include "hal_drivers.h"
5 |
6 | #include "APS.h"
7 | #include "ZDApp.h"
8 | #include "nwk.h"
9 |
10 | #if defined ( MT_TASK )
11 | #include "MT.h"
12 | #include "MT_TASK.h"
13 | #endif
14 |
15 | #include "commissioning.h"
16 | #include "factory_reset.h"
17 | #include "Debug.h"
18 | #include "battery.h"
19 |
20 | #include "bdb_interface.h"
21 | #include "zcl_app.h"
22 |
23 | const pTaskEventHandlerFn tasksArr[] = {macEventLoop,
24 | nwk_event_loop,
25 | Hal_ProcessEvent,
26 | #if defined( MT_TASK )
27 | MT_ProcessEvent,
28 | #endif
29 | APS_event_loop,
30 | ZDApp_event_loop,
31 | zcl_event_loop,
32 | bdb_event_loop,
33 | zclApp_event_loop,
34 | zclCommissioning_event_loop,
35 | zclFactoryResetter_loop
36 | #ifdef ZIC_BATTERY_MODE
37 | ,
38 | zclBattery_event_loop
39 | #endif
40 | };
41 |
42 | const uint8 tasksCnt = sizeof(tasksArr) / sizeof(tasksArr[0]);
43 | uint16 *tasksEvents;
44 |
45 | void osalInitTasks(void) {
46 | uint8 taskID = 0;
47 | DebugInit();
48 |
49 | tasksEvents = (uint16 *)osal_mem_alloc(sizeof(uint16) * tasksCnt);
50 | osal_memset(tasksEvents, 0, (sizeof(uint16) * tasksCnt));
51 | macTaskInit(taskID++);
52 | nwk_init(taskID++);
53 | Hal_Init(taskID++);
54 | #if defined( MT_TASK )
55 | MT_TaskInit( taskID++ );
56 | #endif
57 | APS_Init(taskID++);
58 | ZDApp_Init(taskID++);
59 | zcl_Init(taskID++);
60 | bdb_Init(taskID++);
61 | zclApp_Init(taskID++);
62 | zclCommissioning_Init(taskID++);
63 | zclFactoryResetter_Init(taskID++);
64 | #if defined( ZIC_BATTERY_MODE )
65 | zclBattery_Init(taskID++);
66 | #endif
67 | }
68 |
69 | /*********************************************************************
70 | *********************************************************************/
71 |
--------------------------------------------------------------------------------
/Source/zcl_app.h:
--------------------------------------------------------------------------------
1 | #ifndef ZCL_APP_H
2 | #define ZCL_APP_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | /*********************************************************************
9 | * INCLUDES
10 | */
11 | #include "version.h"
12 | #include "zcl.h"
13 | #include "zcl_general.h"
14 |
15 | /*********************************************************************
16 | * CONSTANTS
17 | */
18 | #define APP_REPORT_DELAY ((uint32)60 * (uint32)1000) // 1 minute
19 | // Application Events
20 | #define APP_REPORT_EVT 0x0001
21 | #define APP_SAVE_ATTRS_EVT 0x0002
22 | #define APP_BTN_CLICK_EVT 0x0004
23 | #define APP_RING_RUN_EVT 0x0008
24 | #define APP_BTN_HOLD_EVT 0x0010
25 | #define APP_RING_STOP_EVT 0x0020
26 | #define APP_TALK_START_EVT 0x0040
27 | #define APP_WORK_LED_EVT 0x0080
28 | #define APP_BTN_DOUBLE_EVT 0x0100
29 |
30 | /*********************************************************************
31 | * MACROS
32 | */
33 | #define NW_APP_CONFIG 0x0402
34 |
35 | #define R ACCESS_CONTROL_READ
36 | // ACCESS_CONTROL_AUTH_WRITE
37 | #define RW (R | ACCESS_CONTROL_WRITE | ACCESS_CONTROL_AUTH_WRITE)
38 | #define RR (R | ACCESS_REPORTABLE)
39 |
40 | //READ REPORT WRITE
41 | #define RRW (R | ACCESS_REPORTABLE | ACCESS_CONTROL_WRITE | ACCESS_CONTROL_AUTH_WRITE)
42 |
43 | #define BASIC ZCL_CLUSTER_ID_GEN_BASIC
44 | #define GEN_ON_OFF ZCL_CLUSTER_ID_GEN_ON_OFF
45 | #define POWER_CFG ZCL_CLUSTER_ID_GEN_POWER_CFG
46 |
47 |
48 |
49 | //Intercom
50 | #define ZCL_INTERCOM 0x0101
51 |
52 | #define ATTRID_STATE 0x0050
53 | #define ATTRID_MODEOPEN 0x0051
54 | #define ATTRID_MODESOUND 0x0052
55 | #define ATTRID_TIMERING 0x0053
56 | #define ATTRID_TIMETALK 0x0054
57 | #define ATTRID_TIMEOPEN 0x0055
58 | #define ATTRID_TIMEBELL 0x0057
59 | #define ATTRID_TIMEREPORT 0x0056
60 |
61 | #define TIMER_RESTART TRUE
62 | #define TIMER_START FALSE
63 |
64 | #define ZIC_WORKMODE_NEVER 0
65 | #define ZIC_WORKMODE_ONCE 1
66 | #define ZIC_WORKMODE_ALWAYS 2
67 | #define ZIC_WORKMODE_DROP 3
68 |
69 |
70 | #define ZIC_WORKSTATE_IDLE 0
71 | #define ZIC_WORKSTATE_RING 1
72 | #define ZIC_WORKSTATE_TALK 2
73 | #define ZIC_WORKSTATE_OPEN 3
74 | #define ZIC_WORKSTATE_DROP 4
75 |
76 | #define ZCL_UINT8 ZCL_DATATYPE_UINT8
77 | #define ZCL_UINT16 ZCL_DATATYPE_UINT16
78 | #define ZCL_INT16 ZCL_DATATYPE_INT16
79 | #define ZCL_INT8 ZCL_DATATYPE_INT8
80 | #define ZCL_INT32 ZCL_DATATYPE_INT32
81 | #define ZCL_UINT32 ZCL_DATATYPE_UINT32
82 | #define ZCL_SINGLE ZCL_DATATYPE_SINGLE_PREC
83 | /*********************************************************************
84 | * TYPEDEFS
85 | */
86 |
87 | typedef enum {
88 | Never,
89 | Once,
90 | Always,
91 | Drop
92 | } WorkMode_t;
93 |
94 | typedef enum {
95 | Idle,
96 | Ring,
97 | Talk,
98 | Open,
99 | Droped
100 | } WorkState_t;
101 |
102 | typedef struct {
103 | WorkMode_t ModeOpen;
104 | uint8 ModeSound;
105 | uint8 TimeRing;
106 | uint8 TimeTalk;
107 | uint8 TimeOpen;
108 | uint8 TimeBell;
109 | uint8 TimeReport;
110 | } application_config_t;
111 |
112 | typedef struct {
113 | WorkState_t State;
114 | uint32 pressTime;
115 | byte clicks;
116 | } device_state_t;
117 |
118 |
119 | /*
120 | typedef enum {
121 | UNKNOWN, SENSEAIR, MHZ19
122 | } SensorType_t;
123 | */
124 | /*********************************************************************
125 | * VARIABLES
126 | */
127 |
128 | extern SimpleDescriptionFormat_t zclApp_FirstEP;
129 | extern CONST zclAttrRec_t zclApp_AttrsFirstEP[];
130 | extern CONST uint8 zclApp_AttrsCount;
131 |
132 |
133 | extern const uint8 zclApp_ManufacturerName[];
134 | extern const uint8 zclApp_ModelId[];
135 | extern const uint8 zclApp_PowerSource;
136 |
137 | extern uint8 zclApp_BatteryVoltage;
138 | extern uint8 zclApp_BatteryPercentageRemainig;
139 | extern uint16 zclApp_BatteryVoltageRawAdc;
140 |
141 | extern application_config_t zclApp_Config;
142 | extern device_state_t zclApp_State;
143 | // APP_TODO: Declare application specific attributes here
144 |
145 | /*********************************************************************
146 | * FUNCTIONS
147 | */
148 |
149 | /*
150 | * Initialization for the task
151 | */
152 | extern void zclApp_Init(byte task_id);
153 |
154 | /*
155 | * Event Process for the task
156 | */
157 | extern UINT16 zclApp_event_loop(byte task_id, UINT16 events);
158 |
159 | extern void zclApp_ResetAttributesToDefaultValues(void);
160 |
161 | /*********************************************************************
162 | *********************************************************************/
163 |
164 | #ifdef __cplusplus
165 | }
166 | #endif
167 |
168 | #endif /* ZCL_APP_H */
169 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Zintercom
2 | [](https://github.com/xyzroe/Zintercom/releases)
3 | [](https://github.com/xyzroe/Zintercom/latest)
4 | [](LICENSE.txt)
5 |
6 | ## How to compile
7 | Follow this article https://zigdevwiki.github.io/Begin/IAR_install/
8 |
9 | ##### Zigbee Intercom Automator
10 | This device is designed to control the matrix intercom using Zigbee.
11 |
12 | Using zigbee2mqtt you can:
13 | 1. Receive a notification when the intercom rings. (also support **direct bind**)
14 | 2. Mute the sound on the intercom handset.
15 | 3. Automatically or manually open the door or hang up when the intercom rings.
16 |
17 | There are 4 work modes:
18 | 1. `Never` - ordinary work mode, use a handset to control
19 | 2. `Once` - one-time open door when intercom rings
20 | 3. `Always` - open door when intercom rings
21 | 4. `Drop` - hangs up all intercom rings, right after the start
22 |
23 | You can change the operating mode using z2m or by short press the button. (< 1000ms)
24 | After pressing the button, the LED will flash at 4 Hz.
25 | The number of flashes indicates the current operating mode.
26 |
27 | You can control sound mode using z2m or by long-press the button. (1000ms < X < 5000ms)
28 | After pressing the button, the LED will flash at 1.5 Hz.
29 | One flash - OFF, two flashes - ON.
30 |
31 | ## Hardware v2.0
32 | New version of the board with RGB led support.
33 | All known bugs and shortcomings have been fixed.
34 | Thanks [@Utyff](https://github.com/Utyff)
35 | ### [More info](https://github.com/diyruz/Zintercom/blob/master/README-RGB.md)
36 |
37 |
38 |
39 |
40 |
41 | ## Important info
42 | #### 1
43 | In Gerber PCB v1.0 committed on Apr 14, there are some errors in the silkscreen layers:
44 | 1. 'Line-' and 'Phone-' are reversed.
45 | 2. '+' and '-' are also reversed.
46 |
47 | Just plug by swapping.
48 |
49 | #### 2
50 | The problem of cross-calls to other apartments:
51 | it was revealed that the intercom circuit is closed through the reverse diode of the u2 transistor (thanks to @Alex_AW)
52 | to prevent it, you need to add a diode according to the diagram:
53 | 
54 |
55 | #### 3
56 | If you want to use the battery version without a handset, do not turn off the sound in z2m, but use an external resistor to emulate the intercom handset, according to the diagram:
57 | 
58 |
59 |
60 | ### How to join
61 | Reset to FN by reboot the device 5 times with intervals of less than 10 seconds.
62 | Reset to FN by pressing and holding BTN for 5 seconds.
63 |
64 | LED will flash during reset.
65 |
66 | 
67 |
68 |
69 | ### How to add device into zigbe2mqtt
70 | Use [external converters](https://www.zigbee2mqtt.io/information/configuration.html#external-converters-configuration) feature
71 |
72 | Converter file located [here](https://github.com/diyruz/Zintercom/blob/master/converters/DIYRuZ_Zintercom.js)
73 |
74 | 
75 |
76 | ### Schematic
77 |
78 | 
79 |
80 |
81 | ### PCB size
82 |
83 | `57.5mm x 27.3mm`
84 | 
85 |
86 |
87 | ### DC Power
88 |
89 | 5-10 V
90 |
91 | Support `router` and `end device` modes.
92 | Install `E18-MS1PA1`, `E18-MS1PA2` or `E18-MS1-PCB`.
93 |
94 | 
95 |
96 | 
97 |
98 |
99 | ### Battery Power
100 |
101 | 2 * AAA batteries
102 |
103 | Support only `end device` mode.
104 | Install `E18-MS1-PCB` only!
105 |
106 | Do not turn off `sound` because it turns U2 forever, which will drain the battery much faster.
107 |
108 | Since the device is in sleep mode, it cannot receive commands.
109 | But you can set the button mode or at the time of the call.
110 |
111 | If any commands are in the coordinator's queue, they will be executed after a button is pressed or a call is received.
112 |
113 | 
114 |
115 | ##### The mode set by the Zigbee command `overwrites` the mode set by the button.
116 |
117 | ### Binding
118 | The device supports the direct binding of an incoming call to the onOff cluster.
119 |
120 | For example, you can turn on the light while a call comes to the intercom, for notification in mute mode.
121 |
122 |
123 | ### Files to reproduce
124 | * [Gerbers and BOM](https://github.com/diyruz/Zintercom/tree/master/hardware) by [xyzroe](https://t.me/xyzroe)
125 | * [Firmware](https://github.com/diyruz/Zintercom/releases) by [xyzroe](https://t.me/xyzroe)
126 | * [Case stl](https://www.thingiverse.com/thing:4866356) by [dreamertwo](https://t.me/dreamertwo)
127 |
128 | 
129 |
130 | ### Like ♥️?
131 | [](https://www.buymeacoffee.com/xyzroe)
132 |
133 |
134 | ### Inspired by
135 | The original scheme of the intercom opener by [Alexander Vaidurov](https://easyeda.com/Alex_AW/domofon-with-battery)
136 | Various hardware solutions by [Jager](https://modkam.ru)
137 | Firmware for different Zigbee devices by [Anonymous](https://github.com/nurikk/)
138 |
--------------------------------------------------------------------------------
/Source/zcl_app_data.c:
--------------------------------------------------------------------------------
1 | #include "AF.h"
2 | #include "OSAL.h"
3 | #include "ZComDef.h"
4 | #include "ZDConfig.h"
5 |
6 | #include "zcl.h"
7 | #include "zcl_general.h"
8 | #include "zcl_ha.h"
9 | #include "zcl_ms.h"
10 |
11 | #include "zcl_app.h"
12 |
13 | #include "battery.h"
14 | #include "version.h"
15 |
16 | #include "bdb_touchlink.h"
17 | #include "bdb_touchlink_target.h"
18 | #include "stub_aps.h"
19 |
20 | /*********************************************************************
21 | * CONSTANTS
22 | */
23 |
24 | #define APP_DEVICE_VERSION 2
25 | #define APP_FLAGS 0
26 |
27 | #define APP_HWVERSION 1
28 | #define APP_ZCLVERSION 1
29 |
30 | /*********************************************************************
31 | * TYPEDEFS
32 | */
33 |
34 | /*********************************************************************
35 | * MACROS
36 | */
37 |
38 | /*********************************************************************
39 | * GLOBAL VARIABLES
40 | */
41 |
42 | // Global attributes
43 | const uint16 zclApp_clusterRevision_all = 0x0002;
44 |
45 | // Basic Cluster
46 | const uint8 zclApp_HWRevision = APP_HWVERSION;
47 | const uint8 zclApp_ZCLVersion = APP_ZCLVERSION;
48 |
49 | const uint8 zclApp_ApplicationVersion = 3;
50 | const uint8 zclApp_StackVersion = 4;
51 |
52 | //{lenght, 'd', 'a', 't', 'a'}
53 | const uint8 zclApp_ManufacturerName[] = {6, 'x', 'y', 'z', 'r', 'o', 'e'};
54 | const uint8 zclApp_ModelId[] = {13, 'D', 'I', 'Y', '_', 'Z', 'i', 'n', 't', 'e', 'r', 'c', 'o', 'm'};
55 |
56 | #if defined( ZIC_BATTERY_MODE )
57 | const uint8 zclApp_PowerSource = POWER_SOURCE_BATTERY;
58 | #define DEFAULT_TimeReport 30 //minutes
59 | #else
60 | const uint8 zclApp_PowerSource = POWER_SOURCE_DC;
61 | #define DEFAULT_TimeReport 1 //minutes
62 | #endif
63 |
64 | #define DEFAULT_ModeOpen Never
65 | #define DEFAULT_ModeSound TRUE
66 |
67 | #define DEFAULT_TimeRing 7 //seconds to ring, before answer
68 | #define DEFAULT_TimeTalk 3 //seconds to talk, before open
69 | #define DEFAULT_TimeOpen 2 //seconds to hold open
70 | #define DEFAULT_TimeBell 3 //seconds after last bell to finish ring
71 |
72 | application_config_t zclApp_Config = {
73 | .ModeOpen = DEFAULT_ModeOpen,
74 | .ModeSound = DEFAULT_ModeSound,
75 | .TimeRing = DEFAULT_TimeRing,
76 | .TimeTalk = DEFAULT_TimeTalk,
77 | .TimeOpen = DEFAULT_TimeOpen,
78 | .TimeBell = DEFAULT_TimeBell,
79 | .TimeReport = DEFAULT_TimeReport,
80 | };
81 |
82 | device_state_t zclApp_State = {
83 | .State = Idle,
84 | .pressTime = 0,
85 | };
86 |
87 |
88 | /*********************************************************************
89 | * ATTRIBUTE DEFINITIONS - Uses REAL cluster IDs
90 | */
91 |
92 | CONST zclAttrRec_t zclApp_AttrsFirstEP[] = {
93 | {BASIC, {ATTRID_BASIC_ZCL_VERSION, ZCL_UINT8, R, (void *)&zclApp_ZCLVersion}},
94 | {BASIC, {ATTRID_BASIC_APPL_VERSION, ZCL_UINT8, R, (void *)&zclApp_ApplicationVersion}},
95 | {BASIC, {ATTRID_BASIC_STACK_VERSION, ZCL_UINT8, R, (void *)&zclApp_StackVersion}},
96 | {BASIC, {ATTRID_BASIC_HW_VERSION, ZCL_UINT8, R, (void *)&zclApp_HWRevision}},
97 | {BASIC, {ATTRID_BASIC_MANUFACTURER_NAME, ZCL_DATATYPE_CHAR_STR, R, (void *)zclApp_ManufacturerName}},
98 | {BASIC, {ATTRID_BASIC_MODEL_ID, ZCL_DATATYPE_CHAR_STR, R, (void *)zclApp_ModelId}},
99 | {BASIC, {ATTRID_BASIC_DATE_CODE, ZCL_DATATYPE_CHAR_STR, R, (void *)zclApp_DateCode}},
100 | {BASIC, {ATTRID_BASIC_POWER_SOURCE, ZCL_DATATYPE_ENUM8, R, (void *)&zclApp_PowerSource}},
101 |
102 |
103 | //#if defined( ZIC_BATTERY_MODE )
104 | {POWER_CFG, {ATTRID_POWER_CFG_BATTERY_VOLTAGE, ZCL_UINT8, RR, (void *)&zclBattery_Voltage}},
105 | /**
106 | * FYI: calculating battery percentage can be tricky, since this device can be powered from 2xAA or 1xCR2032 batteries
107 | * */
108 | {POWER_CFG, {ATTRID_POWER_CFG_BATTERY_PERCENTAGE_REMAINING, ZCL_UINT8, RR, (void *)&zclBattery_PercentageRemainig}},
109 | //#endif
110 |
111 | {BASIC, {ATTRID_BASIC_SW_BUILD_ID, ZCL_DATATYPE_CHAR_STR, R, (void *)zclApp_DateCode}},
112 | {BASIC, {ATTRID_CLUSTER_REVISION, ZCL_UINT16, R, (void *)&zclApp_clusterRevision_all}},
113 |
114 |
115 |
116 |
117 | {ZCL_INTERCOM, {ATTRID_STATE, ZCL_DATATYPE_ENUM8, RRW, (void *)&zclApp_State.State}},
118 |
119 | {ZCL_INTERCOM, {ATTRID_MODEOPEN, ZCL_DATATYPE_ENUM8, RRW, (void *)&zclApp_Config.ModeOpen}},
120 | {ZCL_INTERCOM, {ATTRID_MODESOUND, ZCL_DATATYPE_BOOLEAN, RRW, (void *)&zclApp_Config.ModeSound}},
121 |
122 | {ZCL_INTERCOM, {ATTRID_TIMERING, ZCL_UINT8, RW, (void *)&zclApp_Config.TimeRing}},
123 | {ZCL_INTERCOM, {ATTRID_TIMETALK, ZCL_UINT8, RW, (void *)&zclApp_Config.TimeTalk}},
124 | {ZCL_INTERCOM, {ATTRID_TIMEOPEN, ZCL_UINT8, RW, (void *)&zclApp_Config.TimeOpen}},
125 | {ZCL_INTERCOM, {ATTRID_TIMEBELL, ZCL_UINT8, RW, (void *)&zclApp_Config.TimeBell}},
126 | {ZCL_INTERCOM, {ATTRID_TIMEREPORT, ZCL_UINT8, RW, (void *)&zclApp_Config.TimeReport}},
127 | };
128 |
129 |
130 | uint8 CONST zclApp_AttrsCount = (sizeof(zclApp_AttrsFirstEP) / sizeof(zclApp_AttrsFirstEP[0]));
131 |
132 | const cId_t zclApp_InClusterList[] = {ZCL_CLUSTER_ID_GEN_BASIC};
133 |
134 | #define APP_MAX_INCLUSTERS (sizeof(zclApp_InClusterList) / sizeof(zclApp_InClusterList[0]))
135 |
136 | const cId_t zclApp_OutClusterList[] = {ZCL_INTERCOM, GEN_ON_OFF};
137 |
138 |
139 | #define APP_MAX_OUT_CLUSTERS (sizeof(zclApp_OutClusterList) / sizeof(zclApp_OutClusterList[0]))
140 |
141 |
142 | SimpleDescriptionFormat_t zclApp_FirstEP = {
143 | 1, // int Endpoint;
144 | ZCL_HA_PROFILE_ID, // uint16 AppProfId[2];
145 | ZCL_HA_DEVICEID_SIMPLE_SENSOR, // uint16 AppDeviceId[2];
146 | APP_DEVICE_VERSION, // int AppDevVer:4;
147 | APP_FLAGS, // int AppFlags:4;
148 | APP_MAX_INCLUSTERS, // byte AppNumInClusters;
149 | (cId_t *)zclApp_InClusterList, // byte *pAppInClusterList;
150 | APP_MAX_OUT_CLUSTERS, // byte AppNumInClusters;
151 | (cId_t *)zclApp_OutClusterList // byte *pAppInClusterList;
152 | };
153 |
154 |
155 | void zclApp_ResetAttributesToDefaultValues(void) {
156 | zclApp_Config.ModeOpen = DEFAULT_ModeOpen;
157 | zclApp_Config.ModeSound = DEFAULT_ModeSound;
158 | zclApp_Config.TimeRing = DEFAULT_TimeRing;
159 | zclApp_Config.TimeTalk = DEFAULT_TimeTalk;
160 | zclApp_Config.TimeOpen = DEFAULT_TimeOpen;
161 | zclApp_Config.TimeBell = DEFAULT_TimeBell;
162 | zclApp_Config.TimeReport = DEFAULT_TimeReport;
163 | }
--------------------------------------------------------------------------------
/converters/DIYRuZ_Zintercom.js:
--------------------------------------------------------------------------------
1 | const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters');
2 |
3 | const exposes = zigbeeHerdsmanConverters['exposes'] || require("zigbee-herdsman-converters/lib/exposes");
4 |
5 | const ep = exposes.presets;
6 | const ea = exposes.access;
7 | const fromZigbeeConverters = zigbeeHerdsmanConverters.fromZigbeeConverters || zigbeeHerdsmanConverters.fromZigbee;
8 | const toZigbeeConverters = zigbeeHerdsmanConverters.toZigbeeConverters || zigbeeHerdsmanConverters.toZigbee;
9 |
10 |
11 | const bind = async (endpoint, target, clusters) => {
12 | for (const cluster of clusters) {
13 | await endpoint.bind(cluster, target);
14 | }
15 | };
16 |
17 | const configureReporting = {
18 | currentPositionLiftPercentage: async (endpoint, overrides) => {
19 | const payload = configureReportingPayload('currentPositionLiftPercentage', 1, repInterval.MAX, 1, overrides);
20 | await endpoint.configureReporting('closuresWindowCovering', payload);
21 | },
22 | batteryPercentageRemaining: async (endpoint, overrides) => {
23 | const payload = configureReportingPayload(
24 | 'batteryPercentageRemaining', repInterval.HOUR, repInterval.MAX, 0, overrides,
25 | );
26 | await endpoint.configureReporting('genPowerCfg', payload);
27 | },
28 | batteryVoltage: async (endpoint, overrides) => {
29 | const payload = configureReportingPayload('batteryVoltage', repInterval.HOUR, repInterval.MAX, 0, overrides);
30 | await endpoint.configureReporting('genPowerCfg', payload);
31 | },
32 | }
33 |
34 | const configureReportingPayload = (attribute, min, max, change, overrides) => {
35 | const payload = {
36 | attribute: attribute,
37 | minimumReportInterval: min,
38 | maximumReportInterval: max,
39 | reportableChange: change,
40 | };
41 |
42 |
43 | if (overrides) {
44 | if (overrides.hasOwnProperty('min')) payload.minimumReportInterval = overrides.min;
45 | if (overrides.hasOwnProperty('max')) payload.maximumReportInterval = overrides.max;
46 | if (overrides.hasOwnProperty('change')) payload.reportableChange = overrides.change;
47 | }
48 |
49 | return [payload];
50 | };
51 |
52 | const repInterval = {
53 | MAX: 62000,
54 | HOUR: 3600,
55 | MINUTES_30: 1800,
56 | MINUTES_15: 900,
57 | MINUTES_10: 600,
58 | MINUTES_5: 300,
59 | MINUTE: 60,
60 | };
61 |
62 | const fz = {
63 | diy_zintercom_config: {
64 | cluster: 'closuresDoorLock',
65 | type: ['attributeReport', 'readResponse'],
66 | convert: (model, msg, publish, options, meta) => {
67 | const result = {};
68 | if (msg.data.hasOwnProperty(0x0050)) {
69 | result.state = ['Idle', 'Ring', 'Talk', 'Open', 'Drop'][msg.data[0x0050]];
70 | }
71 | if (msg.data.hasOwnProperty(0x0051)) {
72 | result.mode = ['Never', 'Once', 'Always', 'Drop'][msg.data[0x0051]];
73 | }
74 | if (msg.data.hasOwnProperty(0x0052)) {
75 | result.sound = ['OFF', 'ON'][msg.data[0x0052]];
76 | }
77 | if (msg.data.hasOwnProperty(0x0053)) {
78 | result.time_ring = msg.data[0x0053];
79 | }
80 | if (msg.data.hasOwnProperty(0x0054)) {
81 | result.time_talk = msg.data[0x0054];
82 | }
83 | if (msg.data.hasOwnProperty(0x0055)) {
84 | result.time_open = msg.data[0x0055];
85 | }
86 | if (msg.data.hasOwnProperty(0x0057)) {
87 | result.time_bell = msg.data[0x0057];
88 | }
89 | if (msg.data.hasOwnProperty(0x0056)) {
90 | result.time_report = msg.data[0x0056];
91 | }
92 | return result;
93 | },
94 | },
95 | }
96 |
97 | const tz = {
98 | diy_zintercom_config: {
99 | key: ['state', 'mode', 'sound', 'time_ring', 'time_talk', 'time_open', 'time_bell', 'time_report'],
100 | convertSet: async (entity, key, rawValue, meta) => {
101 | const lookup = {
102 | 'OFF': 0x00,
103 | 'ON': 0x01,
104 | };
105 | const modeOpenLookup = {
106 | 'Never': '0',
107 | 'Once': '1',
108 | 'Always': '2',
109 | 'Drop': '3',
110 | };
111 |
112 |
113 | let value = lookup.hasOwnProperty(rawValue) ? lookup[rawValue] : parseInt(rawValue, 10);
114 |
115 | if (key == 'mode') {
116 | value = modeOpenLookup.hasOwnProperty(rawValue) ? modeOpenLookup[rawValue] : parseInt(rawValue, 10);
117 | }
118 |
119 | const payloads = {
120 | mode: {0x0051: {value, type: 0x30}},
121 | sound: {0x0052: {value, type: 0x10}},
122 | time_ring: {0x0053: {value, type: 0x20}},
123 | time_talk: {0x0054: {value, type: 0x20}},
124 | time_open: {0x0055: {value, type: 0x20}},
125 | time_bell: {0x0057: {value, type: 0x20}},
126 | time_report: {0x0056: {value, type: 0x20}},
127 | };
128 |
129 | await entity.write('closuresDoorLock', payloads[key]);
130 | return {
131 | state: {[key]: rawValue},
132 | };
133 | },
134 | convertGet: async (entity, key, meta) => {
135 | const payloads = {
136 | state: ['closuresDoorLock', 0x0050],
137 | mode: ['closuresDoorLock', 0x0051],
138 | sound: ['closuresDoorLock', 0x0052],
139 | time_ring: ['closuresDoorLock', 0x0053],
140 | time_talk: ['closuresDoorLock', 0x0054],
141 | time_open: ['closuresDoorLock', 0x0055],
142 | time_bell: ['closuresDoorLock', 0x0057],
143 | time_report: ['closuresDoorLock', 0x0056],
144 | };
145 | await entity.read(payloads[key][0], [payloads[key][1]]);
146 | },
147 | },
148 | }
149 |
150 | const device = {
151 | zigbeeModel: ['DIY_Zintercom'],
152 | model: 'DIYRuZ_Zintercom',
153 | vendor: 'DIYRuZ',
154 | description: '[Matrix intercom auto opener](https://diyruz.github.io/posts/zintercom/)',
155 | icon: 'https://raw.githubusercontent.com/diyruz/Zintercom/master/images/z2m.png',
156 | fromZigbee: [
157 | fromZigbeeConverters.battery,
158 | fz.diy_zintercom_config,
159 | ],
160 | toZigbee: [
161 | toZigbeeConverters.factory_reset,
162 | tz.diy_zintercom_config,
163 | ],
164 | meta: {
165 | configureKey: 1,
166 | },
167 | configure: async (device, coordinatorEndpoint) => {
168 | const firstEndpoint = device.getEndpoint(1);
169 |
170 | await bind(firstEndpoint, coordinatorEndpoint, ['closuresDoorLock', 'genPowerCfg']);
171 |
172 | const overides = {min: 0, max: 3600, change: 0};
173 | await configureReporting.batteryVoltage(firstEndpoint, overides);
174 | await configureReporting.batteryPercentageRemaining(firstEndpoint, overides);
175 |
176 | const payload = [{
177 | attribute: {
178 | ID: 0x0050,
179 | type: 0x30,
180 | },
181 | minimumReportInterval: 0,
182 | maximumReportInterval: 3600,
183 | reportableChange: 0,
184 | },
185 | ];
186 | await firstEndpoint.configureReporting('closuresDoorLock', payload);
187 |
188 | },
189 | exposes: [
190 | exposes.enum('state', ea.STATE_GET, ['Idle', 'Ring', 'Talk', 'Open', 'Drop'])
191 | .withDescription('Current state'),
192 | exposes.enum('mode', ea.ALL, ['Never', 'Once', 'Always', 'Drop'])
193 | .withDescription('Select open mode'),
194 | exposes.binary('sound', ea.ALL, 'ON', 'OFF').withProperty('sound')
195 | .withDescription('Enable or disable sound'),
196 | exposes.numeric('time_ring', ea.ALL).withUnit('sec')
197 | .withDescription('Time to ring before answer'),
198 | exposes.numeric('time_talk', ea.ALL).withUnit('sec')
199 | .withDescription('Time to hold before open'),
200 | exposes.numeric('time_open', ea.ALL).withUnit('sec')
201 | .withDescription('Time to open before end'),
202 | exposes.numeric('time_bell', ea.ALL).withUnit('sec')
203 | .withDescription('Time after last bell to finish ring'),
204 | exposes.numeric('time_report', ea.ALL).withUnit('min')
205 | .withDescription('Reporting interval'),
206 | ep.battery(),
207 | ],
208 | };
209 |
210 | module.exports = device;
211 |
--------------------------------------------------------------------------------
/Source/zcl_app.c:
--------------------------------------------------------------------------------
1 |
2 | #include "AF.h"
3 | #include "OSAL.h"
4 | #include "OSAL_Clock.h"
5 | #include "OSAL_PwrMgr.h"
6 | #include "ZComDef.h"
7 | #include "ZDApp.h"
8 | #include "ZDObject.h"
9 | #include "math.h"
10 |
11 | #include "nwk_util.h"
12 | #include "zcl.h"
13 | #include "zcl_app.h"
14 | #include "zcl_diagnostic.h"
15 | #include "zcl_general.h"
16 | #include "zcl_ms.h"
17 |
18 | #include "bdb.h"
19 | #include "bdb_interface.h"
20 | #include "bdb_touchlink.h"
21 | #include "bdb_touchlink_target.h"
22 |
23 | #include "gp_interface.h"
24 |
25 | #include "Debug.h"
26 |
27 | #include "OnBoard.h"
28 |
29 | #include "commissioning.h"
30 | #include "factory_reset.h"
31 | /* HAL */
32 |
33 | #include "hal_drivers.h"
34 |
35 | #include "hal_key.h"
36 | #include "hal_led.h"
37 | #include "hal_adc.h"
38 |
39 | #include "utils.h"
40 |
41 | #include "battery.h"
42 |
43 | #include "version.h"
44 |
45 | /*********************************************************************
46 | * MACROS
47 | */
48 |
49 | /*********************************************************************
50 | * CONSTANTS
51 | */
52 |
53 | /*********************************************************************
54 | * TYPEDEFS
55 | */
56 |
57 | /*********************************************************************
58 | * GLOBAL VARIABLES
59 | */
60 | byte zclApp_TaskID;
61 | #if defined( ZIC_BATTERY_MODE )
62 | static byte isRingOn = false;
63 | static byte isLedOn = false;
64 | #endif
65 |
66 | // for Old LED
67 | static byte showMode = false;
68 | static byte showSound = false;
69 |
70 | /*********************************************************************
71 | * GLOBAL FUNCTIONS
72 | */
73 | //void user_delay_ms(uint32_t period);
74 | //void user_delay_ms(uint32_t period) { MicroWait(period * 1000); }
75 | /*********************************************************************
76 | * LOCAL VARIABLES
77 | */
78 |
79 |
80 | /*********************************************************************
81 | * LOCAL FUNCTIONS
82 | */
83 |
84 | static void zclApp_BasicResetCB(void);
85 | static void zclApp_RestoreAttributesFromNV(void);
86 | static void zclApp_SaveAttributesToNV(void);
87 | static void zclApp_HandleKeys(byte portAndAction, byte keyCode);
88 | static void zclApp_ControlPinsInit(void);
89 | static ZStatus_t zclApp_ReadWriteAuthCB(afAddrType_t *srcAddr, zclAttrRec_t *pAttr, uint8 oper);
90 |
91 | static void zclApp_OneReport(void);
92 | static void zclApp_ConfigInit(bool restart);
93 |
94 | static void zclApp_BtnClicks(byte count);
95 | static void zclApp_RingRun(void);
96 | static void zclApp_TalkStart(void);
97 | static void zclApp_RingEnd(void);
98 | static void zclApp_WorkWithLEDs(void);
99 |
100 | /*********************************************************************
101 | * ZCL General Profile Callback table
102 | */
103 | static zclGeneral_AppCallbacks_t zclApp_CmdCallbacks = {
104 | zclApp_BasicResetCB, // Basic Cluster Reset command
105 | NULL, // Identify Trigger Effect command
106 | NULL, // On/Off cluster commands
107 | NULL, // On/Off cluster enhanced command Off with Effect
108 | NULL, // On/Off cluster enhanced command On with Recall Global Scene
109 | NULL, // On/Off cluster enhanced command On with Timed Off
110 | NULL, // RSSI Location command
111 | NULL // RSSI Location Response command
112 | };
113 |
114 | void zclApp_Init(byte task_id) {
115 | zclApp_RestoreAttributesFromNV();
116 |
117 | zclApp_TaskID = task_id;
118 |
119 | bdb_RegisterSimpleDescriptor(&zclApp_FirstEP);
120 |
121 | zclGeneral_RegisterCmdCallbacks(zclApp_FirstEP.EndPoint, &zclApp_CmdCallbacks);
122 |
123 | zcl_registerAttrList(zclApp_FirstEP.EndPoint, zclApp_AttrsCount, zclApp_AttrsFirstEP);
124 |
125 | zcl_registerReadWriteCB(zclApp_FirstEP.EndPoint, NULL, zclApp_ReadWriteAuthCB);
126 | zcl_registerForMsg(zclApp_TaskID);
127 | RegisterForKeys(zclApp_TaskID);
128 |
129 | LREP("Build %s \r\n", zclApp_DateCodeNT);
130 |
131 | zclApp_ConfigInit(TIMER_START);
132 |
133 | zclApp_ControlPinsInit();
134 |
135 | IO_IMODE_PORT_PIN(0,0,IO_TRI);
136 |
137 | #if defined( ZIC_BATTERY_MODE )
138 | ZMacSetTransmitPower(TX_PWR_PLUS_4); // set 4dBm
139 | #endif
140 | }
141 |
142 | static void zclApp_ControlPinsInit (void) {
143 | CATCH_SSR &= ~CATCH_BV; // Set PIN as general I/O port functions
144 | CATCH_DDR |= CATCH_BV; // Set the port transmission mode for PIN to output
145 |
146 | ANSWER_SSR &= ~ANSWER_BV;
147 | ANSWER_DDR |= ANSWER_BV;
148 |
149 | HANDSET_SSR &= ~HANDSET_BV;
150 | HANDSET_DDR |= HANDSET_BV;
151 |
152 | P0SEL &= ~0x01; // Set P0_0 as general I/O port function
153 | P0DIR &= ~0x01; // Set the port transmission mode of P0_0 to input
154 | // ? P0INP &= ~0x01; //Set the port input mode of P0_0 to: pull up/down
155 | }
156 |
157 |
158 | static void zclApp_HandleKeys(byte portAndAction, byte keyCode) {
159 |
160 | if (portAndAction & KEY_INCOME_PORT) { //P0 Ring //S1 P0_1 TODO add check Income pin
161 | //exit old stop timer
162 | osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
163 | osal_start_timerEx(zclApp_TaskID, APP_RING_STOP_EVT, zclApp_Config.TimeBell * 1000);
164 | if (portAndAction & HAL_KEY_PRESS) {
165 | //start ring
166 | if (zclApp_State.State == Idle) {
167 | #if defined( ZIC_BATTERY_MODE )
168 | osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_HOLD);
169 | isRingOn = true;
170 | #endif
171 | LREPMaster("Ring start\r\n");
172 | osal_start_timerEx(zclApp_TaskID, APP_RING_RUN_EVT, 50);
173 | afAddrType_t inderect_DstAddr = {.addrMode = (afAddrMode_t)AddrNotPresent, .endPoint = 0, .addr.shortAddr = 0};
174 | zclGeneral_SendOnOff_CmdOn(zclApp_FirstEP.EndPoint, &inderect_DstAddr, FALSE, bdb_getZCLFrameCounter());
175 | }
176 | }
177 | }
178 |
179 | if (portAndAction & KEY1_PORT) { //P2 Btn //S2 P2_0 TODO add check BUTTON pin
180 | zclFactoryResetter_HandleKeys(portAndAction, keyCode);
181 | if (portAndAction & HAL_KEY_PRESS) {
182 | LREP("Key pressed. Clicks - %d\r\n", zclApp_State.clicks);
183 | if (zclApp_State.clicks < 2) {
184 | zclApp_State.clicks++;
185 | }
186 |
187 | osal_start_timerEx(zclApp_TaskID, APP_BTN_HOLD_EVT, BTN_HOLD_TIME);
188 | osal_stop_timerEx(zclApp_TaskID, APP_BTN_CLICK_EVT);
189 | }
190 | if (portAndAction & HAL_KEY_RELEASE) {
191 | LREPMaster("Key released\r\n");
192 |
193 | osal_stop_timerEx(zclApp_TaskID, APP_BTN_HOLD_EVT);
194 | if (zclApp_State.clicks == 1) {
195 | osal_start_timerEx(zclApp_TaskID, APP_BTN_CLICK_EVT, 250);
196 | }
197 | if (zclApp_State.clicks == 2) {
198 | osal_start_timerEx(zclApp_TaskID, APP_BTN_DOUBLE_EVT, 50);
199 | }
200 | }
201 | }
202 | }
203 |
204 |
205 | uint16 zclApp_event_loop(uint8 task_id, uint16 events) {
206 | LREP("events 0x%x \r\n", events);
207 | if (events & SYS_EVENT_MSG) {
208 | afIncomingMSGPacket_t *MSGpkt;
209 | while ((MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive(zclApp_TaskID))) {
210 | LREP("MSGpkt->hdr.event 0x%X clusterId=0x%X\r\n", MSGpkt->hdr.event, MSGpkt->clusterId);
211 | switch (MSGpkt->hdr.event) {
212 | case KEY_CHANGE:
213 | zclApp_HandleKeys(((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys);
214 | break;
215 |
216 | case ZCL_INCOMING_MSG:
217 | if (((zclIncomingMsg_t *)MSGpkt)->attrCmd) {
218 | osal_mem_free(((zclIncomingMsg_t *)MSGpkt)->attrCmd);
219 | }
220 | break;
221 |
222 | default:
223 | break;
224 | }
225 |
226 | // Release the memory
227 | osal_msg_deallocate((uint8 *)MSGpkt);
228 | }
229 | // return unprocessed events
230 | return (events ^ SYS_EVENT_MSG);
231 | }
232 | if (events & APP_REPORT_EVT) {
233 | LREPMaster("APP_REPORT_EVT\r\n");
234 | zclApp_OneReport();
235 | return (events ^ APP_REPORT_EVT);
236 | }
237 |
238 | if (events & APP_SAVE_ATTRS_EVT) {
239 | LREPMaster("APP_SAVE_ATTRS_EVT\r\n");
240 | zclApp_SaveAttributesToNV();
241 | zclApp_ConfigInit(TIMER_RESTART);
242 | return (events ^ APP_SAVE_ATTRS_EVT);
243 | }
244 |
245 | if (events & APP_BTN_CLICK_EVT) {
246 | LREPMaster("APP_BTN_CLICK_EVT\r\n");
247 | zclApp_BtnClicks(1);
248 | return (events ^ APP_BTN_CLICK_EVT);
249 | }
250 |
251 | if (events & APP_RING_RUN_EVT) {
252 | LREPMaster("APP_RING_RUN_EVT\r\n");
253 | zclApp_RingRun();
254 | return (events ^ APP_RING_RUN_EVT);
255 | }
256 |
257 | if (events & APP_RING_STOP_EVT) {
258 | LREPMaster("APP_RING_STOP_EVT\r\n");
259 | // if answer started - break not allowed
260 | if (zclApp_State.State == Ring) {
261 | zclApp_RingEnd();
262 | }
263 | return (events ^ APP_RING_STOP_EVT);
264 | }
265 |
266 | if (events & APP_TALK_START_EVT) {
267 | LREPMaster("APP_TALK_START_EVT\r\n");
268 | zclApp_TalkStart();
269 | return (events ^ APP_TALK_START_EVT);
270 | }
271 |
272 | if (events & APP_WORK_LED_EVT) {
273 | LREPMaster("APP_WORK_LED_EVT\r\n");
274 | zclApp_WorkWithLEDs();
275 | return (events ^ APP_WORK_LED_EVT);
276 | }
277 |
278 | if (events & APP_BTN_HOLD_EVT) {
279 | LREPMaster("APP_BTN_HOLD_EVT\r\n");
280 | //#if !defined( ZIC_BATTERY_MODE )
281 | zclApp_BtnClicks(255);
282 | //#endif
283 | return (events ^ APP_BTN_HOLD_EVT);
284 | }
285 |
286 | if (events & APP_BTN_DOUBLE_EVT) {
287 | LREPMaster("APP_BTN_DOUBLE_EVT\r\n");
288 | zclApp_BtnClicks(2);
289 | return (events ^ APP_BTN_DOUBLE_EVT);
290 | }
291 |
292 | return 0;
293 | }
294 |
295 |
296 | static void zclApp_RingRun(void) {
297 | LREP("zclApp_State.State %d\r\n", zclApp_State.State);
298 | uint32 timeRingStart = osal_GetSystemClock();
299 | // timeout for next ring step
300 | // 250 - default ring timeout in Never mode
301 | uint32 timeout_value = 250;
302 |
303 | switch (zclApp_State.State) {
304 | case Idle:
305 | zclApp_State.State = Ring;
306 | if (zclApp_Config.ModeOpen != Never) {
307 | timeout_value = zclApp_Config.TimeRing * 1000;
308 | }
309 | zclApp_OneReport();
310 | break;
311 | case Ring:
312 | if (zclApp_Config.ModeOpen == Never) {
313 | break;
314 | }
315 | zclApp_State.State = Talk;
316 | timeout_value = zclApp_Config.TimeTalk * 1000;
317 | zclApp_TalkStart();
318 | break;
319 | case Talk:
320 | osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
321 | if (zclApp_Config.ModeOpen == Once || zclApp_Config.ModeOpen == Always) {
322 | // open door
323 | timeout_value = zclApp_Config.TimeOpen * 1000;
324 | zclApp_State.State = Open;
325 | ANSWER_PIN = 0;
326 | zclApp_OneReport();
327 | break;
328 | }
329 | // No break here. End call without open
330 | case Open:
331 | // end call
332 | osal_stop_timerEx(zclApp_TaskID, APP_RING_STOP_EVT);
333 | zclApp_RingEnd();
334 | timeout_value = 0;
335 | break;
336 | }
337 |
338 | if (timeout_value != 0) {
339 | osal_start_timerEx(zclApp_TaskID, APP_RING_RUN_EVT, timeout_value);
340 | }
341 | osal_start_timerEx(zclApp_TaskID, APP_WORK_LED_EVT, 50);
342 | }
343 |
344 | static void zclApp_TalkStart(void) {
345 | LREPMaster("Talk start\r\n");
346 | zclApp_OneReport();
347 | ANSWER_PIN = 1;
348 | if (zclApp_Config.ModeSound == true) {
349 | HANDSET_PIN = 1;
350 | }
351 | else {
352 | CATCH_PIN = 0;
353 | }
354 | }
355 |
356 | static void zclApp_RingEnd(void) {
357 | LREPMaster("Ring end\r\n");
358 | CATCH_PIN = !zclApp_Config.ModeSound;
359 | HANDSET_PIN = !zclApp_Config.ModeSound;
360 | ANSWER_PIN = 0;
361 | osal_stop_timerEx(zclApp_TaskID, APP_RING_RUN_EVT);
362 | osal_start_timerEx(zclApp_TaskID, APP_WORK_LED_EVT, 50);
363 | zclApp_State.State = Idle;
364 |
365 | afAddrType_t inderect_DstAddr = {.addrMode = (afAddrMode_t)AddrNotPresent, .endPoint = 0, .addr.shortAddr = 0};
366 | zclGeneral_SendOnOff_CmdOff(zclApp_FirstEP.EndPoint, &inderect_DstAddr, FALSE, bdb_getZCLFrameCounter());
367 |
368 | if (zclApp_Config.ModeOpen == Once) {
369 | zclApp_Config.ModeOpen = Never;
370 | }
371 | zclApp_OneReport();
372 |
373 | #if defined( ZIC_BATTERY_MODE )
374 | zclBattery_Report();
375 | isRingOn = false;
376 | if (isLedOn == false) {
377 | osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_CONSERVE);
378 | }
379 | #endif
380 | }
381 |
382 | static void zclApp_WorkWithLEDs(void) {
383 | #if defined( ZIC_BATTERY_MODE )
384 | if (isLedOn != false) { // Off LEDs and goto sleep
385 | isLedOn = false;
386 | HalLedSet(HAL_LED_ALL, HAL_LED_MODE_OFF);
387 | if (isRingOn == false) {
388 | osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_CONSERVE);
389 | }
390 | return;
391 | }
392 | // On LEDs and hold power 2 sec.
393 | isLedOn = true;
394 | osal_pwrmgr_task_state(zclApp_TaskID, PWRMGR_HOLD);
395 | osal_start_timerEx(zclApp_TaskID, APP_WORK_LED_EVT, 2000);
396 | #endif
397 |
398 | if (showSound & showMode) {
399 | showSound = false;
400 | showMode = false;
401 | HalLedBlink(OLD_LED, 1, 99, 2000);
402 | } else if (showSound) {
403 | showSound = false;
404 | HalLedBlink(OLD_LED, zclApp_Config.ModeSound + 1, 50, 750);
405 | } else if (showMode) {
406 | showMode = false;
407 | HalLedBlink(OLD_LED, zclApp_Config.ModeOpen + 1, 50, 250);
408 | }
409 |
410 | if (zclApp_Config.ModeOpen == Always) {
411 | HalLedSet(GREEN_LED, HAL_LED_MODE_ON);
412 | }
413 | if (zclApp_Config.ModeOpen != Always) {
414 | HalLedSet(GREEN_LED, HAL_LED_MODE_OFF);
415 | }
416 | if (zclApp_Config.ModeOpen == Once) {
417 | HalLedBlink(GREEN_LED, 0, 95, 500);
418 | }
419 | if (zclApp_Config.ModeOpen == Drop) {
420 | HalLedSet(RED_LED, HAL_LED_MODE_ON);
421 | }
422 | if (zclApp_Config.ModeOpen != Drop) {
423 | HalLedSet(RED_LED, HAL_LED_MODE_OFF);
424 | }
425 | if (zclApp_State.State != Idle) {
426 | HalLedSet(RED_LED, HAL_LED_MODE_BLINK);
427 | }
428 | if (zclApp_Config.ModeSound == true) {
429 | HalLedSet(BLUE_LED, HAL_LED_MODE_OFF);
430 | }
431 | else {
432 | HalLedSet(BLUE_LED, HAL_LED_MODE_ON);
433 | }
434 | }
435 |
436 | static void zclApp_BtnClicks(byte count) {
437 | zclApp_State.clicks = 0;
438 | osal_start_timerEx(zclApp_TaskID, APP_WORK_LED_EVT, 50);
439 |
440 | switch (count) {
441 | case 1:
442 | LREPMaster("Button click\r\n");
443 | if (zclApp_State.State == Idle) {
444 | // if we don`t have income ring - change mode
445 | if (zclApp_Config.ModeOpen < Drop) {
446 | zclApp_Config.ModeOpen++;
447 | }
448 | else {
449 | zclApp_Config.ModeOpen = Never;
450 | }
451 | zclApp_OneReport();
452 | }
453 | else {
454 | // if we have income ring, and mode is Never - open door
455 | if (zclApp_State.State == Ring && zclApp_Config.ModeOpen == Never) {
456 | zclApp_Config.ModeOpen = Once;
457 | }
458 | }
459 | showMode = true;
460 | break;
461 | case 2:
462 | LREPMaster("Button double\r\n");
463 | if (zclApp_State.State == Idle) {
464 | zclApp_Config.ModeSound = !zclApp_Config.ModeSound;
465 | HANDSET_PIN = !zclApp_Config.ModeSound;
466 | CATCH_PIN = !zclApp_Config.ModeSound;
467 | zclApp_OneReport();
468 | }
469 | showSound = true;
470 | break;
471 | case 255:
472 | LREPMaster("Button hold\r\n");
473 | if (zclApp_State.State == Idle) {
474 | // if we don`t have income ring - reset mode
475 | zclApp_Config.ModeSound = true;
476 | HANDSET_PIN = !zclApp_Config.ModeSound;
477 | CATCH_PIN = !zclApp_Config.ModeSound;
478 | zclApp_Config.ModeOpen = Never;
479 | zclApp_OneReport();
480 | }
481 | else {
482 | // if we have income ring - drop it
483 | if (zclApp_State.State == Ring) {
484 | // in stage "ring" - start talk
485 | osal_stop_timerEx(zclApp_TaskID, APP_RING_RUN_EVT);
486 | osal_start_timerEx(zclApp_TaskID, APP_RING_RUN_EVT, zclApp_Config.TimeTalk * 1000);
487 | zclApp_TalkStart();
488 | }
489 | // skip step "open", go to end call
490 | zclApp_State.State = Open;
491 | osal_start_timerEx(zclApp_TaskID, APP_RING_STOP_EVT, 250);
492 | }
493 | showMode = true;
494 | showSound = true;
495 | break;
496 | }
497 | }
498 |
499 | static void zclApp_OneReport(void) {
500 | bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_STATE);
501 | bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_MODEOPEN);
502 | bdb_RepChangedAttrValue(zclApp_FirstEP.EndPoint, ZCL_INTERCOM, ATTRID_MODESOUND);
503 | }
504 |
505 | static void zclApp_BasicResetCB(void) {
506 | LREPMaster("BasicResetCB\r\n");
507 | zclApp_ResetAttributesToDefaultValues();
508 | zclApp_SaveAttributesToNV();
509 | }
510 |
511 | static ZStatus_t zclApp_ReadWriteAuthCB(afAddrType_t *srcAddr, zclAttrRec_t *pAttr, uint8 oper) {
512 | LREPMaster("AUTH CB called\r\n");
513 | osal_start_timerEx(zclApp_TaskID, APP_SAVE_ATTRS_EVT, 200);
514 | return ZSuccess;
515 | }
516 |
517 | static void zclApp_SaveAttributesToNV(void) {
518 | uint8 writeStatus = osal_nv_write(NW_APP_CONFIG, 0, sizeof(application_config_t), &zclApp_Config);
519 | LREP("Saving attributes to NV write=%d\r\n", writeStatus);
520 | }
521 |
522 | static void zclApp_ConfigInit(bool restart) {
523 | if (restart) {
524 | LREP("Stop report timer event\r\n");
525 | osal_stop_timerEx(zclApp_TaskID, APP_REPORT_EVT);
526 | osal_clear_event(zclApp_TaskID, APP_REPORT_EVT);
527 | }
528 | uint32 ReportInterval = (uint32)zclApp_Config.TimeReport * (uint32)60;
529 | LREP("Start report with interval %d seconds\r\n", ReportInterval);
530 | osal_start_reload_timer(zclApp_TaskID, APP_REPORT_EVT, ((uint32)ReportInterval*(uint32)1000));
531 | osal_start_timerEx(zclApp_TaskID, APP_WORK_LED_EVT, 50);
532 |
533 | if (zclApp_State.State == Idle) {
534 | HANDSET_PIN = !zclApp_Config.ModeSound;
535 | CATCH_PIN = !zclApp_Config.ModeSound;
536 | ANSWER_PIN = 0;
537 | }
538 | }
539 |
540 | static void zclApp_RestoreAttributesFromNV(void) {
541 | uint8 status = osal_nv_item_init(NW_APP_CONFIG, sizeof(application_config_t), NULL);
542 | LREP("Restoring attributes from NV status=%d \r\n", status);
543 | if (status == NV_ITEM_UNINIT) {
544 | uint8 writeStatus = osal_nv_write(NW_APP_CONFIG, 0, sizeof(application_config_t), &zclApp_Config);
545 | LREP("NV was empty, writing %d\r\n", writeStatus);
546 | }
547 | if (status == ZSUCCESS) {
548 | LREPMaster("Reading from NV\r\n");
549 | osal_nv_read(NW_APP_CONFIG, 0, sizeof(application_config_t), &zclApp_Config);
550 | }
551 | }
552 |
553 | /****************************************************************************
554 | ****************************************************************************/
555 |
--------------------------------------------------------------------------------
/Source/hal_board_cfg.h:
--------------------------------------------------------------------------------
1 | #ifndef HAL_BOARD_CFG_H
2 | #define HAL_BOARD_CFG_H
3 |
4 |
5 | /* ------------------------------------------------------------------------------------------------
6 | * Includes
7 | * ------------------------------------------------------------------------------------------------
8 | */
9 |
10 | #include "hal_mcu.h"
11 | #include "hal_defs.h"
12 | #include "hal_types.h"
13 |
14 | /* ------------------------------------------------------------------------------------------------
15 | * CC2590/CC2591 support
16 | *
17 | * Define HAL_PA_LNA_CC2590 if CC2530+CC2590EM is used
18 | * Define HAL_PA_LNA if CC2530+CC2591EM is used
19 | * Note that only one of them can be defined
20 | * ------------------------------------------------------------------------------------------------
21 | */
22 | #define xHAL_PA_LNA
23 | #define xHAL_PA_LNA_CC2590
24 | #define xHAL_PA_LNA_SE2431L
25 | #define xHAL_PA_LNA_CC2592
26 |
27 | /* ------------------------------------------------------------------------------------------------
28 | * Clock Speed
29 | * ------------------------------------------------------------------------------------------------
30 | */
31 |
32 | #define HAL_CPU_CLOCK_MHZ 32
33 |
34 | /* This flag should be defined if the SoC uses the 32MHz crystal
35 | * as the main clock source (instead of DCO).
36 | */
37 | #define HAL_CLOCK_CRYSTAL
38 |
39 | /* 32 kHz clock source select in CLKCONCMD */
40 | #if !defined (OSC32K_CRYSTAL_INSTALLED) || (defined (OSC32K_CRYSTAL_INSTALLED) && (OSC32K_CRYSTAL_INSTALLED == TRUE))
41 | #define OSC_32KHZ 0x00 /* external 32 KHz xosc */
42 | #else
43 | #define OSC_32KHZ 0x80 /* internal 32 KHz rcosc */
44 | #endif
45 |
46 | #define HAL_CLOCK_STABLE() st( while (CLKCONSTA != (CLKCONCMD_32MHZ | OSC_32KHZ)); )
47 |
48 | /* ------------------------------------------------------------------------------------------------
49 | * LED Configuration
50 | * ------------------------------------------------------------------------------------------------
51 | */
52 |
53 | #if defined (HAL_BOARD_CHDTECH_DEV)
54 | #define HAL_NUM_LEDS 1
55 | #elif defined(HAL_BOARD_TARGET)
56 | #define HAL_NUM_LEDS 1
57 | #else
58 | #error Unknown Board Indentifier
59 | #endif
60 |
61 | #define HAL_LED_BLINK_DELAY() st( { volatile uint32 i; for (i=0; i<0x5800; i++) { }; } )
62 |
63 | #if defined(HAL_BOARD_TARGET)
64 | // blue
65 | #define LED1_BV BV(7)
66 | #define LED1_SBIT P1_7
67 | #define LED1_DDR P1DIR
68 | #define LED1_POLARITY ACTIVE_HIGH
69 | // green
70 | #define LED2_BV BV(6)
71 | #define LED2_SBIT P1_6
72 | #define LED2_DDR P1DIR
73 | #define LED2_POLARITY ACTIVE_HIGH
74 | // red
75 | #define LED3_BV BV(5)
76 | #define LED3_SBIT P1_5
77 | #define LED3_DDR P1DIR
78 | #define LED3_POLARITY ACTIVE_HIGH
79 | // old led
80 | #define LED4_BV BV(4)
81 | #define LED4_SBIT P0_4
82 | #define LED4_DDR P0DIR
83 | #define LED4_POLARITY ACTIVE_HIGH
84 | // Catch control pin
85 | #define CATCH_BV BV(1)
86 | #define CATCH_PIN P0_1
87 | #define CATCH_DDR P0DIR
88 | #define CATCH_SSR P0SEL
89 | // Answer control pin
90 | #define ANSWER_BV BV(2)
91 | #define ANSWER_PIN P0_2
92 | #define ANSWER_DDR P0DIR
93 | #define ANSWER_SSR P0SEL
94 | // Handset control pin
95 | #define HANDSET_BV BV(3)
96 | #define HANDSET_PIN P0_3
97 | #define HANDSET_DDR P0DIR
98 | #define HANDSET_SSR P0SEL
99 |
100 | #elif defined(HAL_BOARD_CHDTECH_DEV)
101 | //blue//d3
102 | #define LED1_BV BV(4)
103 | #define LED1_SBIT P1_4
104 | #define LED1_DDR P1DIR
105 | #define LED1_POLARITY ACTIVE_LOW
106 | //green//d2
107 | #define LED2_BV BV(1)
108 | #define LED2_SBIT P1_1
109 | #define LED2_DDR P1DIR
110 | #define LED2_POLARITY ACTIVE_LOW
111 | //red//d1
112 | #define LED3_BV BV(0)
113 | #define LED3_SBIT P1_0
114 | #define LED3_DDR P1DIR
115 | #define LED3_POLARITY ACTIVE_LOW
116 | //ex
117 | #define LED4_BV BV(4)
118 | #define LED4_SBIT P0_4
119 | #define LED4_DDR P0DIR
120 | #define LED4_POLARITY ACTIVE_HIGH
121 | // Catch control pin
122 | #define CATCH_BV BV(1)
123 | #define CATCH_PIN P0_1
124 | #define CATCH_DDR P0DIR
125 | #define CATCH_SSR P0SEL
126 | // Answer control pin
127 | #define ANSWER_BV BV(2)
128 | #define ANSWER_PIN P1_2
129 | #define ANSWER_DDR P1DIR
130 | #define ANSWER_SSR P1SEL
131 | // Handset control pin
132 | #define HANDSET_BV BV(3)
133 | #define HANDSET_PIN P1_3
134 | #define HANDSET_DDR P1DIR
135 | #define HANDSET_SSR P1SEL
136 | #endif
137 |
138 | #define BLUE_LED HAL_LED_1
139 | #define GREEN_LED HAL_LED_2
140 | #define RED_LED HAL_LED_3
141 | #define OLD_LED HAL_LED_4
142 |
143 | #define INFO_LED HAL_LED_1 | HAL_LED_4
144 |
145 | /* ------------------------------------------------------------------------------------------------
146 | * Push Button Configuration
147 | * ------------------------------------------------------------------------------------------------
148 | */
149 |
150 | #define ACTIVE_LOW !
151 | #define ACTIVE_HIGH !! /* double negation forces result to be '1' */
152 |
153 | /* S1 */
154 | #define PUSH1_BV BV(0)
155 | #define PUSH1_SBIT P2_0
156 |
157 | //???????????????????????????????
158 |
159 |
160 |
161 | /* ------------------------------------------------------------------------------------------------
162 | * OSAL NV implemented by internal flash pages.
163 | * ------------------------------------------------------------------------------------------------
164 | */
165 |
166 | // Flash is partitioned into 8 banks of 32 KB or 16 pages.
167 | #define HAL_FLASH_PAGE_PER_BANK 16
168 | // Flash is constructed of 128 pages of 2 KB.
169 | #define HAL_FLASH_PAGE_SIZE 2048
170 | #define HAL_FLASH_WORD_SIZE 4
171 |
172 | // CODE banks get mapped into the XDATA range 8000-FFFF.
173 | #define HAL_FLASH_PAGE_MAP 0x8000
174 |
175 | // The last 16 bytes of the last available page are reserved for flash lock bits.
176 | // NV page definitions must coincide with segment declaration in project *.xcl file.
177 | #if defined NON_BANKED
178 | #define HAL_FLASH_LOCK_BITS 16
179 | #define HAL_NV_PAGE_END 30
180 | #define HAL_NV_PAGE_CNT 2
181 | #else
182 | #define HAL_FLASH_LOCK_BITS 16
183 | #define HAL_NV_PAGE_END 126
184 | #define HAL_NV_PAGE_CNT 6
185 | #endif
186 |
187 | // Re-defining Z_EXTADDR_LEN here so as not to include a Z-Stack .h file.
188 | #define HAL_FLASH_IEEE_SIZE 8
189 | #define HAL_FLASH_IEEE_PAGE (HAL_NV_PAGE_END+1)
190 | #define HAL_FLASH_IEEE_OSET (HAL_FLASH_PAGE_SIZE - HAL_FLASH_LOCK_BITS - HAL_FLASH_IEEE_SIZE)
191 | #define HAL_INFOP_IEEE_OSET 0xC
192 |
193 | #define HAL_FLASH_DEV_PRIVATE_KEY_OSET 0x7D2
194 | #define HAL_FLASH_CA_PUBLIC_KEY_OSET 0x7BC
195 | #define HAL_FLASH_IMPLICIT_CERT_OSET 0x78C
196 |
197 | #define HAL_NV_PAGE_BEG (HAL_NV_PAGE_END-HAL_NV_PAGE_CNT+1)
198 | // Used by DMA macros to shift 1 to create a mask for DMA registers.
199 | #define HAL_NV_DMA_CH 0
200 | #define HAL_DMA_CH_RX 3
201 | #define HAL_DMA_CH_TX 4
202 |
203 | #define HAL_NV_DMA_GET_DESC() HAL_DMA_GET_DESC0()
204 | #define HAL_NV_DMA_SET_ADDR(a) HAL_DMA_SET_ADDR_DESC0((a))
205 |
206 | /* ------------------------------------------------------------------------------------------------
207 | * Serial Boot Loader: reserving the first 4 pages of flash and other memory in cc2530-sb.xcl.
208 | * ------------------------------------------------------------------------------------------------
209 | */
210 |
211 | #define HAL_SB_IMG_ADDR 0x2000
212 | #define HAL_SB_CRC_ADDR 0x2090
213 | // Size of internal flash less 4 pages for boot loader, 6 pages for NV, & 1 page for lock bits.
214 | #define HAL_SB_IMG_SIZE (0x40000 - 0x2000 - 0x3000 - 0x0800)
215 |
216 | /* ------------------------------------------------------------------------------------------------
217 | * Macros
218 | * ------------------------------------------------------------------------------------------------
219 | */
220 |
221 | /* ----------- RF-frontend Connection Initialization ---------- */
222 | #if defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590 || \
223 | defined HAL_PA_LNA_SE2431L || defined HAL_PA_LNA_CC2592
224 | extern void MAC_RfFrontendSetup(void);
225 | #define HAL_BOARD_RF_FRONTEND_SETUP() MAC_RfFrontendSetup()
226 | #else
227 | #define HAL_BOARD_RF_FRONTEND_SETUP()
228 | #endif
229 |
230 | /* ----------- Cache Prefetch control ---------- */
231 | #define PREFETCH_ENABLE() st( FCTL = 0x08; )
232 | #define PREFETCH_DISABLE() st( FCTL = 0x04; )
233 |
234 | /* ----------- Board Initialization ---------- */
235 | #if !defined(HAL_PA_LNA) && !defined(HAL_PA_LNA_CC2592)
236 | #define HAL_BOARD_INIT() \
237 | { \
238 | uint16 i; \
239 | \
240 | SLEEPCMD &= ~OSC_PD; /* turn on 16MHz RC and 32MHz XOSC */ \
241 | while (!(SLEEPSTA & XOSC_STB)); /* wait for 32MHz XOSC stable */ \
242 | asm("NOP"); /* chip bug workaround */ \
243 | for (i=0; i<504; i++) asm("NOP"); /* Require 63us delay for all revs */ \
244 | CLKCONCMD = (CLKCONCMD_32MHZ | OSC_32KHZ); /* Select 32MHz XOSC and the source for 32K clock */ \
245 | while (CLKCONSTA != (CLKCONCMD_32MHZ | OSC_32KHZ)); /* Wait for the change to be effective */ \
246 | SLEEPCMD |= OSC_PD; /* turn off 16MHz RC */ \
247 | \
248 | /* Turn on cache prefetch mode */ \
249 | PREFETCH_ENABLE(); \
250 | \
251 | LED1_DDR |= LED1_BV; \
252 | LED2_DDR |= LED2_BV; \
253 | LED3_DDR |= LED3_BV; \
254 | LED4_DDR |= LED4_BV; \
255 | }
256 |
257 | #elif defined (HAL_PA_LNA)
258 | #define HAL_BOARD_INIT() \
259 | { \
260 | uint16 i; \
261 | \
262 | SLEEPCMD &= ~OSC_PD; /* turn on 16MHz RC and 32MHz XOSC */ \
263 | while (!(SLEEPSTA & XOSC_STB)); /* wait for 32MHz XOSC stable */ \
264 | asm("NOP"); /* chip bug workaround */ \
265 | for (i=0; i<504; i++) asm("NOP"); /* Require 63us delay for all revs */ \
266 | CLKCONCMD = (CLKCONCMD_32MHZ | OSC_32KHZ); /* Select 32MHz XOSC and the source for 32K clock */ \
267 | while (CLKCONSTA != (CLKCONCMD_32MHZ | OSC_32KHZ)); /* Wait for the change to be effective */ \
268 | SLEEPCMD |= OSC_PD; /* turn off 16MHz RC */ \
269 | \
270 | /* Turn on cache prefetch mode */ \
271 | PREFETCH_ENABLE(); \
272 | \
273 | /* set direction for GPIO outputs */ \
274 | /* For SE2431L PA LNA this sets ANT_SEL to output */ \
275 | /* For CC2592 this enables LNA */ \
276 | P1DIR |= BV(0) | BV(1); \
277 | \
278 | /* Set PA/LNA HGM control P0_7 */ \
279 | P0DIR |= BV(7); \
280 | \
281 | \
282 | /* setup RF frontend if necessary */ \
283 | HAL_BOARD_RF_FRONTEND_SETUP(); \
284 | LED1_DDR |= LED1_BV; \
285 | LED2_DDR |= LED2_BV; \
286 | LED3_DDR |= LED3_BV; \
287 | LED4_DDR |= LED4_BV; \
288 | }
289 |
290 | #elif defined (HAL_PA_LNA_CC2592) || defined (HAL_PA_LNA_SE2431L)
291 | #define HAL_BOARD_INIT() \
292 | { \
293 | uint16 i; \
294 | \
295 | SLEEPCMD &= ~OSC_PD; /* turn on 16MHz RC and 32MHz XOSC */ \
296 | while (!(SLEEPSTA & XOSC_STB)); /* wait for 32MHz XOSC stable */ \
297 | asm("NOP"); /* chip bug workaround */ \
298 | for (i=0; i<504; i++) asm("NOP"); /* Require 63us delay for all revs */ \
299 | CLKCONCMD = (CLKCONCMD_32MHZ | OSC_32KHZ); /* Select 32MHz XOSC and the source for 32K clock */ \
300 | while (CLKCONSTA != (CLKCONCMD_32MHZ | OSC_32KHZ)); /* Wait for the change to be effective */ \
301 | SLEEPCMD |= OSC_PD; /* turn off 16MHz RC */ \
302 | \
303 | /* Turn on cache prefetch mode */ \
304 | PREFETCH_ENABLE(); \
305 | \
306 | /* set direction for GPIO outputs */ \
307 | /* For SE2431L PA LNA this sets ANT_SEL to output */ \
308 | /* For CC2592 this enables LNA */ \
309 | P1DIR |= BV(0) | BV(1); \
310 | \
311 | /* Set PA/LNA HGM control P0_7 */ \
312 | P0DIR |= BV(7); \
313 | \
314 | \
315 | /* setup RF frontend if necessary */ \
316 | HAL_BOARD_RF_FRONTEND_SETUP(); \
317 | LED1_DDR |= LED1_BV; \
318 | LED2_DDR |= LED2_BV; \
319 | LED3_DDR |= LED3_BV; \
320 | LED4_DDR |= LED4_BV; \
321 | }
322 | #endif
323 |
324 | /* ----------- Debounce ---------- */
325 | #define HAL_DEBOUNCE(expr) { int i; for (i=0; i<500; i++) { if (!(expr)) i = 0; } }
326 |
327 | /* ----------- Push Buttons ---------- */
328 | #define HAL_PUSH_BUTTON1() (0)
329 | #define HAL_PUSH_BUTTON2() (0)
330 | #define HAL_PUSH_BUTTON3() (0)
331 | #define HAL_PUSH_BUTTON4() (0)
332 | #define HAL_PUSH_BUTTON5() (0)
333 | #define HAL_PUSH_BUTTON6() (0)
334 |
335 | /* ----------- LED's ---------- */
336 | #define HAL_TURN_OFF_LED1() st( LED1_SBIT = LED1_POLARITY (0); )
337 | #define HAL_TURN_OFF_LED2() st( LED2_SBIT = LED2_POLARITY (0); )
338 | #define HAL_TURN_OFF_LED3() st( LED3_SBIT = LED3_POLARITY (0); )
339 | #define HAL_TURN_OFF_LED4() st( LED4_SBIT = LED4_POLARITY (0); )
340 |
341 | #define HAL_TURN_ON_LED1() st( LED1_SBIT = LED1_POLARITY (1); )
342 | #define HAL_TURN_ON_LED2() st( LED2_SBIT = LED2_POLARITY (1); )
343 | #define HAL_TURN_ON_LED3() st( LED3_SBIT = LED3_POLARITY (1); )
344 | #define HAL_TURN_ON_LED4() st( LED4_SBIT = LED4_POLARITY (1); )
345 |
346 | #define HAL_TOGGLE_LED1() st( if (LED1_SBIT) { LED1_SBIT = 0; } else { LED1_SBIT = 1;} )
347 | #define HAL_TOGGLE_LED2() st( if (LED2_SBIT) { LED2_SBIT = 0; } else { LED2_SBIT = 1;} )
348 | #define HAL_TOGGLE_LED3() st( if (LED3_SBIT) { LED3_SBIT = 0; } else { LED3_SBIT = 1;} )
349 | #define HAL_TOGGLE_LED4() st( if (LED4_SBIT) { LED4_SBIT = 0; } else { LED4_SBIT = 1;} )
350 |
351 | #define HAL_STATE_LED1() (LED1_POLARITY (LED1_SBIT))
352 | #define HAL_STATE_LED2() (LED2_POLARITY (LED2_SBIT))
353 | #define HAL_STATE_LED3() (LED3_POLARITY (LED3_SBIT))
354 | #define HAL_STATE_LED4() (LED4_POLARITY (LED4_SBIT))
355 |
356 | /* ----------- XNV ---------- */
357 | #define XNV_SPI_BEGIN() st(P1_3 = 0;)
358 | #define XNV_SPI_TX(x) st(U1CSR &= ~0x02; U1DBUF = (x);)
359 | #define XNV_SPI_RX() U1DBUF
360 | #define XNV_SPI_WAIT_RXRDY() st(while (!(U1CSR & 0x02));)
361 | #define XNV_SPI_END() st(P1_3 = 1;)
362 |
363 | // The TI reference design uses UART1 Alt. 2 in SPI mode.
364 | #define XNV_SPI_INIT() \
365 | st( \
366 | /* Mode select UART1 SPI Mode as master. */\
367 | U1CSR = 0; \
368 | \
369 | /* Setup for 115200 baud. */\
370 | U1GCR = 11; \
371 | U1BAUD = 216; \
372 | \
373 | /* Set bit order to MSB */\
374 | U1GCR |= BV(5); \
375 | \
376 | /* Set UART1 I/O to alternate 2 location on P1 pins. */\
377 | PERCFG |= 0x02; /* U1CFG */\
378 | \
379 | /* Select peripheral function on I/O pins but SS is left as GPIO for separate control. */\
380 | P1SEL |= 0xE0; /* SELP1_[7:4] */\
381 | /* P1.1,2,3: reset, LCD CS, XNV CS. */\
382 | P1SEL &= ~0x0E; \
383 | P1 |= 0x0E; \
384 | P1_1 = 0; \
385 | P1DIR |= 0x0E; \
386 | \
387 | /* Give UART1 priority over Timer3. */\
388 | P2SEL &= ~0x20; /* PRI2P1 */\
389 | \
390 | /* When SPI config is complete, enable it. */\
391 | U1CSR |= 0x40; \
392 | /* Release XNV reset. */\
393 | P1_1 = 1; \
394 | )
395 |
396 | /* ----------- Minimum safe bus voltage ---------- */
397 |
398 | // Vdd/3 / Internal Reference X ENOB --> (Vdd / 3) / 1.15 X 127
399 | #define VDD_2_0 74 // 2.0 V required to safely read/write internal flash.
400 | #define VDD_2_7 100 // 2.7 V required for the Numonyx device.
401 | #define VDD_MIN_RUN (VDD_2_0+4) // VDD_MIN_RUN = VDD_MIN_NV
402 | #define VDD_MIN_NV (VDD_2_0+4) // 5% margin over minimum to survive a page erase and compaction.
403 | #define VDD_MIN_GOOD (VDD_2_0+8) // 10% margin over minimum to survive a page erase and compaction.
404 | #define VDD_MIN_XNV (VDD_2_7+5) // 5% margin over minimum to survive a page erase and compaction.
405 |
406 | /* ------------------------------------------------------------------------------------------------
407 | * Driver Configuration
408 | * ------------------------------------------------------------------------------------------------
409 | */
410 |
411 | /* Set to TRUE enable H/W TIMER usage, FALSE disable it */
412 | #ifndef HAL_TIMER
413 | #define HAL_TIMER FALSE
414 | #endif
415 |
416 | /* Set to TRUE enable ADC usage, FALSE disable it */
417 | #ifndef HAL_ADC
418 | #define HAL_ADC TRUE
419 | #endif
420 |
421 | /* Set to TRUE enable DMA usage, FALSE disable it */
422 | #ifndef HAL_DMA
423 | #define HAL_DMA TRUE
424 | #endif
425 |
426 | /* Set to TRUE enable Flash access, FALSE disable it */
427 | #ifndef HAL_FLASH
428 | #define HAL_FLASH TRUE
429 | #endif
430 |
431 | /* Set to TRUE enable AES usage, FALSE disable it */
432 | #ifndef HAL_AES
433 | #define HAL_AES TRUE
434 | #endif
435 |
436 | #ifndef HAL_AES_DMA
437 | #define HAL_AES_DMA TRUE
438 | #endif
439 |
440 | /* Set to TRUE enable LCD usage, FALSE disable it */
441 | #ifndef HAL_LCD
442 | #define HAL_LCD TRUE
443 | #endif
444 |
445 | /* Set to TRUE enable LED usage, FALSE disable it */
446 | #ifndef HAL_LED
447 | #define HAL_LED TRUE
448 | #endif
449 | #if (!defined BLINK_LEDS) && (HAL_LED == TRUE)
450 | #define BLINK_LEDS
451 | #endif
452 |
453 | /* Set to TRUE enable KEY usage, FALSE disable it */
454 | #ifndef HAL_KEY
455 | #define HAL_KEY TRUE
456 | #endif
457 |
458 | /* Set to TRUE enable UART usage, FALSE disable it */
459 | #ifndef HAL_UART
460 | #if (defined ZAPP_P1) || (defined ZAPP_P2) || (defined ZTOOL_P1) || (defined ZTOOL_P2)
461 | #define HAL_UART TRUE
462 | #else
463 | #define HAL_UART FALSE
464 | #endif
465 | #endif
466 |
467 | #if HAL_UART
468 | #ifndef HAL_UART_DMA
469 | #if HAL_DMA
470 | #if (defined ZAPP_P2) || (defined ZTOOL_P2)
471 | #define HAL_UART_DMA 2
472 | #else
473 | #define HAL_UART_DMA 1
474 | #endif
475 | #else
476 | #define HAL_UART_DMA 0
477 | #endif
478 | #endif
479 |
480 | #ifndef HAL_UART_ISR
481 | #if HAL_UART_DMA // Default preference for DMA over ISR.
482 | #define HAL_UART_ISR 0
483 | #elif (defined ZAPP_P2) || (defined ZTOOL_P2)
484 | #define HAL_UART_ISR 2
485 | #else
486 | #define HAL_UART_ISR 1
487 | #endif
488 | #endif
489 |
490 | #if (HAL_UART_DMA && (HAL_UART_DMA == HAL_UART_ISR))
491 | #error HAL_UART_DMA & HAL_UART_ISR must be different.
492 | #endif
493 |
494 | // Used to set P2 priority - USART0 over USART1 if both are defined.
495 | #if ((HAL_UART_DMA == 1) || (HAL_UART_ISR == 1))
496 | #define HAL_UART_PRIPO 0x00
497 | #else
498 | #define HAL_UART_PRIPO 0x40
499 | #endif
500 |
501 | #else
502 | #define HAL_UART_DMA 0
503 | #define HAL_UART_ISR 0
504 | #endif
505 |
506 | /* USB is not used for CC2530 configuration */
507 | #define HAL_UART_USB 0
508 | #endif
509 | /*******************************************************************************************************
510 | */
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------