Skip to content

Commit dd5ddca

Browse files
committed
Fixes to require dependency on M5Unit-NFC
1 parent 65eb515 commit dd5ddca

20 files changed

Lines changed: 585 additions & 892 deletions

.github/workflows/arduino-esp-v2-build-check.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build(arduino-esp32:2.x)
22

33
env:
44
SKETCH_NAMES_FIND_START: ./examples/UnitUnified
5-
REQUIRED_LIBRARIES: M5Unified,M5UnitUnified
5+
REQUIRED_LIBRARIES: M5Unified,M5UnitUnified,M5Unit-NFC
66

77
on:
88
push:
@@ -52,13 +52,14 @@ jobs:
5252

5353
strategy:
5454
fail-fast: false
55-
#max-parallel: 1
55+
max-parallel: 20
56+
5657
matrix:
5758
platform-url:
5859
- https://espressif.github.io/arduino-esp32/package_esp32_index.json
5960

6061
sketch:
61-
- DetectDevices
62+
- Detect
6263

6364
board:
6465
- m5stack-atom
@@ -89,6 +90,12 @@ jobs:
8990
archi: esp32
9091
platform-version: 2.0.17
9192
board: m5stack-core-esp32
93+
- sketch: NDEF
94+
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
95+
platform: esp32
96+
archi: esp32
97+
platform-version: 2.0.17
98+
board: m5stack-core-esp32
9299

93100
unit:
94101
- ''

.github/workflows/arduino-esp-v3-build-check.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build(arduino-esp32:3.x)
22

33
env:
44
SKETCH_NAMES_FIND_START: ./examples/UnitUnified
5-
REQUIRED_LIBRARIES: M5Unified,M5UnitUnified
5+
REQUIRED_LIBRARIES: M5Unified,M5UnitUnified,M5Unit-NFC
66

77
on:
88
push:
@@ -52,13 +52,14 @@ jobs:
5252

5353
strategy:
5454
fail-fast: false
55-
#max-parallel: 1
55+
max-parallel: 20
56+
5657
matrix:
5758
platform-url:
5859
- https://espressif.github.io/arduino-esp32/package_esp32_index.json
5960

6061
sketch:
61-
- DetectDevices
62+
- Detect
6263

6364
unit:
6465
- ''
@@ -110,9 +111,15 @@ jobs:
110111
platform: esp32
111112
archi: esp32
112113
board: m5stack_core
114+
- sketch: NDEF
115+
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
116+
platform-version: 3.0.4
117+
platform: esp32
118+
archi: esp32
119+
board: m5stack_core
113120

114121
platform-version:
115-
- 3.0.4
122+
- 3.1.3
116123

117124
platform:
118125
- esp32

.github/workflows/arduino-m5-build-check.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build(arduino-m5stack)
22

33
env:
44
SKETCH_NAMES_FIND_START: ./examples/UnitUnified
5-
REQUIRED_LIBRARIES: M5Unified,M5UnitUnified
5+
REQUIRED_LIBRARIES: M5Unified,M5UnitUnified,M5Unit-NFC
66

77
on:
88
push:
@@ -52,13 +52,14 @@ jobs:
5252

5353
strategy:
5454
fail-fast: false
55-
# max-parallel: 1
55+
max-parallel: 20
56+
5657
matrix:
5758
platform-url:
5859
- https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
5960

6061
sketch:
61-
- DetectDevices
62+
- Detect
6263

6364
unit:
6465
- ''
@@ -94,25 +95,31 @@ jobs:
9495
# Specific sketches
9596
- sketch: Dump
9697
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
97-
platform-version: 2.1.2
98+
platform-version: 3.2.1
9899
platform: m5stack
99100
archi: esp32
100101
board: m5stack_core
101102
- sketch: ValueBlock
102103
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
103-
platform-version: 2.1.2
104+
platform-version: 3.2.1
104105
platform: m5stack
105106
archi: esp32
106107
board: m5stack_core
107108
- sketch: ReadWrite
108109
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
109-
platform-version: 2.1.2
110+
platform-version: 3.2.1
111+
platform: m5stack
112+
archi: esp32
113+
board: m5stack_core
114+
- sketch: NDEF
115+
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
116+
platform-version: 3.2.1
110117
platform: m5stack
111118
archi: esp32
112119
board: m5stack_core
113120

114121
platform-version:
115-
- 2.1.2
122+
- 3.2.1
116123

117124
platform:
118125
- m5stack

.github/workflows/platformio-build-check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ jobs:
5050

5151
strategy:
5252
fail-fast: false
53-
#max-parallel: 1
53+
max-parallel: 20
5454

5555
matrix:
5656
example:
57-
- DetectDevices
57+
- Detect
5858
#- Dump
5959
#- ValueBlock
6060
#- ReadWrite
@@ -130,7 +130,7 @@ jobs:
130130
board: Core
131131
framework: Arduino
132132
espressif32: latest
133-
- example: NFC
133+
- example: NDEF
134134
board: Core
135135
framework: Arduino
136136
espressif32: latest
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
/*
7+
Example using M5UnitUnified for UnitRFID2
8+
Detect NFC-A PICC
9+
*/
10+
#include "main/Detect.cpp"

