34 |
35 | int main (void)
36 | {
37 | ...
38 | }
39 |
40 | ```
41 |
42 | PlatformIO Library Dependency Finder will find automatically dependent
43 | libraries scanning project source files.
44 |
45 | More information about PlatformIO Library Dependency Finder
46 | - https://docs.platformio.org/page/librarymanager/ldf.html
47 |
--------------------------------------------------------------------------------
/lib/knx:
--------------------------------------------------------------------------------
1 | ../../knx
--------------------------------------------------------------------------------
/library.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "OAM-PresenceModule",
3 | "version": "3.6.2",
4 | "description": "Virtual Presence application for the knx stack, can be parametrized with ETS",
5 | "homepage": "https://openknx.de",
6 | "authors": {
7 | "name": "OpenKNX",
8 | "email": "info@openknx.de",
9 | "url": "https://openknx.de",
10 | "maintainer": true
11 | },
12 | "repository": {
13 | "type": "git",
14 | "url": "https://github.com/OpenKNX/OAM-PresenceModule"
15 | }
16 | }
--------------------------------------------------------------------------------
/platformio.bak.ini:
--------------------------------------------------------------------------------
1 | ;PlatformIO Project Configuration File
2 | ;
3 | ; Build options: build flags, source filter
4 | ; Upload options: custom upload port, speed and extra flags
5 | ; Library options: dependencies, extra library storages
6 | ; Advanced options: extra scripting
7 | ;
8 | ; Please visit documentation for the other options and examples
9 | ; https://docs.platformio.org/page/projectconf.html
10 |
11 | [platformio]
12 | ; default_envs = build
13 | libdeps_dir = /tmp/libdeps
14 |
15 | [env]
16 | framework = arduino
17 | build_flags =
18 | ; -include "src/PMmodulHardware.h"
19 | # put preprocessor output into object file directory
20 | ; -save-temps=obj
21 | ; -fverbose-asm
22 | -D PMMODULE
23 | ; optimize knx stack
24 | -D SMALL_GROUPOBJECT
25 | -D USE_BINSEARCH
26 | ; -D KNX_AUTO_ADAPT
27 | ; -D KNX_WAIT_FOR_ADDR
28 | -D MASK_VERSION=0x07B0
29 | ; use flash directly
30 | -D KNX_FLASH_SIZE=0x8000 ; be careful, has to be large enough for ETS data and data stored by IFlashUserData
31 | ;-D DEBUG_TIMING
32 | ;-D LOGIC_TRACE
33 | -Wno-unknown-pragmas
34 | -Wno-switch
35 | ; debug timing in knx stack
36 | monitor_speed = 115200
37 | lib_ldf_mode = deep+
38 | ; lib_extra_dirs =
39 | ; ${PROJECT_DIR}\..
40 | debug_tool = jlink
41 | debug_extra_cmds =
42 | set output-radix 16
43 | upload_protocol = jlink
44 |
45 | [RP2040]
46 | platform = https://github.com/maxgerhardt/platform-raspberrypi.git
47 | board = pico
48 | board_build.core = earlephilhower
49 | platform_packages = framework-arduinopico @ https://github.com/earlephilhower/arduino-pico/releases/download/2.7.3/rp2040-2.7.3.zip
50 | ; board_build.filesystem_size = 0.1m
51 | ; platform_packages =
52 | ; ; framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#2.3.2
53 | ; framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
54 |
55 | build_flags =
56 | ${env.build_flags}
57 | -D SERIAL_DEBUG=Serial
58 | ;flash start at 1.5MiB
59 | -D KNX_FLASH_OFFSET=0x180000
60 | ; -D USE_RP2040_EEPROM_EMULATION
61 | ; -D USE_RP2040_LARGE_EEPROM_EMULATION
62 | -D PIO_FRAMEWORK_ARDUINO_ENABLE_RTTI
63 | -D LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
64 | -O0
65 |
66 | build_unflags = -Os
67 |
68 | lib_deps =
69 | adafruit/Adafruit VEML7700 Library @ 2.1.0
70 | ; adafruit/Adafruit SleepyDog Library @ ^1.4.0
71 | ; ; Wire
72 | ; ; SPI
73 | ; build_type = debug
74 | debug_build_flags = -O0 -ggdb3
75 | ; debug_build_flags = -ggdb3
76 |
77 | [SAMD]
78 | platform = atmelsam
79 | board = zeroUSB
80 | build_flags =
81 | ${env.build_flags}
82 | -D SERIAL_DEBUG=SerialUSB
83 | ; -D KNX_FLASH_SIZE=0x8000
84 | ; use EEPROM emulation
85 | ; -D USE_SAMD_EEPROM_EMULATION
86 | ; -D CRYSTALLESS
87 | ; -D WATCHDOG
88 | lib_deps =
89 | adafruit/Adafruit SleepyDog Library @ 1.4.0
90 | adafruit/Adafruit VEML7700 Library @ 2.1.0
91 | ; Wire
92 | ; SPI
93 |
94 | [RP2040_develop]
95 | build_flags =
96 | -D DEBUG_DELAY=10000
97 | ; -D BOARD_MASIFI_PICO
98 | ; -D BOARD_MASIFI_V40
99 | ;-D BOARD_MASIFI_HFPM_DEVEL
100 | ; -D BOARD_SMARTMF_1TE_RP2040
101 | ; -D BOARD_SIRSYDOM_PIPICO_BCU_CONNECTOR
102 | -D BOARD_MASIFI_SENSOR_BREAKOUT
103 | -D SERIAL_HF=Serial2
104 |
105 | [SAMD_develop]
106 | build_flags =
107 | -D DEBUG_DELAY=10000
108 | -D BOARD_MASIFI_V2
109 |
110 |
111 |
112 | [env:build_RP2040]
113 | extends = RP2040
114 | build_flags =
115 | ${RP2040.build_flags}
116 | ${RP2040_develop.build_flags}
117 |
118 | [env:build_SAMD]
119 | extends = SAMD
120 | build_flags =
121 | ${SAMD.build_flags}
122 | ${SAMD_develop.build_flags}
123 |
124 |
125 |
126 | [env:upload_USB_RP2040]
127 | extends = RP2040
128 | build_flags =
129 | ${RP2040.build_flags}
130 | ${RP2040_develop.build_flags}
131 | upload_protocol = picotool
132 |
133 | [env:upload_USB_SAMD]
134 | extends = SAMD
135 | build_flags =
136 | ${SAMD.build_flags}
137 | ${SAMD_develop.build_flags}
138 | upload_protocol = sam-ba
139 |
140 | [env:upload_JLINK_RP2040]
141 | extends = RP2040
142 | build_flags =
143 | ${RP2040.build_flags}
144 | ${RP2040_develop.build_flags}
145 | upload_protocol = jlink
146 |
147 | [env:upload_Release_JLINK_RP2040]
148 | extends = RP2040
149 | build_flags =
150 | ${RP2040.build_flags}
151 | -D DEBUG_DELAY=100
152 | -D BOARD_MASIFI_HFPM_DEVEL2
153 | -D SERIAL_HF=Serial2
154 | upload_protocol = jlink
155 |
156 | [env:upload_JLINK_SAMD]
157 | extends = SAMD
158 | build_flags =
159 | ${SAMD.build_flags}
160 | ${SAMD_develop.build_flags}
161 | upload_protocol = jlink
162 |
163 | [env:upload_Release_JLINK_SAMD]
164 | extends = SAMD
165 | build_flags =
166 | ${SAMD.build_flags}
167 | -D DEBUG_DELAY=100
168 | -D BOARD_MASIFI_V3
169 | upload_protocol = jlink
170 |
171 |
172 | #### Release Environments
173 | [env:release_Sensormodul_v31_SAMD]
174 | extends = SAMD
175 | build_flags =
176 | ${SAMD.build_flags}
177 | -D DEBUG_DELAY=100
178 | -D BOARD_MASIFI_V31
179 |
180 | [env:release_Sensormodul_v30_SAMD]
181 | extends = SAMD
182 | build_flags =
183 | ${SAMD.build_flags}
184 | -D DEBUG_DELAY=100
185 | -D BOARD_MASIFI_V3
186 |
187 | [env:release_Sensormodul_v40_RP2040]
188 | extends = RP2040
189 | build_flags =
190 | ${RP2040.build_flags}
191 | -D DEBUG_DELAY=100
192 | -D BOARD_MASIFI_V40
193 |
194 | [env:release_PiPico_BCU_Connector]
195 | extends = RP2040
196 | build_flags =
197 | ${RP2040.build_flags}
198 | -D DEBUG_DELAY=100
199 | -D BOARD_SIRSYDOM_PIPICO_BCU_CONNECTOR
200 |
201 | [env:release_1TE_RP2040_SmartMF]
202 | extends = RP2040
203 | build_flags =
204 | ${RP2040.build_flags}
205 | -D DEBUG_DELAY=100
206 | -D BOARD_SMARTMF_1TE_RP2040
207 |
208 | [env:release_OpenKNX_REG1_Base]
209 | extends = RP2040
210 | build_flags =
211 | ${RP2040.build_flags}
212 | -D DEBUG_DELAY=100
213 | -D BOARD_OPENKNX_REG1_BASE
214 |
215 | [env:release_RP2040_devel]
216 | extends = RP2040
217 | build_flags =
218 | ${RP2040.build_flags}
219 | -D DEBUG_DELAY=100
220 | -D BOARD_MASIFI_HFPM_DEVEL
221 | -D SERIAL_HF=Serial2
222 |
223 | [env:release_RealPresence]
224 | extends = RP2040
225 | build_flags =
226 | ${RP2040.build_flags}
227 | -D DEBUG_DELAY=100
228 | -D BOARD_MASIFI_HFPM_DEVEL2
229 | -D SERIAL_HF=Serial2
230 |
231 | [env:release_RealPresence_v20]
232 | extends = RP2040
233 | build_flags =
234 | ${RP2040.build_flags}
235 | -D DEBUG_DELAY=100
236 | -D BOARD_MASIFI_HFPM_V20
237 | -D SERIAL_HF=Serial2
238 |
239 | ### This is an example for enduser compiled environment
240 | [env:enduser]
241 | extends = SAMD
242 | ;extends = RP2040
243 | upload_protocol = sam-ba
244 | ;upload_protocol = picotool
245 | build_flags =
246 | ${SAMD.build_flags}
247 | -D DEBUG_DELAY=100
248 | -D BOARD_ENDUSER
249 | ; -D BOARD_MASIFI_HFPM_DEVEL
250 |
--------------------------------------------------------------------------------
/platformio.custom.ini:
--------------------------------------------------------------------------------
1 | [SAMD_FLASH]
2 | build_flags =
3 | -D KNX_FLASH_SIZE=0x3800
4 | -D KNX_FLASH_OFFSET=0x3BC00
5 | -D OPENKNX_FLASH_SIZE=0x600
6 | -D OPENKNX_FLASH_OFFSET=0x3FA00
7 |
8 | [RP2040_FLASH]
9 | build_flags =
10 | -D KNX_FLASH_SIZE=0xC000
11 | -D KNX_FLASH_OFFSET=0xF0000
12 | -D OPENKNX_FLASH_SIZE=0x4000
13 | -D OPENKNX_FLASH_OFFSET=0xFC000
14 |
15 | [custom]
16 | build_flags =
17 | -D PMMODULE
18 | -D LOGICMODULE
19 | -D OPENKNX_LOOPTIME_WARNING=100
20 | ; -D KNX_AUTO_ADAPT
21 | ; -D KNX_WAIT_FOR_ADDR # ensures rx of an address (GA or PA) with higher ACK probability, but takes 7ms in knx.loop()!
22 | ; -D OPENKNX_LOOPTIME_WARNING=13 # should be set with KNX_WAIT_FOR_ADDR to OPENKNX_LOOPTIME_WARNING + 7
23 |
24 | ; debug parameters
25 | [custom_develop]
26 | extends = custom
27 | build_flags =
28 | ${custom.build_flags}
29 | -D OPENKNX_HEARTBEAT
30 | ; -D OPENKNX_HEARTBEAT_PRIO
31 | ; -D OPENKNX_RTT
32 | ; -D BUFFER_SIZE_UP=10240
33 | ; -D DEBUG_LOOP_TIME=10 ; will print a info when a loop took more than x ms.
34 | ; -D LOGIC_TRACE
35 | ; ; to see trace logs, they must match one of the 5 filters (TRACE_LOG1 .. TRACE_LOG2)
36 | ; "-D OPENKNX_TRACE1=Common.*"
37 | ; "-D OPENKNX_TRACE2=Flash.*"
38 | debug_build_flags =
39 | -D OPENKNX_DEBUGGER
40 | -ggdb3
41 |
42 | ; this config block is for specifing options that are valid for all RP2040-based builds
43 | [RP2040_custom]
44 | extends = RP2040, custom
45 | ; platform = https://github.com/maxgerhardt/platform-raspberrypi.git#0b2e90a
46 | ; platform_packages = framework-arduinopico @ https://github.com/earlephilhower/arduino-pico/releases/download/2.7.3/rp2040-2.7.3.zip
47 | ; board = pipico
48 | build_flags =
49 | -D SERIAL_DEBUG=Serial
50 | -D USE_KNX_DMA_UART=0
51 | -D USE_KNX_DMA_IRQ=0
52 | ; -D HF_SERIAL=Serial2
53 | -Wunused-variable
54 |
55 | ; this config block is for specifing options that are valid for all RP2040-based develop/debug builds
56 | [RP2040_custom_develop]
57 | extends = RP2040_develop, RP2040_custom, custom_develop, RP2040_EXCHANGE_2MB
58 | build_flags =
59 | ${RP2040_develop.build_flags}
60 | ${RP2040_custom.build_flags}
61 | ${custom_develop.build_flags}
62 | ${RP2040_EXCHANGE_2MB.build_flags}
63 | ${KNX_TP.build_flags}
64 | debug_build_flags =
65 | ${custom_develop.debug_build_flags}
66 | -O0
67 |
68 | ; this config block is for specifing options that are valid for all RP2040-based release builds
69 | [RP2040_custom_releases]
70 | extends = RP2040_releases, RP2040_custom, custom, UPLOAD_JLINK
71 | build_flags =
72 | ${RP2040_releases.build_flags}
73 | ${RP2040_custom.build_flags}
74 | ${custom.build_flags}
75 | ; "-D OPENKNX_TRACE1=C.*"
76 | ; -D OPENKNX_DEBUG
77 | -O0
78 |
79 | [RP2040_custom_releases_TP]
80 | extends = RP2040_custom_releases
81 | build_flags =
82 | ${RP2040_custom_releases.build_flags}
83 | ${KNX_TP.build_flags}
84 |
85 | [RP2040_custom_releases_TP_2MB]
86 | extends = RP2040_custom_releases_TP, RP2040_EXCHANGE_2MB
87 | build_flags =
88 | ${RP2040_EXCHANGE_2MB.build_flags}
89 | ${RP2040_custom_releases_TP.build_flags}
90 |
91 | [RP2040_custom_releases_TP_16MB]
92 | extends = RP2040_custom_releases_TP, RP2040_EXCHANGE_16MB
93 | build_flags =
94 | ${RP2040_EXCHANGE_16MB.build_flags}
95 | ${RP2040_custom_releases_TP.build_flags}
96 |
97 | [RP2040_custom_releases_IP]
98 | extends = RP2040_custom_releases
99 | build_flags =
100 | ${RP2040_custom_releases.build_flags}
101 | ${KNX_IP.build_flags}
102 |
103 |
104 | ; this config block is for specifing options that are valid for all SAMD-based builds
105 | [SAMD_custom]
106 | extends = SAMD, custom
107 | build_flags =
108 | -D SERIAL_DEBUG=SerialUSB
109 | -D KNX_DEBUG_SERIAL=SerialUSB
110 | -D KNX_SERIAL=Serial1
111 |
112 | ; this config block is for specifing options that are valid for all SAMD-based develop/debug builds
113 | [SAMD_custom_develop]
114 | extends = SAMD_custom, SAMD_develop, custom_develop
115 | build_flags =
116 | ${SAMD_develop.build_flags}
117 | ${SAMD_custom.build_flags}
118 | ${custom_develop.build_flags}
119 | ${KNX_TP.build_flags}
120 | debug_build_flags =
121 | ${custom_develop.debug_build_flags}
122 | -Os
123 |
124 |
125 | ; this config block is for specifing options that are valid for all SAMD-based release builds
126 | [SAMD_custom_releases]
127 | extends = SAMD_releases, SAMD_custom, custom
128 | build_flags =
129 | ${SAMD_releases.build_flags}
130 | ${SAMD_custom.build_flags}
131 | ${custom.build_flags}
132 | ${KNX_TP.build_flags}
133 | -Os
134 |
135 | [env:develop_SAMD]
136 | extends = SAMD_custom_develop
137 | build_flags =
138 | ${SAMD_custom_develop.build_flags}
139 | -D BOARD_MASIFI_V3
140 | ; -D BOARD_MASIFI_V31
141 |
142 | [env:develop_RP2040]
143 | extends = RP2040_custom_develop, RP2040_EXCHANGE_2MB
144 | build_flags =
145 | ${RP2040_custom_develop.build_flags}
146 | ; -D BOARD_SMARTMF_1TE_RP2040
147 | ; -D BOARD_MASIFI_PICO
148 | -D HF_SERIAL=Serial2
149 | -D BOARD_MASIFI_HFPM_DEVEL2
150 | ; -D BOARD_MASIFI_V40
151 |
152 | [env:develop_REG1_BASE_IP]
153 | extends = RP2040_UPLOAD_USB, RP2040_custom_develop, RP2040_EXCHANGE_16MB
154 | build_flags =
155 | ${RP2040_EXCHANGE_16MB.build_flags}
156 | ${RP2040_custom_develop.build_flags}
157 | ${KNX_IP.build_flags}
158 | -D OKNXHW_REG1_BASE_IP
159 | ; -D KNX_IP_GENERIC
160 | -D KNX_IP_W5500
161 | -D KNX_LOG_IP
162 |
163 | [env:upload_USB_SAMD]
164 | extends = UPLOAD_USB_SAMD, env:develop_SAMD
165 |
166 | [env:upload_JLINK_SAMD]
167 | extends = UPLOAD_JLINK, env:develop_SAMD
168 |
169 | [env:upload_USB_RP2040]
170 | extends = UPLOAD_USB_RP2040, env:develop_RP2040
171 |
172 | [env:upload_JLINK_RP2040]
173 | extends = UPLOAD_JLINK, env:develop_RP2040
174 |
175 |
176 | ; Releases
177 | [env:release_Sensormodul_Breakout_RP2040]
178 | extends = RP2040_custom_releases_TP_2MB
179 | build_flags =
180 | ${RP2040_custom_releases_TP_2MB.build_flags}
181 | -D BOARD_MASIFI_SENSOR_BREAKOUT
182 |
183 | [env:release_Sensormodul_v31_SAMD]
184 | extends = SAMD_custom_releases
185 | build_flags =
186 | ${SAMD_custom_releases.build_flags}
187 | -D BOARD_MASIFI_V31
188 |
189 | [env:release_Sensormodul_v30_SAMD]
190 | extends = SAMD_custom_releases
191 | build_flags =
192 | ${SAMD_custom_releases.build_flags}
193 | -D BOARD_MASIFI_V3
194 |
195 | [env:release_Sensormodul_v40_RP2040]
196 | extends = RP2040_custom_releases_TP_16MB
197 | build_flags =
198 | ${RP2040_custom_releases_TP_16MB.build_flags}
199 | -D BOARD_MASIFI_V40
200 |
201 | [env:release_PiPico_BCU_Connector]
202 | extends = RP2040_custom_releases_TP_2MB
203 | build_flags =
204 | ${RP2040_custom_releases_TP_2MB.build_flags}
205 | -D DEVICE_PIPICO_BCU_CONNECTOR
206 |
207 | [env:release_1TE_RP2040_SmartMF]
208 | extends = RP2040_custom_releases_TP_16MB
209 | build_flags =
210 | ${RP2040_custom_releases_TP_16MB.build_flags}
211 | -D BOARD_SMARTMF_1TE_RP2040
212 |
213 | [env:release_OpenKNX_REG1_BASE_V0]
214 | extends = RP2040_custom_releases_TP_16MB
215 | build_flags =
216 | ${RP2040_custom_releases_TP_16MB.build_flags}
217 | -D DEVICE_REG1_BASE_V0
218 |
219 | [env:release_OpenKNX_REG1_BASE_V1]
220 | extends = RP2040_custom_releases_TP_16MB
221 | build_flags =
222 | ${RP2040_custom_releases_TP_16MB.build_flags}
223 | -D DEVICE_REG1_BASE_V1
224 |
225 | [env:release_RP2040_devel]
226 | extends = RP2040_custom_releases_TP_2MB
227 | build_flags =
228 | ${RP2040_custom_releases_TP_2MB.build_flags}
229 | -D HF_SERIAL=Serial2
230 | -D BOARD_MASIFI_HFPM_DEVEL
231 |
232 | [env:release_RealPresence]
233 | extends = RP2040_custom_releases_TP_16MB
234 | build_flags =
235 | ${RP2040_custom_releases_TP_16MB.build_flags}
236 | -D HF_SERIAL=Serial2
237 | -D BOARD_MASIFI_HFPM_DEVEL2
238 |
239 | [env:release_RealPresence_v20]
240 | extends = RP2040_custom_releases_TP_16MB
241 | build_flags =
242 | ${RP2040_custom_releases_TP_16MB.build_flags}
243 | -D HF_SERIAL=Serial2
244 | -D BOARD_MASIFI_HFPM_V20
245 |
246 | [env:release_Fingerprint_v13_RP2040]
247 | extends = RP2040_custom_develop, RP2040_16MB
248 | build_flags =
249 | ${RP2040_custom_releases.build_flags}
250 | -D BOARD_ABTOOLS_FINGERPRINT_V13
251 |
252 | [env:release_REG1_BASE_IP]
253 | extends = RP2040_UPLOAD_USB, RP2040_custom_releases_IP, RP2040_EXCHANGE_16MB
254 | build_flags =
255 | ${RP2040_EXCHANGE_16MB.build_flags}
256 | ${RP2040_custom_releases_IP.build_flags}
257 | -D DEVICE_REG1_BASE_IP
258 | ; -D KNX_IP_WIFI
259 | -D KNX_IP_LAN
260 | -D CONFIG_ETH_ENABLED
261 |
262 |
263 |
--------------------------------------------------------------------------------
/platformio.ini:
--------------------------------------------------------------------------------
1 | ;PlatformIO Project Configuration File
2 | ;
3 | ; Build options: build flags, source filter
4 | ; Upload options: custom upload port, speed and extra flags
5 | ; Library options: dependencies, extra library storages
6 | ; Advanced options: extra scripting
7 | ;
8 | ; Please visit documentation for the other options and examples
9 | ; https://docs.platformio.org/page/projectconf.html
10 |
11 | [platformio]
12 | ; default_envs = build
13 | libdeps_dir = /tmp/libdeps
14 | extra_configs =
15 | lib/OGM-Common/platformio.base.ini
16 | lib/OGM-Common/platformio.rp2040.ini
17 | lib/OGM-Common/platformio.samd.ini
18 | lib/OFM-UsbExchange/platformio.exchange.ini
19 | platformio.custom.ini
20 |
--------------------------------------------------------------------------------
/restore/Restore-Dependencies-Branch.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | Open ■
3 | ┬────┴ Restore-Dependencies
4 | ■ KNX 2024 OpenKNX - Erkan Çolak
5 |
6 | FILEPATH: restore/Restore-Dependencies-Branch.ps1
7 | #>
8 |
9 | param(
10 | # Set the Git checkout mode
11 | [ValidateSet("Branch", "Hash")]
12 | [string]$GitCheckoutMode = "Branch", # Default is Branch
13 |
14 | # Force the script to recreate symbolic links
15 | [switch]$ForceRecreateSymLinks = $true, # Default is $true
16 |
17 | # "dependencies.txt" file
18 | [string]$DependenciesFile = "dependencies.txt", # Default is "dependencies.txt"
19 |
20 | # Check for privileges (Windows only)
21 | [switch]$CheckForDeveloperMode = $false, # Default is $false
22 | [switch]$CheckForSymbolicLinkPermissions = $true, # Default is $true
23 | [switch]$CheckForAdminOnly = $false, # Default is $false
24 |
25 | # Set the Write-Host message behavior
26 | [switch]$Verbose = $false, # Default is $false
27 | [switch]$DebugMsg = $false # Default is $false
28 | )
29 |
30 | # Construct the command to invoke Restore-Dependencies.ps1
31 | $command = ".\Restore-Dependencies.ps1" +
32 | " -GitCheckoutMode $GitCheckoutMode" +
33 | " -ForceRecreateSymLinks:`$$ForceRecreateSymLinks" +
34 | " -DependenciesFile $DependenciesFile" +
35 | " -CheckForDeveloperMode:`$$CheckForDeveloperMode" +
36 | " -CheckForSymbolicLinkPermissions:`$$CheckForSymbolicLinkPermissions" +
37 | " -CheckForAdminOnly:`$$CheckForAdminOnly" +
38 | " -Verbose:`$$Verbose" +
39 | " -DebugMsg:`$$DebugMsg"
40 |
41 | # Execute the command
42 | Invoke-Expression $command
43 |
--------------------------------------------------------------------------------
/restore/Restore-Dependencies.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | Open ■
3 | ┬────┴ Restore-Dependencies
4 | ■ KNX 2024 OpenKNX - Erkan Çolak
5 |
6 | FILEPATH: restore/Restore-Dependencies.ps1
7 |
8 | This script is designed to automate the process of managing dependencies in a software project, making it easier to
9 | set up the project environment for development or deployment. It is structured in a way that allows for easy
10 | modification and extension, and it can be used in a variety of different environments due to its platform-independent design.
11 |
12 | Here's a high-level description of what it does:
13 | 1. The script starts by checking the operating system it's running on. It sets up several variables
14 | (IsWindows, IsLinux, IsMacOs) based on the operating system type. This information is used later in
15 | the script to handle OS-specific operations. The script is designed to run platform-independently.
16 |
17 | 2. It assumes that the script is started in the project's 'restore' directory. It suggests going one
18 | directory back to get to the project directory.
19 |
20 | 3. The script checks if a specific dependencies file (dependencies.txt) exists. If the file exists,
21 | it reads the content of the file into a variable. This file contains information about the dependencies
22 | that need to be cloned from git.
23 |
24 | 4. For each dependency listed in the dependencies.txt file, the script performs a git clone operation
25 | to download the dependency into a directory outside of the current project. It also checks out the
26 | correct branch for each dependency as specified in the dependencies.txt file.
27 |
28 | 5. The script checks if a 'lib' directory exists. If the directory does not exist, it creates the directory
29 | and outputs a message to the user. It then gets the project files from the 'lib' directory.
30 |
31 | 6. The script creates symbolic links for the cloned dependencies in the 'lib' subfolder. This allows the
32 | project to reference the dependencies as if they were part of the project's own source code.
33 |
34 | 7. The script checks if each project file exists. If a project file does not exist, it outputs a message to the user.
35 |
36 | 8. Many core functions of the script are modularized and can be used outside of this script, providing flexibility and reusability.
37 | #>
38 |
39 | # Optional Input Parameters
40 | param(
41 | # Set the Git checkout mode
42 | [ValidateSet("Branch", "Hash")]
43 | [string]$GitCheckoutMode= "Hash", # Branch or Hash. Default is Hash
44 |
45 | # Force the script to recreate symbolic links
46 | [switch]$ForceRecreateSymLinks= $true, # Default is $true
47 |
48 | # "dependencies.txt" file
49 | [string]$DependenciesFile= "dependencies.txt", # Default is "dependencies.txt"
50 |
51 | # Check for privileges (Windows only)
52 | [switch]$CheckForDeveloperMode= $false, # Default is $false
53 | [switch]$CheckForSymbolicLinkPermissions= $true, # Default is $true
54 | [switch]$CheckForAdminOnly= $false, # Default is $false
55 |
56 | # Set the Write-Host message behavior
57 | [switch]$Verbose= $false, # Default is $false
58 | [switch]$DebugMsg= $false # Default is $false
59 | )
60 |
61 | # Global Variables
62 | # If the user has no permissions to create symbolic links with 'New-Item', the script will try to use mklink to create symbolic links.
63 |
64 | #Those variables are used to check if the script is running on Windows. Only on Windows we can use mklink to create symbolic links.
65 | # If $Auto_Use_mklink_To_Create_SymLinks is $true, the script will automatically use mklink to create symbolic links.
66 | $Auto_Use_mklink_To_Create_SymLinks = $false # Default is $false
67 | # Ignore the permissions to create symbolic links with 'New-Item' and use mklink to create symbolic links.
68 | $Force_Use_mklink_To_Create_SymLinks = $true # Default is $true. If $Auto_Use_mklink_To_Create_SymLinks is $true, this variable is ignored.
69 |
70 |
71 |
72 | function Test-Administrator {
73 | return (([Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole('Administrators')).If($true, $false)
74 | }
75 |
76 | function Test-DeveloperMode {
77 | try {
78 | # Check if the registry key exists
79 | $isDeveloperMode = (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -ErrorAction Stop) -eq 1
80 | return $isDeveloperMode
81 | } catch {
82 | Write-Host -ForegroundColor Red "Error: $_"
83 | return $false
84 | }
85 | }
86 |
87 | function Test-SymbolicLinkPermission {
88 | # Clear the error variable
89 | $Error.Clear()
90 | $bRet = $true
91 | # Create a test symbolic link and target
92 | $testLinkPath = Join-Path ([System.IO.Path]::GetTempPath()) "test_symlink"
93 | $testTargetPath = Join-Path ([System.IO.Path]::GetTempPath()) "test_target"
94 | # Create the test target file
95 | $null = New-Item -ItemType File -Path $testTargetPath -Force
96 | $null = New-Item -ItemType SymbolicLink -Path $testLinkPath -Target $testTargetPath -Force -ErrorAction SilentlyContinue
97 | # Check last error message to see if the symbolic link was created successfully
98 | if ($Error) {
99 | # There was an error, so check the error message. If the error message is "UnauthorizedAccess", the user does not have permissions to create symbolic links
100 | $bRet = $false
101 | # Any other error message is unexpected and should be investigated. The script will return $false also in this case.
102 | # If the symbolic link was not created successfully, check the error message
103 | foreach ($err in $Error) {
104 | # Check the FullyQualifiedErrorId property if it contains the "UnauthorizedAccess" error
105 | if ($DebugMsg) {
106 | Write-Host -ForegroundColor DarkRed "- Error Message: $($err.Exception.Message)"
107 | Write-Host -ForegroundColor DarkRed "- Category : $($err.CategoryInfo.Category)"
108 | Write-Host -ForegroundColor DarkRed "- TargetName: $($err.CategoryInfo.TargetName)"
109 | Write-Host -ForegroundColor DarkRed "- ScriptName: $($err.InvocationInfo.ScriptName)"
110 | Write-Host -ForegroundColor DarkRed "- ErrorId: $($err.FullyQualifiedErrorId)"
111 | } else {
112 | if ($Verbose) {
113 | Write-Host -ForegroundColor DarkRed "- Error Message: $($err.Exception.Message)"
114 | Write-Host -ForegroundColor DarkRed "- ErrorId: $($err.FullyQualifiedErrorId)"
115 | }
116 | }
117 | if ($err.FullyQualifiedErrorId -eq "UnauthorizedAccess" -or
118 | $err.FullyQualifiedErrorId -eq "NewItemSymbolicLinkElevationRequired,Microsoft.PowerShell.Commands.NewItemCommand") {
119 | if ($Verbose) { Write-Host -ForegroundColor Red "- Symbolic link creation requires elevated privileges." ([Char]0x2717) }
120 | Write-Host -ForegroundColor Red "- User $($env:USERNAME) has not permissions to create symbolic links with 'New-Item'." ([Char]0x2717)
121 | break
122 | }
123 | }
124 | } else {
125 | # There was no error, so the symbolic link was created successfully
126 | if ($Verbose) { Write-Host -ForegroundColor Green "- TestSymbolic link created successfully." }
127 | Write-Host -ForegroundColor Green "- User $($env:USERNAME) has permissions to create symbolic links with New-Item." ([Char]0x221A)
128 | }
129 | # Clean up the test symbolic link and target
130 | Remove-Item -Path $testLinkPath -ErrorAction SilentlyContinue
131 | Remove-Item -Path $testTargetPath -ErrorAction SilentlyContinue
132 | return $bRet
133 | }
134 |
135 | function OpenKNX_ShowLogo($AddCustomText = $null) {
136 | Write-Host ""
137 | Write-Host "Open " -NoNewline
138 | #Write-Host "■" -ForegroundColor Green
139 | Write-Host "$( [char]::ConvertFromUtf32(0x25A0) )" -ForegroundColor Green
140 | $unicodeString = "$( [char]::ConvertFromUtf32(0x252C) )$( [char]::ConvertFromUtf32(0x2500) )$( [char]::ConvertFromUtf32(0x2500) )$( [char]::ConvertFromUtf32(0x2500) )$( [char]::ConvertFromUtf32(0x2500) )$( [char]::ConvertFromUtf32(0x2534) ) "
141 |
142 | if ($AddCustomText) {
143 | #Write-Host "┬────┴ $AddCustomText" -ForegroundColor Green
144 | Write-Host "$($unicodeString) $($AddCustomText)" -ForegroundColor Green
145 | }
146 | else {
147 | #Write-Host "┬────┴" -ForegroundColor Green
148 | Write-Host "$($unicodeString)" -ForegroundColor Green
149 | }
150 |
151 | #Write-Host "■" -NoNewline -ForegroundColor Green
152 | Write-Host "$( [char]::ConvertFromUtf32(0x25A0) )" -NoNewline -ForegroundColor Green
153 | Write-Host " KNX"
154 | Write-Host ""
155 | }
156 |
157 | function CheckForPrivileges {
158 | if ($IsWinEnv ) {
159 | if($CheckForAdminOnly) {
160 | if($Verbose) { Write-Host -ForegroundColor Yellow "- Checking if we are in Administrator privileges" }
161 | if( -not (Test-Administrator) ) {
162 | Write-Host -ForegroundColor Red "ERROR: Restore-Dependencies requires Administrator privileges to run!"
163 | Write-Host -ForegroundColor Red "- Please run the script again with Administrator privileges."
164 | exit 1
165 | } else { Write-Host -ForegroundColor Green "- The script is running with Administrator privileges." ([Char]0x221A) }
166 | }
167 | if($CheckForDeveloperMode) {
168 | if($Verbose) { Write-Host -ForegroundColor Yellow "- Checking if we are in Developer Mode" }
169 | if( -not (Test-DeveloperMode) ) {
170 | Write-Host -ForegroundColor Red "ERROR: Restore-Dependencies requires Developer Mode to run!"
171 | Write-Host -ForegroundColor Red "- Please run the script again with Developer Mode."
172 | Write-Host -ForegroundColor Red "- If you are using Windows `>10, you can enable Developer Mode by going to Settings `> Update `& Security `> For developers and selecting Developer mode."
173 | exit 1
174 | } else { Write-Host -ForegroundColor Green "- The script is running with Developer Mode." ([Char]0x221A) }
175 | }
176 | if(-not $Force_Use_mklink_To_Create_SymLinks -and $CheckForSymbolicLinkPermissions) {
177 | if($Verbose) { Write-Host -ForegroundColor Yellow "- Checking if we have permissions to create symbolic links" }
178 | if( -not (Test-SymbolicLinkPermission) ) {
179 | if($Auto_Use_mklink_To_Create_SymLinks) {
180 | $script:Force_Use_mklink_To_Create_SymLinks = $true
181 | Write-Host -ForegroundColor Yellow "- We have no permissions to create symbolic links with 'New-Item'. We will try to use mklink to create symbolic links."
182 | } else {
183 | Write-Host -ForegroundColor Red "ERROR: Restore-Dependencies requires permissions to create symbolic links to run!"
184 | Write-Host -ForegroundColor Red "- Please run the script again with Administrator privileges."
185 | exit 1
186 | }
187 | } else { Write-Host -ForegroundColor Green "- The script has permissions to create symbolic links." ([Char]0x221A) }
188 | } else { Write-Host -ForegroundColor Green "- We will use mklink to create symbolic links." ([Char]0x221A) }
189 | }
190 | }
191 |
192 | function CheckOS {
193 | # check on which os we are running
194 | # After check, the Os-Informations are availibe in the PS-Env.
195 | if ($PSVersionTable.PSVersion.Major -lt 6.0) {
196 | switch ($([System.Environment]::OSVersion.Platform)) {
197 | 'Win32NT' {
198 | New-Variable -Option Constant -Name IsWindows -Value $True -ErrorAction SilentlyContinue
199 | New-Variable -Option Constant -Name IsLinux -Value $false -ErrorAction SilentlyContinue
200 | New-Variable -Option Constant -Name IsMacOs -Value $false -ErrorAction SilentlyContinue
201 | }
202 | }
203 | }
204 | $script:IsLinuxEnv = (Get-Variable -Name "IsLinux" -ErrorAction Ignore) -and $IsLinux
205 | $script:IsMacOSEnv = (Get-Variable -Name "IsMacOS" -ErrorAction Ignore) -and $IsMacOS
206 | $script:IsWinEnv = !$IsLinuxEnv -and !$IsMacOSEnv
207 |
208 | $CurrentOS = switch($true) {
209 | $IsLinuxEnv { "Linux" }
210 | $IsMacOSEnv { "MacOS" }
211 | $IsWinEnv { "Windows" }
212 | default { "Unknown" }
213 | }
214 | $PSVersion = "$($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor).$($PSVersionTable.PSVersion.Patch)"
215 | if($true) { Write-Host -ForegroundColor Green "- We are on $CurrentOS Build Environment with PowerShell $PSVersion" ([Char]0x221A) }
216 | }
217 | function ProcessDependencies($DependenciesFile) {
218 | # Check if the file exists
219 | if (-not (Test-Path $DependenciesFile)) {
220 | Write-Host -ForegroundColor Red "The file $DependenciesFile does not exist."
221 | return $null
222 | }
223 |
224 | # Get the content of the file
225 | $dependencies = Get-Content $DependenciesFile
226 |
227 | # Process each line and filter out invalid ones
228 | $lineNumber = 0
229 | $dependedProjects = foreach ($line in $dependencies) {
230 | $lineNumber++
231 | if ($line -notmatch '^-------' -and -not $line.StartsWith('#')) {
232 | $parts = $line -split ' ', 4
233 | if ($parts.Count -lt 4) {
234 | if($Verbose) { Write-Host -ForegroundColor DarkYellow "Dependencies: Error on line ${lineNumber}: Line does not have the expected format and will be skipped: $line" }
235 | } else {
236 | $hash, $branch, $folders, $urlParts = $parts
237 | $folders = $folders -split '/'
238 | $urlParts = $urlParts -split '#'
239 | $url = $urlParts[0]
240 | $branch = if($urlParts.Count -gt 1) { $urlParts[1] } else { $branch }
241 | # Extract the project name from the URL
242 | $urlParts = $url -split '/'
243 | $projectNameWithExtension = $urlParts[-1]
244 | # Assuming the project name is the same as the repository name, and considering the possibility of a .git extension to fix a 'dot' in the project name.
245 | # Get the index of the last dot in the string (.git)
246 | $lastDotPosition = $projectNameWithExtension.LastIndexOf('.')
247 | # Check if a dot was found
248 | if ($lastDotPosition -ge 0) {
249 | # Extract the substring without the last dot
250 | $projectName = $projectNameWithExtension.Substring(0, $lastDotPosition)
251 | } else {
252 | # No dot found, use the entire string as the project name!
253 | $projectName = $projectNameWithExtension
254 | }
255 | # Create a custom object for the project
256 | [PSCustomObject]@{
257 | "Hash" = $hash
258 | "Branch" = $branch
259 | "Folder" = $folders
260 | "FolderCount" = $folders.Count
261 | "URL" = $url
262 | "ProjectName" = $projectName
263 | }
264 | }
265 | }
266 | }
267 | return $dependedProjects
268 | }
269 | function Get-ProjectFiles($subprojects) {
270 | # Initialize an empty array for the project files
271 | $projectFiles = @()
272 |
273 | # Loop through each subproject
274 | foreach ($subproject in $subprojects) {
275 | # Find and Get the project file
276 | $projectFile = $subproject | Select-Object BaseName
277 | if($Verbose) { Write-Host "- Get-ProjectFiles - Found existing project file: $($projectFile.BaseName)" -ForegroundColor Yellow }
278 |
279 | # Check if the file name is not "README" and is not empty
280 | if ($projectFile.BaseName -ne "README" -and ![string]::IsNullOrWhiteSpace($projectFile.BaseName)) {
281 | # Add the project file to the list
282 | $projectFiles += $projectFile
283 | }
284 | }
285 |
286 | # Return the list of project files
287 | return $projectFiles
288 | }
289 | function CloneRepository($projectFilesGitInfo, $dependedProjects, $CloneDir, $CloneModeHash= $false) {
290 | # Loop through each depended project
291 | if($CloneModeHash -and $Verbose) { Write-Host "- CloneRepository - Using hash" -ForegroundColor Green }
292 | foreach ($dependedProject in $dependedProjects) {
293 | # Initialize a flag to track if the project is found
294 | $hashMatch = $false
295 | $branchMatch = $false
296 |
297 | if($Verbose) { Write-Host "- CloneRepository - Check: '$($dependedProject.ProjectName)'" -ForegroundColor Green }
298 | # Loop through each project file's git information
299 | foreach ($projectFile in $projectFilesGitInfo) {
300 | # Check if projectFile contains valid data
301 | if (($null -ne $projectFile.BaseName -and $projectFile.BaseName -ne "") -and
302 | ($null -ne $dependedProject.ProjectName -and $dependedProject.ProjectName -ne "") -and
303 | ( $projectFile.BaseName -match $dependedProject.ProjectName) )
304 | {
305 | if($Verbose) { Write-Host "- CloneRepository - Found: '$($dependedProject.ProjectName)' - '$($projectFile.Path)'" -ForegroundColor Green }
306 | #Compare the branches and hashes
307 | # Check if the branches match
308 | if (($null -ne $projectFile.TargetBranch -and $projectFile.TargetBranch -ne "") -and
309 | $projectFile.TargetBranch -eq $dependedProject.Branch)
310 | {
311 | # If the branches match, set the flag to true
312 | $branchMatch = $true
313 | if($Verbose) { Write-Host "- CloneRepository - Branch: '$($dependedProject.ProjectName)' - Both matches to ($($projectFile.TargetBranch))" -ForegroundColor Green }
314 | }
315 | # Check if the hashes match
316 | if (($null -ne $projectFile.TargetShortHash -and $null -ne $dependedProject.Hash) -and
317 | $projectFile.TargetShortHash -match $dependedProject.Hash)
318 | {
319 | # If the project is found, set the flag to true and break the loop
320 | $hashMatch = $true
321 | if($Verbose) { Write-Host "- CloneRepository - Hash: '$($dependedProject.ProjectName)' - Both matches to ($($projectFile.TargetShortHash))" -ForegroundColor Green }
322 | }
323 | if($branchMatch -and $hashMatch) {
324 | if($Verbose) { Write-Host "- CloneRepository - Found: "$dependedProject.ProjectName" - "$projectFile.Path -ForegroundColor Green }
325 | if($Verbose) { Write-Host "- CloneRepository - Branches and Hashes matching: '$($dependedProject.ProjectName)'" -ForegroundColor Green }
326 | break
327 | }
328 | break
329 | }
330 | }
331 |
332 | # If the project is not found, clone the repository
333 | if (-not $branchMatch -and -not $hashMatch) {
334 | # Create the Git clone URL with the URL and the Hash from the dependency
335 | $GitClone = ($dependedProject.URL).ToString()
336 | if($Verbose) { Write-Host "- CloneRepository - '$($dependedProject.ProjectName)' not Found. Target does not exist." -ForegroundColor DarkYellow }
337 | # Try to clone the repository
338 | try {
339 | if($IsWinEnv){
340 | $CloneTarget = Join-Path $CloneDir $dependedProject.ProjectName
341 | } else {
342 | $CloneTarget = Join-Path -Path $CloneDir -ChildPath $dependedProject.ProjectName
343 | }
344 | if($Verbose) { Write-Host "- CloneRepository - CloneTarget: " $CloneTarget -ForegroundColor Green }
345 | if($Verbose) { Write-Host "- CloneRepository - Cloning '$($dependedProject.ProjectName)': '$GitClone' to '$CloneTarget'" -ForegroundColor Yellow }
346 |
347 | $DoClone= $true
348 | # Check if the folder already exists
349 | if (Test-Path $CloneTarget -PathType Container) {
350 | # Check if it's a Git repository (contains .git directory)
351 | if (Test-Path (Join-Path $CloneTarget ".git") -PathType Container) {
352 | if($Verbose) { Write-Host "- CloneRepository - Cloning: The target directory is already a Git repository." -ForegroundColor Yellow }
353 | $DoClone= $false
354 | } else {
355 | # The folder exists, but it's not a Git repository, so rename it
356 | if($true) { Write-Host "- CloneRepository - The directory already exists, but it's not a Git repository. Renaming..." -ForegroundColor Yellow }
357 | Rename-Item -Path $CloneTarget -NewName "${CloneTarget}_backup" -Force
358 | }
359 | }
360 | if($DoClone) {
361 | #Invoke-RestMethod -Uri $GitClone -Method Head -ErrorAction Stop;
362 | if($Verbose) { $GitCmd= "git clone '$($GitClone)' '$($CloneTarget.ToString())'"
363 | } else { $GitCmd= "git clone -q '$($GitClone)' '$($CloneTarget.ToString())'" }
364 | $exitCode = Invoke-Expression $($GitCmd+';$?')
365 | if (!$exitCode) {
366 | Write-Host "- CloneRepository - Failed Cloning "$dependedProject.ProjectName": '$GitClone' to '$CloneTarget' "([Char]0x2717) -ForegroundColor Red
367 | # exit 1 expected, but error-handling should be consistent
368 | # TODO: extend restore script error-handling and check for possible side-effects
369 | }
370 | #git clone -q '$GitClone' '$CloneTarget.ToString()'
371 | }
372 |
373 | if($true) { Write-Host "- CloneRepository - Cloned "$dependedProject.ProjectName": '$GitClone' to '$CloneTarget' "([Char]0x221A) -ForegroundColor Green }
374 | }
375 | # If the repository does not exist, catch the error
376 | catch {
377 | if($Verbose) { Write-Host "CloneRepository - Cloning Error: "$dependedProject.ProjectName"- Repository does not exist: "$GitClone -ForegroundColor DarkYellow }
378 | }
379 | }
380 | # If the project is found, check out to the specific branch
381 | if(-not $hashMatch -or -not $branchMatch)
382 | {
383 | if($Verbose) { Write-Host "- CloneRepository - Found: "$dependedProject.ProjectName" - "$dependedProject.URL -ForegroundColor Green }
384 |
385 | # If the repository already exists, switch to the corresponding branch
386 | $checkoutTarget = if ($CloneModeHash) { "Hash" } else { "Branch" }
387 | if($Verbose) { Write-Host "- CloneRepository -"$dependedProject.ProjectName"- Repository already exists. Checking out to the $($checkoutTarget)." -ForegroundColor Yellow }
388 |
389 | try {
390 | # Check the installed Git version
391 | if($IsWinEnv){
392 | $CloneTarget = Join-Path $CloneDir $dependedProject.ProjectName
393 | $GitDir = Join-Path $CloneTarget ".git"
394 | } else {
395 | $CloneTarget = Join-Path -Path $CloneDir -ChildPath $dependedProject.ProjectName
396 | $GitDir = Join-Path -Path $CloneTarget -ChildPath ".git"
397 | }
398 |
399 | if($Verbose) { Write-Host "- CloneRepository - $($checkoutTarget) - GitDir: "$GitDir -ForegroundColor Yellow }
400 | $GitCmd = "git --git-dir=""$($GitDir)"" --work-tree=""$($CloneTarget.ToString())"""
401 | if($Verbose) { Write-Host "- CloneRepository - $($checkoutTarget) - GitCmd: "$GitCmd -ForegroundColor Yellow }
402 |
403 | if($CloneModeHash) {
404 | $CheckOutTarget = $($dependedProject.Hash) # Optional: If the CloneModeHash is true, use the Hash
405 | } else {
406 | $CheckOutTarget = $($dependedProject.Branch) # If the CloneModeHash is false (default), use the Branch
407 | }
408 |
409 | if ((& git --version) -ge 'git version 2.23' -and $CloneModeHash -eq $false ) {
410 | $CheckOutMethod = "switch" # If the Git version is 2.23 or higher, use the 'switch' command
411 | } else {
412 | $CheckOutMethod = "checkout" # If the Git version is 2.23 or higher, use the 'switch' command
413 | }
414 |
415 | # Let's do the git checkout
416 | if($Verbose) {
417 | Invoke-Expression "$GitCmd fetch --all"
418 | Invoke-Expression "$GitCmd $CheckOutMethod $($CheckOutTarget)"
419 | } else {
420 | Invoke-Expression "$GitCmd fetch --all -q" | Out-Null
421 | Invoke-Expression "$GitCmd $CheckOutMethod $($CheckOutTarget) -q" | Out-Null
422 | }
423 |
424 | if($true) {
425 | $checkoutTarget = if ($CloneModeHash) { "Hash '$($dependedProject.Hash)'" } else { "Branch '$($dependedProject.Branch)'" }
426 | Write-Host "- CloneRepository - '$($dependedProject.ProjectName)' $($checkoutTarget) Checked out."([Char]0x221A) -ForegroundColor Green
427 | }
428 | }
429 | # If cannot check out to the branch, catch the error
430 | catch {
431 | if($Verbose) {
432 | $checkoutTarget = if ($CloneModeHash) { "Hash '$($dependedProject.Hash)'" } else { "Branch '$($dependedProject.Branch)'" }
433 | Write-Host "- CloneRepository - $($dependedProject.ProjectName) - Checkout Error! Cannot checkout $($checkoutTarget)."([Char]0x2717) -ForegroundColor Red }
434 | }
435 | }
436 |
437 | # Repository exists and the correct branch or hash is already checked out
438 | # if freshly cloned or checkout, no action needed but when switched or correct branch was set, we need to pull last changes
439 | # if CloneMode Branch, check if the branch is up-to-date
440 | if (-not $CloneModeHash)
441 | {
442 | if($Verbose) { Write-Host "- CloneRepository - Pull: "$dependedProject.ProjectName" - "$dependedProject.URL -ForegroundColor Green }
443 | try{
444 | if($IsWinEnv){
445 | $CloneTarget = Join-Path $CloneDir $dependedProject.ProjectName
446 | $GitDir = Join-Path $CloneTarget ".git"
447 | } else {
448 | $CloneTarget = Join-Path -Path $CloneDir -ChildPath $dependedProject.ProjectName
449 | $GitDir = Join-Path -Path $CloneTarget -ChildPath ".git"
450 | }
451 |
452 | $GitCmd = "git --git-dir=""$($GitDir)"" --work-tree=""$($CloneTarget.ToString())"""
453 |
454 | if($Verbose) {
455 | Invoke-Expression "$GitCmd pull --ff-only"
456 | } else {
457 | Invoke-Expression "$GitCmd pull --ff-only -q" | Out-Null
458 | }
459 | }
460 | catch {
461 | if($Verbose) {
462 | Write-Host "- CloneRepository - $($dependedProject.ProjectName) - Pull Error!"([Char]0x2717) -ForegroundColor Red }
463 | }
464 | }
465 | }
466 | }
467 | function Get-GitInfo($path) {
468 | if ($IsWinEnv) {
469 | $TargetDir= (Join-Path $path ".git").ToString()
470 | } else {
471 | $TargetDir= (Join-Path -Path $path -ChildPath ".git").ToString()
472 | }
473 | if($Verbose) { Write-Host "GitInfo - TargetDir: "$TargetDir -ForegroundColor Yellow }
474 | if (Test-Path $TargetDir) {
475 | $ShortCommitHash = "git --git-dir ""$($TargetDir)"" log -1 --pretty=format:'%h'"
476 | $LongCommitHash = "git --git-dir ""$($TargetDir)"" log -1 --pretty=format:'%H'"
477 | $RemoteOriginURL = "git --git-dir ""$($TargetDir)"" config --get remote.origin.url"
478 |
479 | if($Verbose) { $ShortCommitHash= Invoke-Expression $ShortCommitHash } else { $ShortCommitHash= Invoke-Expression $ShortCommitHash | Out-Null }
480 | if($Verbose) { $LongCommitHash= Invoke-Expression $LongCommitHash } else { $LongCommitHash= Invoke-Expression $LongCommitHash | Out-Null }
481 | if($Verbose) { $RemoteOriginURL = Invoke-Expression $RemoteOriginURL } else { $RemoteOriginURL = Invoke-Expression $RemoteOriginURL | Out-Null }
482 |
483 | if($Verbose) { Write-Host "GitInfo - Found git repo in directory: $path" -ForegroundColor Green }
484 |
485 | return @{
486 | ShortHash = $ShortCommitHash
487 | LongHash = $LongCommitHash
488 | RemoteURL = $RemoteOriginURL
489 | }
490 | }
491 | else {
492 | if($Verbose) { Write-Host "GitInfo - Not a git repo. Ignoring directory: $path" -ForegroundColor DarkYellow }
493 | return $null
494 | }
495 | }
496 | function CreateGitDependencyInfo($projectDir, $dependedProjects) {
497 | # Check if project files or project directory is null or empty
498 | if ( -not $projectDir -or -not $dependedProjects) {
499 | if($Verbose) { Write-Host "CreateGitDependencyInfo - Project files or project directory is null or empty." -ForegroundColor DarkYellow }
500 | return @()
501 | }
502 | # Iterate over each project file
503 | $projectDependedList = $dependedProjects | ForEach-Object {
504 | if( $IsWinEnv ){
505 | $fullPath = Join-Path $projectDir $_.Folder[0]
506 | $fullPath = Join-Path $fullPath $_.Folder[1]
507 | $TargetPath = (Resolve-Path (Join-Path $projectDir '..') ).Path
508 | $TargetPath = (Join-Path $TargetPath $_.ProjectName).ToString()
509 | }
510 | else {
511 | $fullPath = Join-Path -Path $projectDir -ChildPath $_.Folder[0] -AdditionalChildPath $_.Folder[1]
512 | $TargetPath = (Join-Path -Path ((Resolve-Path (Join-Path $projectDir '..')).Path) -ChildPath $_.ProjectName).ToString()
513 | }
514 |
515 | # Get Git information for the current and target paths
516 | $TargetBranch = ""
517 | if (Test-Path (Join-Path $TargetPath ".git")) {
518 | if ($Verbose) { Write-Host "CreateGitDependencyInfo - GitInfo for target project: $($_.ProjectName)" -ForegroundColor Yellow }
519 | $gitInfo = Get-GitInfo $fullPath
520 | $targetGitInfo = Get-GitInfo $TargetPath
521 | if ($Verbose) { Write-Host "CreateGitDependencyInfo - getting the current branch of project: $($_.ProjectName)" -ForegroundColor Yellow }
522 | try {
523 | $gitDir = Join-Path -Path $TargetPath -ChildPath ".git"
524 | $TargetBranch = & git --git-dir $gitDir branch --show-current
525 | } catch {
526 | Write-Host "Failed to get the current branch of project: $($_.ProjectName)" -ForegroundColor Red
527 | }
528 | } else {
529 | if ($Verbose) { Write-Host "CreateGitDependencyInfo - Target project: $($_.ProjectName) is not a git repo." -ForegroundColor DarkYellow }
530 | }
531 |
532 | # Create a new PSObject with the git information and return it
533 | New-Object PSObject -Property @{
534 | BaseName = $_.ProjectName
535 | Path = $fullPath
536 | Branch = $_.Branch
537 | ShortHash = $_.Hash
538 | LongHash = $gitInfo.LongHash
539 | RemoteURL = $_.URL
540 | TargetPath = $TargetPath
541 | TargetBranch = $TargetBranch
542 | TargetShortHash = $targetGitInfo.ShortHash
543 | TargetLongHash = $targetGitInfo.LongHash
544 | TargetRemoteURL = $targetGitInfo.RemoteURL
545 | }
546 | }
547 | return $projectDependedList
548 | }
549 | function CreateSymbolicLink ($projectDir, $projectFiles) {
550 |
551 | # Check if projectDir and projectFiles are not empty
552 | if (-not $projectDir -or -not $projectFiles) {
553 | if($Verbose) { Write-Host "- CreateSymbolicLink - Project directory or project files are empty." -ForegroundColor DarkYellow }
554 | return
555 | }
556 | foreach ($projectFile in $projectFiles) {
557 | $CreateSymLink = $true
558 |
559 | # Test if if a symbolic link exists
560 | if($Verbose) { Write-Host "- CreateSymbolicLink - Symbolic link test: $($projectFile.Path)" -ForegroundColor Yellow }
561 | if ($null -ne $projectFile.Path -and $projectFile.Path -ne '' -and (Test-Path $projectFile.Path)) {
562 | if ((Get-Item $projectFile.Path).Attributes.ToString().Contains("ReparsePoint")) {
563 | # Seems that there is a valid link. Now lets get the linked Target of it
564 | $targetPath = (Get-Item $projectFile.Path)
565 | if($DebugMsg) { write-output $targetPath }
566 |
567 | # Get the target of the symbolic link
568 | if($IsMacOS -or $IsLinux) { $symlink = $targetPath.target
569 | } else { $symlink = $targetPath.target[0] }
570 |
571 | if($Verbose) { Write-Host "- CreateSymbolicLink - Found Symbolic Link: $($symlink)"-ForegroundColor DarkYellow }
572 |
573 | # Now, lets create target link path
574 | $linkTarget = Join-Path $(Join-Path ".." "..") $projectFile.BaseName.ToString()
575 |
576 | # Check if we are on Windows and if we should use mklink to create the symbolic link
577 | if($IsWinEnv -and -not $Force_Use_mklink_To_Create_SymLinks) {
578 | $LinkTarget = Join-Path $(Split-Path -Path $projectDir -Parent) $ProjectFile.BaseName
579 | }
580 |
581 | # If the link target is the same as the project file name, set the CreateSymLink flag to false
582 | if ($symlink.ToString() -eq $linkTarget.ToString()) {
583 | if(!$ForceRecreateSymLinks) { Write-Host "- CreateSymbolicLink - '$($ProjectFile.BaseName)'- A existing and valid symbolic link detected. Skip linking."([Char]0x221A) -ForegroundColor Green }
584 | $CreateSymLink = $false
585 | }
586 | }
587 | } else { if (-not ($null -ne $projectFile.Path -and $projectFile.Path -ne '')) { $CreateSymLink = $false } }
588 |
589 | if($CreateSymLink -or $ForceRecreateSymLinks ) {
590 | # Create a symlink
591 | if($Verbose) {
592 | $Message= "- CreateSymbolicLink - '$($ProjectFile.BaseName)' - No valid symbolic link detected. Creating new symbolic link."
593 | if( $ForceRecreateSymLinks ) {
594 | $Message= "- CreateSymbolicLink - '$($ProjectFile.BaseName)' - Forcing to create new symbolic links."
595 | }
596 | Write-Host $Message -ForegroundColor Yellow
597 | }
598 |
599 | # Remove a existing symbolic link first
600 | if( ($ForceRecreateSymLinks -or ($null -ne $projectFile.Path -and $projectFile.Path -ne '')) -and
601 | (Test-Path $projectFile.Path) ) {
602 |
603 | if($Verbose -and $ForceRecreateSymLinks ) {
604 | $Message= "- CreateSymbolicLink - '$($ProjectFile.BaseName)' - Forcing to remove existing symbolic link: '$($projectFile.Path)'"
605 | Write-Host $Message -ForegroundColor Yellow
606 | }
607 |
608 | Remove-Item -Path $projectFile.Path -Force -Recurse
609 | if (!$?) { exit 1 }
610 | }
611 | if($DebugMsg) { write-output $ProjectFile }
612 |
613 | # Create the symbolic link to link the project file to the target
614 | $linkTarget = $ProjectFile.BaseName
615 | $linkValue = Join-Path $(Join-Path ".." "..") $linkTarget
616 |
617 | #The create smbolic link command
618 | $CreateSymLinkCommand = "New-Item -ItemType SymbolicLink -Path '$($projectFile.Path)' -Target '$($linkValue)'"
619 |
620 | # Check if we are on Windows and if we should use mklink command to create the symbolic link
621 | if($IsWinEnv) {
622 | if ( $Force_Use_mklink_To_Create_SymLinks) {
623 | $CreateSymLinkCommand = "cmd /C mklink /D ""$($projectFile.Path)"" ""$($linkValue)"""
624 | } else {
625 | $TargetLinkDir = Split-Path -Path $projectDir -Parent
626 | $linkValue = Join-Path $TargetLinkDir $ProjectFile.BaseName
627 | $CreateSymLinkCommand = "New-Item -ItemType SymbolicLink -Path '$($projectFile.Path)' -Target '$($linkValue)'"
628 | }
629 | }
630 | if($Verbose) { Write-Host "- CreateSymbolicLink - '$($ProjectFile.BaseName)' - CreateSymLinkCommand: $($CreateSymLinkCommand)" -ForegroundColor Yellow }
631 |
632 | # Try to create the symbolic link
633 | try {
634 | if($Verbose) {
635 | Invoke-Expression $CreateSymLinkCommand
636 | } else {
637 | Invoke-Expression $CreateSymLinkCommand | Out-Null
638 | }
639 | Write-Host "- CreateSymbolicLink - Symbolic link created at $($projectFile.Path) with target $linkValue"([Char]0x221A) -ForegroundColor Green
640 | } catch {
641 | Write-Host "Error creating symbolic link: $_" -ForegroundColor Red
642 | exit 1
643 | }
644 | }
645 | }
646 | }
647 |
648 | # Beispielaufruf der Funktion
649 | Clear-Host
650 | OpenKNX_ShowLogo -AddCustomText "Restore Dependencies"
651 | Write-Host "Starting to Restore depended projects..." -ForegroundColor Green
652 |
653 | CheckOS # check on which os we are running
654 | CheckForPrivileges # check for privileges, which are needed to run the script
655 | if($Verbose) { Write-Host -ForegroundColor Yellow "- We assume, we start this script in the project's 'restore' directory." }
656 | #Start-Sleep 30
657 | Set-Location .. # Go one directory back, to get the project dir.
658 | # Now we are in the project directory
659 |
660 | # Call the ProcessDependencies function and store the result in the $dependedProjects variable
661 | Write-Host -ForegroundColor Yellow "- Reading the dependencies.txt file and processing each line."
662 | $dependedProjects = ProcessDependencies $DependenciesFile
663 | if( $dependedProjects.Count -eq 0) {
664 | Write-Host -ForegroundColor Red "- No dependencies found in dependencies.txt file. Please check the file."
665 | exit 1 # exit with error
666 | }
667 | if($DebugMsg) { $dependedProjects | ForEach-Object { Write-Output $_ } } # Output each depended project
668 |
669 | # Call the Get-ProjectFiles function with the content of the 'lib' directory and store the result in the $projectFiles variable
670 | # Check if the 'lib' directory exists
671 | Write-Host -ForegroundColor Yellow "- Checking if the 'lib' directory exists."
672 | if (Test-Path 'lib') {
673 | # Call the Get-ProjectFiles function with the content of the 'lib' directory and store the result in the $projectFiles variable
674 | $projectFiles = Get-ProjectFiles (Get-ChildItem 'lib')
675 | } else {
676 | Write-Host -ForegroundColor DarkYellow "- The 'lib' directory was not found and will be created in 3 seconds..."
677 | Start-Sleep -Seconds 3
678 | New-Item -ItemType Directory -Path 'lib' | Out-Null
679 | $projectFiles = Get-ProjectFiles (Get-ChildItem 'lib')
680 | }
681 |
682 | #Write-Host "Project files:"
683 | if($DebugMsg) { $projectFiles | ForEach-Object { Write-Output $_ } } # Output each project file
684 | # Get the current location and store it in the $projectDir variable
685 | $projectDir = Get-Location
686 |
687 | # Call the CreateGitDependencyInfo function with the current location and the project files and store the result in the $projectFilesGitInfo variable
688 | Write-Host -ForegroundColor Yellow "- Creating git dependency information for each project file."
689 | $projectFilesGitInfo = CreateGitDependencyInfo $projectDir $dependedProjects
690 | if($DebugMsg) { $projectFilesGitInfo | ForEach-Object { Write-Output $_ } }
691 | # Output each project file's git information
692 |
693 | # Call the CloneRepository function with the project files' git information and the depended projects
694 | Write-Host -ForegroundColor Yellow "- Checking, cloning and rebranching the git repositories for each dependency."
695 | $CloneDir = (Resolve-Path (Join-Path $projectDir '..')).Path
696 | if($Verbose) { Write-Host $CloneDir }
697 | CloneRepository $projectFilesGitInfo $dependedProjects $CloneDir ($GitCheckoutMode -eq "Hash")
698 |
699 |
700 | if($Verbose) { Write-Host -ForegroundColor Yellow "- Checking and creating symbolic links for each project file." }
701 | CreateSymbolicLink $projectDir $projectFilesGitInfo
702 | OpenKNX_ShowLogo -AddCustomText "Restore Dependencies: Done $([Char]0x221A)"
--------------------------------------------------------------------------------
/scripts/Build-IP.ps1:
--------------------------------------------------------------------------------
1 | # This script is just a template and has to be copied and modified per project
2 | # This script should be called from .vscode/tasks.json with
3 | #
4 | # scripts/Build-Release.ps1 - for Beta builds
5 | # scripts/Build-Release.ps1 Release - for Release builds
6 | #
7 | # {
8 | # "label": "Build-Release",
9 | # "type": "shell",
10 | # "command": "scripts/Build-Release.ps1 Release",
11 | # "args": [],
12 | # "problemMatcher": [],
13 | # "group": "test"
14 | # },
15 | # {
16 | # "label": "Build-Beta",
17 | # "type": "shell",
18 | # "command": "scripts/Build-Release.ps1 ",
19 | # "args": [],
20 | # "problemMatcher": [],
21 | # "group": "test"
22 | # }
23 |
24 |
25 |
26 | # set product names, allows mapping of (devel) name in Project to a more consistent name in release
27 | # $settings = scripts/OpenKNX-Build-Settings.ps1
28 |
29 | # execute generic pre-build steps
30 | lib/OGM-Common/scripts/setup/reusable/Build-Release-Preprocess.ps1 $args[0]
31 | if (!$?) { exit 1 }
32 |
33 | # build firmware based on generated headerfile
34 |
35 | # build firmware for REG1_BASE_IP
36 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_REG1_BASE_IP firmware-REG1-BASE-IP uf2
37 | if (!$?) { exit 1 }
38 |
39 | # # TEMPORARY: We use our own generic updload files for this version
40 | # Copy-Item scripts/data/* release/data -Force
41 |
42 | # execute generic post-build steps
43 | lib/OGM-Common/scripts/setup/reusable/Build-Release-Postprocess.ps1 $args[0]
44 | if (!$?) { exit 1 }
45 |
46 | if (Test-Path -Path release-collection -PathType Container) {
47 | Copy-Item release/* release-collection/
48 | }
49 |
--------------------------------------------------------------------------------
/scripts/Build-Release-Package.ps1:
--------------------------------------------------------------------------------
1 | # This script should be called from .vscode/tasks.json with
2 | # {
3 | # "label": "Build-Release-Package",
4 | # "type": "shell",
5 | # "command": "scripts/Build-Release-Package.ps1",
6 | # "args": [
7 | # ],
8 | # "problemMatcher": [],
9 | # "group": "test"
10 | # },
11 |
12 | # check and cleanup working dir
13 | if (Test-Path -Path release-package) {
14 | # clean working dir
15 | Remove-Item -Recurse release-package\*
16 | } else {
17 | New-Item -Path release-package -ItemType Directory | Out-Null
18 | }
19 |
20 | # list here all release variants you want to release as a package
21 | scripts/Build-Release.ps1 Big
22 | if (!$?) { exit 1 }
23 | Copy-Item release/* release-package
24 |
25 | # scripts/Build-Release.ps1 Release
26 | # if (!$?) { exit 1 }
27 | # Copy-Item release/* release-package
28 |
29 | scripts/Build-IP.ps1 IP
30 | if (!$?) { exit 1 }
31 | Copy-Item release/* release-package
32 |
33 | Write-Host "Release package sucessfully created!"
--------------------------------------------------------------------------------
/scripts/Build-Release.ps1:
--------------------------------------------------------------------------------
1 | # This script is just a template and has to be copied and modified per project
2 | # This script should be called from .vscode/tasks.json with
3 | #
4 | # scripts/Build-Release.ps1 - for Beta builds
5 | # scripts/Build-Release.ps1 Release - for Release builds
6 | #
7 | # {
8 | # "label": "Build-Release",
9 | # "type": "shell",
10 | # "command": "scripts/Build-Release.ps1 Release",
11 | # "args": [],
12 | # "problemMatcher": [],
13 | # "group": "test"
14 | # },
15 | # {
16 | # "label": "Build-Beta",
17 | # "type": "shell",
18 | # "command": "scripts/Build-Release.ps1 ",
19 | # "args": [],
20 | # "problemMatcher": [],
21 | # "group": "test"
22 | # }
23 |
24 | $releaseIndication = $args[0]
25 |
26 | # set product names, allows mapping of (devel) name in Project to a more consistent name in release
27 | # $settings = scripts/OpenKNX-Build-Settings.ps1
28 |
29 | # execute generic pre-build steps
30 | lib/OGM-Common/scripts/setup/reusable/Build-Release-Preprocess.ps1 $args[0]
31 | if (!$?) { exit 1 }
32 |
33 | if (Test-Path -Path scripts/data -PathType Container) {
34 | Copy-Item scripts/data/* release/data/
35 | if (!$?) { exit 1 }
36 | }
37 |
38 | # build firmware based on generated headerfile for RP2040
39 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_RP2040_devel firmware-DeveloperBoard uf2 DeveloperBoard-JustForTesters
40 | if (!$?) { exit 1 }
41 |
42 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_PiPico_BCU_Connector firmware-PiPico-BCU-Connector uf2
43 | if (!$?) { exit 1 }
44 |
45 | # build firmware for 1TE-RP2040-SmartMF
46 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_1TE_RP2040_SmartMF firmware-1TE-RP2040-SmartMF uf2
47 | if (!$?) { exit 1 }
48 |
49 | # build firmware for OpenKNX-REG1-Base-V0
50 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_OpenKNX_REG1_BASE_V0 firmware-OpenKNX-REG1-BASE-V0 uf2
51 | if (!$?) { exit 1 }
52 |
53 | # build firmware for OpenKNX-REG1-Base-V1
54 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_OpenKNX_REG1_BASE_V1 firmware-OpenKNX-REG1-BASE-V1 uf2
55 | if (!$?) { exit 1 }
56 |
57 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_RealPresence firmware-RealPresence uf2
58 | if (!$?) { exit 1 }
59 |
60 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_RealPresence_v20 firmware-RealPresence_v2.0 uf2
61 | if (!$?) { exit 1 }
62 |
63 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_Sensormodul_v40_RP2040 firmware-Sensormodul-v4x-RP2040 uf2
64 | if (!$?) { exit 1 }
65 |
66 | if ($releaseIndication -eq "Release") {
67 | # build firmware based on generated headerfile for SAMD
68 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_Sensormodul_v31_SAMD firmware-Sensormodul-v31-SAMD bin
69 | if (!$?) { exit 1 }
70 |
71 | lib/OGM-Common/scripts/setup/reusable/Build-Step.ps1 release_Sensormodul_v30_SAMD firmware-Sensormodul-v30-SAMD bin
72 | if (!$?) { exit 1 }
73 | }
74 | # execute generic post-build steps
75 | lib/OGM-Common/scripts/setup/reusable/Build-Release-Postprocess.ps1 $args[0]
76 | if (!$?) { exit 1 }
77 |
78 | if (Test-Path -Path release-collection -PathType Container) {
79 | Copy-Item release/* release-collection/
80 | }
81 |
--------------------------------------------------------------------------------
/scripts/OpenKNX-Build-Settings.ps1:
--------------------------------------------------------------------------------
1 |
2 | # set product names, allows mapping of (devel) name in Project to a more consistent name in release
3 | $settings = lib/OGM-Common/scripts/build/OpenKNX-Build-Settings.ps1 $args[0] "PMmodul" "PresenceModule"
4 |
5 | # $settings.sourceName="PMmodul"
6 | # $settings.targetName="PresenceModule"
7 | # $settings.knxprod="src/{0}.h" -f $settings.sourceName
8 | # $settings.hardware="src/{0}Hardware.h" -f $settings.sourceName
9 |
10 | Return $settings
--------------------------------------------------------------------------------
/scripts/OpenKNX-Build.ps1:
--------------------------------------------------------------------------------
1 | lib/OGM-Common/scripts/build/OpenKNX-Build.ps1 $args[0] $args[1]
--------------------------------------------------------------------------------
/scripts/Readme-Hardware.html:
--------------------------------------------------------------------------------
1 | Unterstützte Hardware
2 | Die Software für dieses Release wurde auf folgender Hardware getestet und läuft damit "out-of-the-box":
3 |
4 | - Smart-MF Sensormodul 4.x www.smart-mf.de, als virtueller
5 | Präsenzmelder, um die Applikationen von alten oder unzuverlässigen Präsenzmeldern zu verbessern
6 | - PiPico-BCU-Connector OpenKNX-Wiki, als virtueller
8 | Präsenzmelder
9 | - 1TE-RP2040-Smart-MF www.smart-mf.de, als virtueller
10 | Präsenzmelder auf allen Varianten lauffähig
11 | - OpenKNX-UP1-System OpenKNX-Wiki, als virtueller Präsenzmelder
13 | auf allen Varianten lauffähig
14 | - OpenKNX-REG1-System OpenKNX-Wiki, als virtueller Präsenzmelder
16 | auf allen Varianten lauffähig
17 | - Smart-MF RealPresence www.smart-mf.de, als vollständiger
18 | Präsenzmelder, der auch Personen ohne Bewegung zuverlässig erkennt.
19 |
20 | Andere Hardware kann genutzt werden, jedoch muss das Projekt dann neu compiliert werden. Alle notwendigen Teile für
21 | ein Aufsetzen der Build-Umgebung inclusive aller notwendigen Projekte finden sich im OpenKNX-Projekt
23 | Interessierte sollten auch die Beiträge im OpenKNX-Forum studieren.
--------------------------------------------------------------------------------
/scripts/Readme-Hardware.md:
--------------------------------------------------------------------------------
1 | # Unterstützte Hardware
2 |
3 | Die Software für dieses Release wurde auf folgender Hardware getestet und läuft damit "out-of-the-box":
4 |
5 | * **Smart-MF Sensormodul 4.x** [www.smart-mf.de](https://www.smart-mf.de), als virtueller Präsenzmelder, um die Applikationen von alten oder unzuverlässigen Präsenzmeldern zu verbessern
6 | * **PiPico-BCU-Connector** [OpenKNX-Wiki](https://github.com/OpenKNX/OpenKNX/wiki/PiPico-BCU-Connector), als virtueller Präsenzmelder
7 | * **1TE-RP2040-Smart-MF** [www.smart-mf.de](https://www.smart-mf.de), als virtueller Präsenzmelder auf allen Varianten lauffähig
8 | * **OpenKNX-UP1-System** [OpenKNX-Wiki](https://github.com/OpenKNX/OpenKNX/wiki/OpenKNX-UP1), als virtueller Präsenzmelder auf allen Varianten lauffähig
9 | * **OpenKNX-REG1-System** [OpenKNX-Wiki](https://github.com/OpenKNX/OpenKNX/wiki/OpenKNX-REG1), als virtueller Präsenzmelder auf allen Varianten lauffähig
10 | * **Smart-MF RealPresence** [www.smart-mf.de](https://www.smart-mf.de), als vollständiger Präsenzmelder, der auch Personen ohne Bewegung zuverlässig erkennt.
11 |
12 | Andere Hardware kann genutzt werden, jedoch muss das Projekt dann neu compiliert werden. Alle notwendigen Teile für ein Aufsetzen der Build-Umgebung inclusive aller notwendigen Projekte finden sich im [OpenKNX-Projekt](https://github.com/OpenKNX)
13 |
14 | Interessierte sollten auch die Beiträge im [OpenKNX-Forum](https://knx-user-forum.de/forum/projektforen/openknx) studieren.
15 |
--------------------------------------------------------------------------------
/src/PMmodul-Big.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
20 |
21 |
25 |
26 |
27 |
28 |
30 |
31 |
32 |
33 |
37 |
38 |
39 |
40 |
46 |
47 |
48 |
49 |
55 |
56 |
57 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/src/PMmodul-IP.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
22 |
26 |
27 |
28 |
30 |
31 |
32 |
33 |
36 |
37 |
38 |
39 |
43 |
44 |
45 |
46 |
52 |
53 |
54 |
55 |
61 |
62 |
63 |
64 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/src/PMmodul-Release.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
18 |
20 |
21 |
22 |
23 |
27 |
28 |
29 |
30 |
36 |
37 |
38 |
39 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/src/PMmodul-VirtualButton.link.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/PMmodul.conf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/PMmodul.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
21 |
22 |
26 |
27 |
28 |
29 |
31 |
32 |
33 |
34 |
38 |
39 |
40 |
41 |
47 |
48 |
49 |
50 |
56 |
57 |
58 |
59 |
65 |
66 |
67 |
68 |
69 |
80 |
--------------------------------------------------------------------------------
/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "Logic.h"
2 | #include "Presence.h"
3 | #include "SensorDevices.h"
4 | #ifdef ARDUINO_ARCH_RP2040
5 | #include "FileTransferModule.h"
6 | #include "UsbExchangeModule.h"
7 | #include "VirtualButtonModule.h"
8 | #if defined(KNX_IP_LAN) || defined(KNX_IP_WIFI)
9 | #include "NetworkModule.h"
10 | #endif
11 | #endif
12 | #include "OpenKNX.h"
13 |
14 | #ifdef ARDUINO_ARCH_RP2040
15 | #pragma message "Pico Core Version: " ARDUINO_PICO_VERSION_STR
16 | #endif
17 | #include "hardware.h"
18 |
19 | #include "Sensor.h"
20 |
21 | void setup()
22 | {
23 | const uint8_t firmwareRevision = 2;
24 |
25 | #ifdef ARDUINO_ARCH_RP2040
26 | #ifdef I2C_WIRE
27 | I2C_WIRE.setSDA(I2C_SDA_PIN);
28 | I2C_WIRE.setSCL(I2C_SCL_PIN);
29 | openknxSensorDevicesModule.defaultWire(I2C_WIRE);
30 | #endif
31 | #endif
32 | openknx.init(firmwareRevision);
33 | openknx.addModule(1, openknxLogic);
34 | openknx.addModule(2, openknxPresenceModule);
35 | openknx.addModule(4, openknxSensorDevicesModule);
36 | #ifdef ARDUINO_ARCH_RP2040
37 | openknx.addModule(5, openknxVirtualButtonModule);
38 | openknx.addModule(3, openknxFileTransferModule);
39 | openknx.addModule(8, openknxUsbExchangeModule);
40 | #if defined(KNX_IP_LAN) || defined(KNX_IP_WIFI)
41 | openknx.addModule(7, openknxNetwork);
42 | #endif
43 | #endif
44 | openknx.setup();
45 | }
46 |
47 | void loop()
48 | {
49 | openknx.loop();
50 | }
51 |
--------------------------------------------------------------------------------
/test/README:
--------------------------------------------------------------------------------
1 |
2 | This directory is intended for PIO Unit Testing and project tests.
3 |
4 | Unit Testing is a software testing method by which individual units of
5 | source code, sets of one or more MCU program modules together with associated
6 | control data, usage procedures, and operating procedures, are tested to
7 | determine whether they are fit for use. Unit testing finds problems early
8 | in the development cycle.
9 |
10 | More information about PIO Unit Testing:
11 | - https://docs.platformio.org/page/plus/unit-testing.html
12 |
--------------------------------------------------------------------------------