From 4876cd42e112b4b4bdbbbaa9e350dc7a47b57e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Ba=C5=82ys?= Date: Fri, 15 Jul 2022 12:02:30 +0200 Subject: [PATCH] Weather station factory data (#130) * Added Factory Data for Thingy Weather Station. * Added Certification Declaration for Matter Weather Station SVE as a define * Added an overlay for building the new factory data set * [nrfconnect] Fix window-covering app build after adding EnableKey The nRF Connect window-covering app didn't build correctly after recent changes. The fix is to move using the namespaces into another place in the code. This change needs to be also applied in the SVE branch. --- examples/weather_station/Kconfig | 7 ++ .../overlay-factory_data_build.conf | 31 ++++++ .../thingy53_nrf5340_cpuapp/pm_static.yml | 6 +- examples/weather_station/factory_data/CD.der | Bin 0 -> 234 bytes .../weather_station/factory_data/DAC_cert.der | Bin 0 -> 514 bytes .../weather_station/factory_data/DAC_cert.pem | 13 +++ .../weather_station/factory_data/DAC_key.der | Bin 0 -> 121 bytes .../weather_station/factory_data/DAC_key.pem | 5 + .../weather_station/factory_data/PAI_cert.der | Bin 0 -> 451 bytes .../weather_station/factory_data/PAI_cert.pem | 12 +++ .../weather_station/factory_data/PAI_key.der | Bin 0 -> 121 bytes .../weather_station/factory_data/PAI_key.pem | 5 + .../factory_data/factory_data.bin | Bin 0 -> 1425 bytes .../factory_data/factory_data.hex | 92 ++++++++++++++++++ .../factory_data/factory_data.json | 20 ++++ examples/weather_station/src/app_task.cpp | 35 ++++++- examples/weather_station/src/app_task.h | 8 ++ .../weather_station/src/chip_project_config.h | 31 +++--- .../window-app/nrfconnect/main/AppTask.cpp | 7 +- 19 files changed, 254 insertions(+), 18 deletions(-) create mode 100644 examples/weather_station/configuration/thingy53_nrf5340_cpuapp/overlay-factory_data_build.conf create mode 100644 examples/weather_station/factory_data/CD.der create mode 100644 examples/weather_station/factory_data/DAC_cert.der create mode 100644 examples/weather_station/factory_data/DAC_cert.pem create mode 100644 examples/weather_station/factory_data/DAC_key.der create mode 100644 examples/weather_station/factory_data/DAC_key.pem create mode 100644 examples/weather_station/factory_data/PAI_cert.der create mode 100644 examples/weather_station/factory_data/PAI_cert.pem create mode 100644 examples/weather_station/factory_data/PAI_key.der create mode 100644 examples/weather_station/factory_data/PAI_key.pem create mode 100644 examples/weather_station/factory_data/factory_data.bin create mode 100644 examples/weather_station/factory_data/factory_data.hex create mode 100644 examples/weather_station/factory_data/factory_data.json diff --git a/examples/weather_station/Kconfig b/examples/weather_station/Kconfig index 89fa577dba8bdf..7c9de8eaa8c2b5 100644 --- a/examples/weather_station/Kconfig +++ b/examples/weather_station/Kconfig @@ -13,4 +13,11 @@ config AVERAGE_CURRENT_CONSUMPTION The predicted average current consumption of the Matter weather station device, used to estimate the remaining battery time. +# Overwrite the Fprotect block size to fit the size of the factory data partition. +# See lib/fprotect/Kconfig to get full description of this config. +config FPROTECT_BLOCK_SIZE + hex + default 0x1000 + + source "Kconfig.zephyr" diff --git a/examples/weather_station/configuration/thingy53_nrf5340_cpuapp/overlay-factory_data_build.conf b/examples/weather_station/configuration/thingy53_nrf5340_cpuapp/overlay-factory_data_build.conf new file mode 100644 index 00000000000000..98c5d6ec868285 --- /dev/null +++ b/examples/weather_station/configuration/thingy53_nrf5340_cpuapp/overlay-factory_data_build.conf @@ -0,0 +1,31 @@ +# +# Copyright (c) 2022 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Use this overlay to re-generate new PAI and DAC certificates. +# Be sure that chip-cert executable is added to your system PATH. + +# Enable building the new factory data +CONFIG_CHIP_FACTORY_DATA=y +CONFIG_CHIP_FACTORY_DATA_BUILD=y +CONFIG_CHIP_FACTORY_DATA_USE_DEFAULTS_CERTS=n +CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=y + +# Set up the Factory Data +CONFIG_CHIP_DEVICE_SERIAL_NUMBER="11223344556677889900" +CONFIG_CHIP_DEVICE_VENDOR_ID=4735 +CONFIG_CHIP_DEVICE_VENDOR_NAME="Nordic Semiconductor ASA" +CONFIG_CHIP_DEVICE_PRODUCT_ID=32781 +CONFIG_CHIP_DEVICE_PRODUCT_NAME="Weather Station" +CONFIG_CHIP_DEVICE_MANUFACTURING_DATE="2022-07-12" +CONFIG_CHIP_DEVICE_HARDWARE_VERSION=1 +CONFIG_CHIP_DEVICE_HARDWARE_VERSION_STRING="SVE" +CONFIG_CHIP_DEVICE_DISCRIMINATOR=0xE46 +CONFIG_CHIP_DEVICE_SPAKE2_PASSCODE=28073715 +CONFIG_CHIP_DEVICE_SPAKE2_IT=1000 +CONFIG_CHIP_DEVICE_SPAKE2_SALT="SPAKE2P Key Salt" +CONFIG_CHIP_DEVICE_SPAKE2_TEST_VERIFIER="XUQaKLznAVZ+WEWkSTIEJwvjaU/CuWY1qLbRKuS56VEE4Us+aJNGy3B3tLClZWRDAS5yXUgku5pHyFLgVTAKXQIo663Y2L7HvrJh/8jlD0OTNDDLlsnjKdj+l0b2rC3vMg==" +CONFIG_CHIP_DEVICE_ROTATING_DEVICE_UID="0989f27796617e00ff9dc844496dbcf3" +CONFIG_CHIP_DEVICE_ENABLE_KEY="d229322af1412d66ebeda07e0d39b80e" diff --git a/examples/weather_station/configuration/thingy53_nrf5340_cpuapp/pm_static.yml b/examples/weather_station/configuration/thingy53_nrf5340_cpuapp/pm_static.yml index 7a48d51ec33477..01b6d9498be388 100644 --- a/examples/weather_station/configuration/thingy53_nrf5340_cpuapp/pm_static.yml +++ b/examples/weather_station/configuration/thingy53_nrf5340_cpuapp/pm_static.yml @@ -28,7 +28,11 @@ mcuboot_primary_app: settings_storage: address: 0xf0000 region: flash_primary - size: 0x10000 + size: 0xf000 +factory_data: + address: 0xff000 + region: flash_primary + size: 0x1000 mcuboot_primary_1: address: 0x0 size: 0x40000 diff --git a/examples/weather_station/factory_data/CD.der b/examples/weather_station/factory_data/CD.der new file mode 100644 index 0000000000000000000000000000000000000000..ca87ddf9d8e13dd156b89de4659c38e6b4ae76e5 GIT binary patch literal 234 zcmXqLe9p$H)#lOmotKfFX+h&ngT`x2jLe3-2Hb3%32h#Xsmv@)j0P?UMT`r~SxiM$ z7#LL<>xImiSa};HRG7JRScIcI-Hi+kO^l+PjExNp42*S+OjKAIRM;3)*{7(fa4<+1 z))-U)&2A7$`qg9{x#ri(X?8NdM7ZvLW%*o~fNCEX8wb!)=WJP+nONKmT$mL2FP>(# z*)n(Lb%j4|DIAAh*6b>(J2ZcP`Mv`T)!*Z?PBSUwTu%JiT;MMfI6-@zRqN$rA2-Cg R2)#UeMtR~PUum^N-T<_YNf!VB literal 0 HcmV?d00001 diff --git a/examples/weather_station/factory_data/DAC_cert.der b/examples/weather_station/factory_data/DAC_cert.der new file mode 100644 index 0000000000000000000000000000000000000000..27756d11738d5bdc8aa08be6edb5ef5010dca222 GIT binary patch literal 514 zcmXqLV*F>&#JFSuGZP~d6Gv2x;gpMSmiZWPv2kd%d7QIlVP-P$G&D5OXJZa!Vdl~B z%P&gFOjZa^&CN{C&r2yyF3B%aa13^g4^K@j$w)0y2rfx1$;{6)6fqED`r0ZcqB76t|` z29XBBZ0um4F)>2D$jr#j?8Lwlw(W1_zJA@GUTu>T&n(mnHm}_FfzwWFa!mZ&_i~=h zzDpkSWEU-3_%ZEkWCB-d@!tvei|ch~OlHdBYvg#LQSftdfycB2(PYbs5Nmq?K7D48$5l zOz*SjD9@e5$@U~f?t_`P%JwaSoyd{G?7?8*%B0BfrG?95m;8pNe{1FBj@c!LFH#e= zv3G8gag6VAJoPckg-IbbJ=7*xD#1U0$*QOePycpF*hT*QoX_7aaB^{iUY6xb0Cj4c A0{{R3 literal 0 HcmV?d00001 diff --git a/examples/weather_station/factory_data/DAC_cert.pem b/examples/weather_station/factory_data/DAC_cert.pem new file mode 100644 index 00000000000000..3133f229dd5e7f --- /dev/null +++ b/examples/weather_station/factory_data/DAC_cert.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB/jCCAaSgAwIBAgIIWlwxlNHspkwwCgYIKoZIzj0EAwIwSTExMC8GA1UEAwwo +Tm9yZGljIFNlbWljb25kdWN0b3IgQVNBX1dlYXRoZXIgU3RhdGlvbjEUMBIGCisG +AQQBgqJ8AgEMBDEyN0YwHhcNMjIwNzEyMDAwMDAwWhcNNDkxMTI2MjM1OTU5WjBf +MTEwLwYDVQQDDChOb3JkaWMgU2VtaWNvbmR1Y3RvciBBU0FfV2VhdGhlciBTdGF0 +aW9uMRQwEgYKKwYBBAGConwCAQwEMTI3RjEUMBIGCisGAQQBgqJ8AgIMBDgwMEQw +WTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARWtv15vo8t+UqGk2HMoS5TN3m28Ak+ +KpNcX+3vHkkDTaTjDGtyoqHxZvVZYAp1c/2Q33N/LZiTAmoOgQjoKHD5o2AwXjAM +BgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQEAwIHgDAdBgNVHQ4EFgQU2Cc2UkqWe8MA +ppyrs8DRFJRHzoowHwYDVR0jBBgwFoAUNd8HbCOdkgkG5FQe8DZLJLe0EYkwCgYI +KoZIzj0EAwIDSAAwRQIhAPSECki6H7CC/q0eHsY+Y1eiJhU8P0OCHEFfjEHK8VpE +AiBlZ1U8UxpgT2+kqlrQ5f2KGD5Z+fNvD4sQyaNgLmo5qQ== +-----END CERTIFICATE----- diff --git a/examples/weather_station/factory_data/DAC_key.der b/examples/weather_station/factory_data/DAC_key.der new file mode 100644 index 0000000000000000000000000000000000000000..801117871b274250628ede0a7973813e060d49c5 GIT binary patch literal 121 zcmV-<0EYiCcLD(c1R(xQi>}Gs0C6a)tN=9BpNQYk%BYT#c$Ui4+IEcX`)r^J1_&yK zNX|V20SBQ(13~}WN`{kR%%Lt*H+i=32|g;5Twm?)9!UdDq~i>0a-yN} bX7yQM3Uzb+kl%BEEtr!6Y7T)2=qPac{_i(Z literal 0 HcmV?d00001 diff --git a/examples/weather_station/factory_data/DAC_key.pem b/examples/weather_station/factory_data/DAC_key.pem new file mode 100644 index 00000000000000..d1cee947372897 --- /dev/null +++ b/examples/weather_station/factory_data/DAC_key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIP5Mi67J3ABxKKqsADTUn4jf0MqojpJ4lsrU2naM7ftsoAoGCCqGSM49 +AwEHoUQDQgAEVrb9eb6PLflKhpNhzKEuUzd5tvAJPiqTXF/t7x5JA02k4wxrcqKh +8Wb1WWAKdXP9kN9zfy2YkwJqDoEI6Chw+Q== +-----END EC PRIVATE KEY----- diff --git a/examples/weather_station/factory_data/PAI_cert.der b/examples/weather_station/factory_data/PAI_cert.der new file mode 100644 index 0000000000000000000000000000000000000000..86fcbfa807046270a542c9d40da0a82e2bdcc465 GIT binary patch literal 451 zcmXqLV%%@g#F)B(nTe5!i9>OF@_}6WFTMs`Y#dr`9_MUXn3)Wu3?&T2*qB3En0fep z6H7``ixfgqi%S#&932hh#CeU349pFU48R~toY%zC(9p=t$k^1<)H2Gz)6mdBAEH;o zFTW@yGg%=xH8(RkKQE;;xg@_x!7u486oXLe#>DUyzQ^&?o`@4|N98!>J#CcCcQ!t-lS zr0~&4M?bE4u3;aO&)N6SNvOSdw|)D*S1Ny>9L(EL@a@ury*;m%6ke2_zBtVw1!yI6 zsH`v}<9`+o12!PV#K>U42NL54i2=ibkPtlMuNNX5K2> zw+MC`$b+PnS%9I{AW{+YoOMTbzhD0G$*U4hJHN`zXu66Vs>~h?2ChsBL5?NsB7WU9 z$x>Cy)GutU@31kj*p!;)o%ZBNdeHrskxYsVn|10IUFF&t`_}W;yzi!8pNFiBpOJTA P#fOy*>-qP7dwT%@+f$Wq literal 0 HcmV?d00001 diff --git a/examples/weather_station/factory_data/PAI_cert.pem b/examples/weather_station/factory_data/PAI_cert.pem new file mode 100644 index 00000000000000..0bbab2260dd3cd --- /dev/null +++ b/examples/weather_station/factory_data/PAI_cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBvzCCAWWgAwIBAgIIIbdjwG0f9E0wCgYIKoZIzj0EAwIwGjEYMBYGA1UEAwwP +TWF0dGVyIFRlc3QgUEFBMB4XDTIyMDcxMjAwMDAwMFoXDTQ5MTEyNjIzNTk1OVow +STExMC8GA1UEAwwoTm9yZGljIFNlbWljb25kdWN0b3IgQVNBX1dlYXRoZXIgU3Rh +dGlvbjEUMBIGCisGAQQBgqJ8AgEMBDEyN0YwWTATBgcqhkjOPQIBBggqhkjOPQMB +BwNCAARyG1rq+FMfTtC3TdhcRuiTRau0DPq8WRPF4sXxrOcoP1xvCY7+QhKHjbs/ +h77qJP3kwW6wcPbS4L2M6qRx0R2Xo2YwZDASBgNVHRMBAf8ECDAGAQH/AgEAMA4G +A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUNd8HbCOdkgkG5FQe8DZLJLe0EYkwHwYD +VR0jBBgwFoAUeFznBbhrj05vx5OqYMtD6mlogtUwCgYIKoZIzj0EAwIDSAAwRQIg +UkF0rlj63TRqJSJpL3GFf4g8MDiyZWZLZuTEZ1Lf6VkCIQCzLH6i1Qq5Xe1J2p73 +NfXnVKlfmG7QqPCpgK8Pvfbt0A== +-----END CERTIFICATE----- diff --git a/examples/weather_station/factory_data/PAI_key.der b/examples/weather_station/factory_data/PAI_key.der new file mode 100644 index 0000000000000000000000000000000000000000..93955faa2f0fffd332bed736cad529d0cbda3348 GIT binary patch literal 121 zcmV-<0EYiCcLD(c1R(VubE=m;J?)8dmy2W0oNFn|B~Yb|_Z$qyI~|?t0NtPp1_&yK zNX|V20SBQ(13~}$4Tt?`VMXR(7`n*{a#p1>Btmh~{TyF`E{z4Lm bjk`aGzUn0XVrXb&WNd6=Vrpt;W^Qg_VQFb#kXe?Rmy%x;pP3>lRG(E) zl%G!(1~`5|iVTQ;SL> znV1Zk821%%#7^JP7Ewz+x}MW>(~A1)iyct%tF0j z^U7@>IPJ71$Hc#VFXzeZyW}xXcG04RAJe`@CUBJ&|DABZxL$Y0WTq^>MvfO61wR)j z7{nRy0E07uBHLdzE!?HQ6Hy^kt zGR6H|mw`M;TA4+{K&(N;^gerz^4v+BY)?YuKA3r{Y~Lc-i5w}+9t;MqOo|L&TDUxR z$!}=-w^mN>m|b%CA~jJPd*>z@$M_z{Qy-&Tm=sdeLv4bk68!U*tctqu^lz7hUF6Tt z`TX4iCl@E^Wm&FF2c?GW)XE5je?HyoPTpZC)L6BK!Q{&Pj{6r*t>~LnG40fqTV*|O zf9GTrBxXX=4dY>8n%NJ;snB$zxIOtmuKX8YWG5O(83Mfm^b;`M@cSl~lmHWINNRD3 zLV%+q!Gu7?G>1FNi=?Ao{Ro!#yRhB&MvU8w$*!xn@ch~nDSY(N(T{7MYuLx+bN2mn z5^C?=ZQs7{mCD~I2lF-*e7p2uZ_leGg%@R~FHSQ^0VZ=;lyexc0pps95iQ~w*^nY0 zYrG;yd_~N2)*adXe)-2IuSz)W{3(ni}%C$50t>>+I-%Y^3dBZW3t=ng7PgJmZqjSGwKz^dZ_H4 z<$faQL8t*&ER)9TwKs0;JHBsI;{Ov*`JE@57@VGV^0DTPf79K*t!YJ? P+UvIq>Ub@8@G$@Y7IW?^ literal 0 HcmV?d00001 diff --git a/examples/weather_station/factory_data/factory_data.hex b/examples/weather_station/factory_data/factory_data.hex new file mode 100644 index 00000000000000..71e9ac3bc82733 --- /dev/null +++ b/examples/weather_station/factory_data/factory_data.hex @@ -0,0 +1,92 @@ +:02000004000FEB +:10F00000B26776657273696F6E0162736E543131E7 +:10F010003232333334343535363637373838393998 +:10F0200030306976656E646F725F696419127F6A49 +:10F0300070726F647563745F696419800D6B7665B7 +:10F040006E646F725F6E616D6558184E6F726469A1 +:10F05000632053656D69636F6E647563746F7220AE +:10F060004153416C70726F647563745F6E616D655E +:10F070004F576561746865722053746174696F6E6F +:10F0800064646174654A323032322D30372D31324A +:10F090006668775F766572016A68775F7665725F2A +:10F0A00073747243535645686461635F6365727439 +:10F0B000590202308201FE308201A4A00302010243 +:10F0C00002085A5C3194D1ECA64C300A06082A8614 +:10F0D00048CE3D04030230493131302F0603550438 +:10F0E000030C284E6F726469632053656D69636F0A +:10F0F0006E647563746F72204153415F576561742C +:10F100006865722053746174696F6E311430120631 +:10F110000A2B0601040182A27C02010C0431323761 +:10F1200046301E170D323230373132303030303009 +:10F13000305A170D343931313236323335393539A9 +:10F140005A305F3131302F06035504030C284E6FBF +:10F15000726469632053656D69636F6E647563746F +:10F160006F72204153415F57656174686572205327 +:10F17000746174696F6E31143012060A2B06010433 +:10F180000182A27C02010C04313237463114301264 +:10F19000060A2B0601040182A27C02020C0438300C +:10F1A00030443059301306072A8648CE3D02010606 +:10F1B000082A8648CE3D0301070342000456B6FDE7 +:10F1C00079BE8F2DF94A869361CCA12E533779B63B +:10F1D000F0093E2A935C5FEDEF1E49034DA4E30C5A +:10F1E0006B72A2A1F166F559600A7573FD90DF7329 +:10F1F0007F2D9893026A0E8108E82870F9A3603089 +:10F200005E300C0603551D130101FF04023000306F +:10F210000E0603551D0F0101FF0404030207803091 +:10F220001D0603551D0E04160414D82736524A969F +:10F230007BC300A69CABB3C0D1149447CE8A301FC9 +:10F240000603551D2304183016801435DF076C2380 +:10F250009D920906E4541EF0364B24B7B411893050 +:10F260000A06082A8648CE3D0403020348003045BA +:10F27000022100F4840A48BA1FB082FEAD1E1EC6E9 +:10F280003E6357A226153C3F43821C415F8C41CA16 +:10F29000F15A4402206567553C531A604F6FA4AA87 +:10F2A0005AD0E5FD8A183E59F9F36F0F8B10C9A3A8 +:10F2B000602E6A39A9676461635F6B65795820FEC7 +:10F2C0004C8BAEC9DC007128AAAC0034D49F88DF17 +:10F2D000D0CAA88E927896CAD4DA768CEDFB6C6888 +:10F2E0007061695F636572745901C3308201BF3018 +:10F2F000820165A003020102020821B763C06D1FED +:10F30000F44D300A06082A8648CE3D040302301A1E +:10F310003118301606035504030C0F4D61747465E3 +:10F3200072205465737420504141301E170D3232E3 +:10F33000303731323030303030305A170D343931C7 +:10F340003132363233353935395A30493131302F4F +:10F3500006035504030C284E6F72646963205365DD +:10F360006D69636F6E647563746F72204153415FA2 +:10F37000576561746865722053746174696F6E318A +:10F38000143012060A2B0601040182A27C02010C31 +:10F3900004313237463059301306072A8648CE3DAD +:10F3A000020106082A8648CE3D03010703420004F5 +:10F3B000721B5AEAF8531F4ED0B74DD85C46E893FB +:10F3C00045ABB40CFABC5913C5E2C5F1ACE7283F14 +:10F3D0005C6F098EFE4212878DBB3F87BEEA24FD1B +:10F3E000E4C16EB070F6D2E0BD8CEAA471D11D9775 +:10F3F000A366306430120603551D130101FF040893 +:10F4000030060101FF020100300E0603551D0F01F9 +:10F4100001FF040403020106301D0603551D0E04FE +:10F4200016041435DF076C239D920906E4541EF080 +:10F43000364B24B7B41189301F0603551D23041819 +:10F4400030168014785CE705B86B8F4E6FC793AAAF +:10F4500060CB43EA696882D5300A06082A8648CE1E +:10F460003D04030203480030450220524174AE5867 +:10F47000FADD346A2522692F71857F883C3038B2E5 +:10F4800065664B66E4C46752DFE959022100B32C7C +:10F490007EA2D50AB95DED49DA9EF735F5E754A9A4 +:10F4A0005F986ED0A8F0A980AF0FBDF6EDD069735C +:10F4B00070616B65325F69741903E86B7370616B1F +:10F4C00065325F73616C74505350414B453250202C +:10F4D0004B65792053616C746F7370616B65325F3B +:10F4E000766572696669657258615D441A28BCE781 +:10F4F00001567E5845A4493204270BE3694FC2B92F +:10F500006635A8B6D12AE4B9E95104E14B3E6893C7 +:10F5100046CB7077B4B0A5656443012E725D482474 +:10F52000BB9A47C852E055300A5D0228EBADD8D8E7 +:10F53000BEC7BEB261FFC8E50F43933430CB96C956 +:10F54000E329D8FE9746F6AC2DEF326D64697363FC +:10F5500072696D696E61746F72190E466672645FCE +:10F56000756964500989F27796617E00FF9DC844F1 +:10F57000496DBCF36A656E61626C655F6B6579505D +:10F58000D229322AF1412D66EBEDA07E0D39B80E5D +:01F59000007A +:00000001FF diff --git a/examples/weather_station/factory_data/factory_data.json b/examples/weather_station/factory_data/factory_data.json new file mode 100644 index 00000000000000..369853a8e119d7 --- /dev/null +++ b/examples/weather_station/factory_data/factory_data.json @@ -0,0 +1,20 @@ +{ + "version": 1, + "sn": "11223344556677889900", + "vendor_id": 4735, + "product_id": 32781, + "vendor_name": "Nordic Semiconductor ASA", + "product_name": "Weather Station", + "date": "2022-07-12", + "hw_ver": 1, + "hw_ver_str": "SVE", + "dac_cert": "hex:308201fe308201a4a00302010202085a5c3194d1eca64c300a06082a8648ce3d04030230493131302f06035504030c284e6f726469632053656d69636f6e647563746f72204153415f576561746865722053746174696f6e31143012060a2b0601040182a27c02010c0431323746301e170d3232303731323030303030305a170d3439313132363233353935395a305f3131302f06035504030c284e6f726469632053656d69636f6e647563746f72204153415f576561746865722053746174696f6e31143012060a2b0601040182a27c02010c043132374631143012060a2b0601040182a27c02020c04383030443059301306072a8648ce3d020106082a8648ce3d0301070342000456b6fd79be8f2df94a869361cca12e533779b6f0093e2a935c5fedef1e49034da4e30c6b72a2a1f166f559600a7573fd90df737f2d9893026a0e8108e82870f9a360305e300c0603551d130101ff04023000300e0603551d0f0101ff040403020780301d0603551d0e04160414d82736524a967bc300a69cabb3c0d1149447ce8a301f0603551d2304183016801435df076c239d920906e4541ef0364b24b7b41189300a06082a8648ce3d0403020348003045022100f4840a48ba1fb082fead1e1ec63e6357a226153c3f43821c415f8c41caf15a4402206567553c531a604f6fa4aa5ad0e5fd8a183e59f9f36f0f8b10c9a3602e6a39a9", + "dac_key": "hex:fe4c8baec9dc007128aaac0034d49f88dfd0caa88e927896cad4da768cedfb6c", + "pai_cert": "hex:308201bf30820165a003020102020821b763c06d1ff44d300a06082a8648ce3d040302301a3118301606035504030c0f4d6174746572205465737420504141301e170d3232303731323030303030305a170d3439313132363233353935395a30493131302f06035504030c284e6f726469632053656d69636f6e647563746f72204153415f576561746865722053746174696f6e31143012060a2b0601040182a27c02010c04313237463059301306072a8648ce3d020106082a8648ce3d03010703420004721b5aeaf8531f4ed0b74dd85c46e89345abb40cfabc5913c5e2c5f1ace7283f5c6f098efe4212878dbb3f87beea24fde4c16eb070f6d2e0bd8ceaa471d11d97a366306430120603551d130101ff040830060101ff020100300e0603551d0f0101ff040403020106301d0603551d0e0416041435df076c239d920906e4541ef0364b24b7b41189301f0603551d23041830168014785ce705b86b8f4e6fc793aa60cb43ea696882d5300a06082a8648ce3d04030203480030450220524174ae58fadd346a2522692f71857f883c3038b265664b66e4c46752dfe959022100b32c7ea2d50ab95ded49da9ef735f5e754a95f986ed0a8f0a980af0fbdf6edd0", + "spake2_it": 1000, + "spake2_salt": "hex:5350414b453250204b65792053616c74", + "spake2_verifier": "hex:5d441a28bce701567e5845a4493204270be3694fc2b96635a8b6d12ae4b9e95104e14b3e689346cb7077b4b0a5656443012e725d4824bb9a47c852e055300a5d0228ebadd8d8bec7beb261ffc8e50f43933430cb96c9e329d8fe9746f6ac2def32", + "discriminator": 3654, + "rd_uid": "hex:0989f27796617e00ff9dc844496dbcf3", + "enable_key": "hex:d229322af1412d66ebeda07e0d39b80e" +} diff --git a/examples/weather_station/src/app_task.cpp b/examples/weather_station/src/app_task.cpp index c28955068cb267..22e6327fca11f7 100644 --- a/examples/weather_station/src/app_task.cpp +++ b/examples/weather_station/src/app_task.cpp @@ -11,11 +11,14 @@ #include "buzzer.h" #include +#include + #include #include #include #include #include +#include #include #include #include @@ -95,6 +98,13 @@ bool sIsThreadEnabled; bool sIsBleAdvertisingEnabled; bool sHaveBLEConnections; +// NOTE! This key is for test/certification only and should not be available in production devices! +// If CONFIG_CHIP_FACTORY_DATA is enabled, this value is read from the factory data. +uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, + 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, + 0xcc, 0xdd, 0xee, 0xff }; +chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; + LedState sLedState = LedState::kAlive; /* Add identify for all endpoints */ @@ -189,6 +199,23 @@ CHIP_ERROR AppTask::Init() return chip::System::MapErrorZephyr(ret); } +/* Get factory data */ +#ifdef CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); + // Read EnableKey from the factory data. + MutableByteSpan enableKey(sTestEventTriggerEnableKey); + err = mFactoryDataProvider.GetEnableKey(enableKey); + if (err != CHIP_NO_ERROR) { + LOG_ERR("mFactoryDataProvider.GetEnableKey() failed. Could not delegate a test event trigger"); + memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); + } +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + #ifdef CONFIG_MCUMGR_SMP_BT /* Initialize DFU over SMP */ GetDFUOverSMP().Init(RequestSMPAdvertisingStart); @@ -210,11 +237,15 @@ CHIP_ERROR AppTask::Init() &sIdentifyTimer, [](k_timer *) { sAppTask.PostEvent(AppEvent{ AppEvent::IdentifyTimer }); }, nullptr); /* Initialize CHIP server */ - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); static chip::CommonCaseDeviceServerInitParams initParams; + static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; (void)initParams.InitializeStaticResourcesBeforeServerInit(); - + initParams.testEventTriggerDelegate = &testEventTriggerDelegate; ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams)); + + gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); + chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + #if CONFIG_CHIP_OTA_REQUESTOR InitBasicOTARequestor(); #endif diff --git a/examples/weather_station/src/app_task.h b/examples/weather_station/src/app_task.h index 076292a224a2b5..f9a5e2f43b6d7e 100644 --- a/examples/weather_station/src/app_task.h +++ b/examples/weather_station/src/app_task.h @@ -16,6 +16,10 @@ #include "DFUOverSMP.h" #endif +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + struct k_timer; class AppTask { @@ -53,6 +57,10 @@ class AppTask { static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent *event, intptr_t arg); static AppTask sAppTask; + +#if CONFIG_CHIP_FACTORY_DATA + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif }; inline AppTask &GetAppTask() diff --git a/examples/weather_station/src/chip_project_config.h b/examples/weather_station/src/chip_project_config.h index 026eb6bb355008..e7bb76bf493bdb 100644 --- a/examples/weather_station/src/chip_project_config.h +++ b/examples/weather_station/src/chip_project_config.h @@ -16,18 +16,27 @@ #pragma once /* Use a default pairing code if one hasn't been provisioned in flash. */ -#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 -#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 28073715 +/* Use a default SED idle interval */ #define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 1000_ms32 -/* Configure device configuration with exemplary data */ -#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "Nordic" -#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME "WeatherStation" -#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_PRODUCT_REVISION_STRING \ - "Prerelease weather station device" -#define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_PRODUCT_REVISION 1 -#define CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION_STRING "Prerelease weather station firmware" -#define CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION 1 - #define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 + +#ifdef CONFIG_CHIP_FACTORY_DATA +/* Store Certification Declaration */ +#define CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION \ + { 0x30, 0x81, 0xe7, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x81, 0xd9, 0x30, \ + 0x81, 0xd6, 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, \ + 0x02, 0x01, 0x30, 0x44, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x37, 0x04, \ + 0x35, 0x15, 0x24, 0x00, 0x01, 0x25, 0x01, 0x7f, 0x12, 0x36, 0x02, 0x05, 0x0d, 0x80, 0x18, 0x24, 0x03, 0x0a, \ + 0x2c, 0x04, 0x13, 0x5a, 0x49, 0x47, 0x32, 0x30, 0x31, 0x34, 0x32, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, \ + 0x33, 0x2d, 0x32, 0x34, 0x24, 0x05, 0x00, 0x24, 0x06, 0x00, 0x25, 0x07, 0x94, 0x26, 0x24, 0x08, 0x00, 0x18, \ + 0x31, 0x7c, 0x30, 0x7a, 0x02, 0x01, 0x03, 0x80, 0x14, 0x62, 0xfa, 0x82, 0x33, 0x59, 0xac, 0xfa, 0xa9, 0x96, \ + 0x3e, 0x1c, 0xfa, 0x14, 0x0a, 0xdd, 0xf5, 0x04, 0xf3, 0x71, 0x60, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, \ + 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, \ + 0x04, 0x46, 0x30, 0x44, 0x02, 0x20, 0x0f, 0xd1, 0xcb, 0x05, 0x3c, 0xb4, 0x9d, 0x99, 0xd7, 0x20, 0xfc, 0x86, \ + 0x64, 0x08, 0xc2, 0xe9, 0x7c, 0xba, 0x72, 0x7e, 0xc2, 0x9f, 0xbf, 0x77, 0xbe, 0xc0, 0x00, 0x7b, 0xf7, 0x5e, \ + 0x6a, 0xcb, 0x02, 0x20, 0x6c, 0xd3, 0x61, 0xf9, 0x83, 0x70, 0x4f, 0x14, 0x51, 0x90, 0x2b, 0xae, 0x3a, 0x85, \ + 0xd3, 0xc6, 0xf1, 0xb0, 0x5e, 0x44, 0x12, 0xe9, 0xcd, 0xcc, 0x23, 0x91, 0xc2, 0x4d, 0x1b, 0x26, 0xc2, 0x4b }; +#endif diff --git a/examples/window-app/nrfconnect/main/AppTask.cpp b/examples/window-app/nrfconnect/main/AppTask.cpp index 330fb4862e6529..65b6b3f6857212 100644 --- a/examples/window-app/nrfconnect/main/AppTask.cpp +++ b/examples/window-app/nrfconnect/main/AppTask.cpp @@ -53,6 +53,9 @@ LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), APP_EVENT_QUEUE_SIZE, alignof(AppEvent)); +using namespace ::chip; +using namespace ::chip::Credentials; +using namespace ::chip::DeviceLayer; namespace { // NOTE! This key is for test/certification only and should not be available in production devices! @@ -83,10 +86,6 @@ constexpr uint32_t kOff_ms{ 950 }; } // namespace StatusLed } // namespace LedConsts -using namespace ::chip; -using namespace ::chip::Credentials; -using namespace ::chip::DeviceLayer; - CHIP_ERROR AppTask::Init() { // Initialize CHIP stack