examples/UnitUnified/DetectDevices/main/DetectDevices.cpp renamed to examples/UnitUnified/Detect/main/Detect.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
33
*
44
* SPDX-License-Identifier: MIT
55
*/
66
/*
77
Example using M5UnitUnified for UnitRFID2
8-
Detect NFC-A devices
8+
Detect NFC-A PICC
99
*/
1010
#include <M5Unified.h>
1111
#include <M5UnitUnified.h>
@@ -60,23 +60,22 @@ void setup()
6060
void loop()
6161
{
6262
M5.update();
63-
auto touch = M5.Touch.getDetail();
6463
Units.update();
64+
auto touch = M5.Touch.getDetail();
6565

66-
std::vector<UID> devices;
67-
if (nfc_a.detect(devices)) {
66+
std::vector<UID> uids;
67+
if (nfc_a.detect(uids)) {
6868
M5.Speaker.tone(3000, 10);
6969
lcd.fillScreen(0);
7070
lcd.setCursor(0, 0);
71-
lcd.printf("Devices: %zu\n", devices.size());
72-
M5.Log.printf("Devices: %zu\n", devices.size());
71+
lcd.printf("%zu PICC\n", uids.size());
72+
M5.Log.printf("%zu PICC\n", uids.size());
7373
uint32_t idx{};
74-
for (auto&& u : devices) {
74+
for (auto&& u : uids) {
7575
M5.Log.printf("UID:%s %s %u/%u\n", u.uidAsString().c_str(), u.typeAsString().c_str(), u.userAreaSize(),
7676
u.totalSize());
7777
lcd.printf("[%2u]:UID:<%s> %s\n", idx, u.uidAsString().c_str(), u.typeAsString().c_str());
7878
++idx;
7979
}
80-
nfc_a.deactivate();
8180
}
8281
}

examples/UnitUnified/DetectDevices/DetectDevices.ino

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/UnitUnified/Dump/Dump.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
33
*
44
* SPDX-License-Identifier: MIT
55
*/
66
/*
77
Example using M5UnitUnified for UnitRFID2
8-
Dump to serial
8+
Dump NFC-A PICC
99
*/
1010
#include "main/Dump.cpp"

examples/UnitUnified/Dump/main/Dump.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
33
*
44
* SPDX-License-Identifier: MIT
55
*/
66
/*
77
Example using M5UnitUnified for UnitRFID2
8-
Dump NFC device
8+
Dump NFC-A PICC
99
*/
1010
#include <M5Unified.h>
1111
#include <M5UnitUnified.h>
@@ -23,6 +23,7 @@ auto& lcd = M5.Display;
2323
m5::unit::UnitUnified Units;
2424
m5::unit::UnitRFID2 unit;
2525
m5::unit::nfc::NFCLayerA nfc_a{unit};
26+
2627
// KeyA that can authenticate all blocks
2728
// If it's a different key value, change it
2829
constexpr Key keyA = DEFAULT_KEY; // Default as 0xFFFFFFFFFFFF
@@ -59,8 +60,8 @@ void setup()
5960
}
6061
lcd.fillScreen(0);
6162
lcd.setCursor(0, 0);
62-
lcd.printf("Please put the device and click A");
63-
M5.Log.printf("Please put the device and click A\n");
63+
lcd.printf("Please put the PICC and click A");
64+
M5.Log.printf("Please put the PICC and click A\n");
6465
}
6566

6667
void loop()
@@ -71,20 +72,23 @@ void loop()
7172

7273
if (M5.BtnA.wasClicked() || touch.wasClicked()) {
7374
lcd.fillRect(0, lcd.fontHeight(), lcd.width(), lcd.height() - lcd.fontHeight());
74-
std::vector<UID> devices;
75-
if (nfc_a.detect(devices)) {
75+
std::vector<UID> uids;
76+
if (nfc_a.detect(uids)) {
7677
// If multiple occurrences are detected, only the first one detected
77-
auto& uid = devices.front();
78-
if (nfc_a.activate(uid)) {
78+
auto& uid = uids.front();
79+
if (nfc_a.reactivate(uid)) {
80+
M5.Speaker.tone(2000, 30);
7981
M5.Log.printf("==== Dump %s %s %u/%u====\n", uid.uidAsString().c_str(), uid.typeAsString().c_str(),
8082
uid.userAreaSize(), uid.totalSize());
8183
nfc_a.dump(keyA); // Need key if MIFARE classic, Ignore key if not MIFARE classic
84+
8285
nfc_a.deactivate();
86+
M5.Log.printf("Please remove the PICC from the reader\n");
8387
} else {
8488
M5_LOGE("Failed to activate %s", uid.uidAsString().c_str());
8589
}
8690
} else {
87-
M5.Log.printf("No devices\n");
91+
M5.Log.printf("PICC NOT exists\n");
8892
}
8993
}
9094
}

examples/UnitUnified/NDEF/NDEF.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
/*
7+
Example using M5UnitUnified for UnitRFID2
8+
NDEF example
9+
*/
10+
#include "main/NDEF.cpp"

0 commit comments

Comments
 (0)