Skip to content

Commit d2831a1

Browse files
committed
Merge branch 'develop'
2 parents 3e7190f + 7308238 commit d2831a1

5 files changed

Lines changed: 56 additions & 31 deletions

File tree

library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "M5Unit-RFID",
33
"description": "Library for M5Stack UNIT RFID using M5UnitUnified",
4-
"keywords": "M5Stack UNIT RFIDT,M5UnitUnified",
4+
"keywords": "M5Stack UNIT RFID,M5UnitUnified",
55
"authors": {
66
"name": "M5Stack",
77
"url": "http://www.m5stack.com"
@@ -27,4 +27,4 @@
2727
"docs/html"
2828
]
2929
}
30-
}
30+
}

src/M5UnitUnifiedRFID.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
@mainpage M5Unit-RFID
1111
Library for Unit-RFID using M5UnitUnified.
1212
*/
13-
#ifndef M5_UNIT_UNIFIED_WEIGHT_HPP
14-
#define M5_UNIT_UNIFIED_WEIGHT_HPP
13+
#ifndef M5_UNIT_UNIFIED_RFID_HPP
14+
#define M5_UNIT_UNIFIED_RFID_HPP
1515

1616
#include "rfid/rfid.hpp"
1717
#include "rfid/mifare.hpp"

src/rfid/rfid.cpp

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace {
1414
constexpr char type_unknown[] = "Unknown";
1515
constexpr char type_classic[] = "MIFARE Classic";
1616
constexpr char type_classic_1K[] = "MIFARE Classsic 1K";
17+
constexpr char type_classic_2K[] = "MIFARE Classsic 2K";
1718
constexpr char type_classic_4K[] = "MIFARE Classsic 4K";
1819
constexpr char type_ultra_light[] = "MIFARE Ultralight";
1920
constexpr char type_ultra_light_c[] = "MIFARE UltralightC";
@@ -33,25 +34,25 @@ constexpr char type_iso14443_4[] = "ISO14443-4";
3334
constexpr char type_iso18092[] = "ISO18092";
3435
constexpr char type_not_completed[] = "NOT COMPLEDTED";
3536
constexpr const char* type_table[] = {
36-
type_unknown, //
37-
type_classic, type_classic_1K, type_classic_4K, // Classic
38-
type_ultra_light, type_ultra_light_c, // Light
39-
type_plus_2K, type_plus_4K, // Plus
40-
type_desfire_2K, type_desfire_4K, type_desfire_8K, // DESFire
41-
type_ntag203, type_ntag210u, type_ntag210, // NTAG
42-
type_ntag212, type_ntag213, type_ntag215, // NTAG
43-
type_ntag216, // NTAG
44-
type_iso14443_4, type_iso18092, //
37+
type_unknown, //
38+
type_classic, type_classic_1K, type_classic_2K, type_classic_4K, // Classic
39+
type_ultra_light, type_ultra_light_c, // Light
40+
type_plus_2K, type_plus_4K, // Plus
41+
type_desfire_2K, type_desfire_4K, type_desfire_8K, // DESFire
42+
type_ntag203, type_ntag210u, type_ntag210, // NTAG
43+
type_ntag212, type_ntag213, type_ntag215, // NTAG
44+
type_ntag216, // NTAG
45+
type_iso14443_4, type_iso18092, //
4546
};
4647

4748
// included system area
4849
constexpr uint16_t max_block_table[] = {
49-
0, // Unknown
50-
20, 64, 256, // Classic
51-
16, 48, // Light
52-
128, 256, // Plus
53-
0, 0, 0, // DESFire (Not has blocks, File base system)
54-
42, 19, 16, 40, 44, 134, 230 // NTAG
50+
0, // Unknown
51+
20, 64, 128, 256, // Classic
52+
16, 48, // Light
53+
128, 256, // Plus
54+
0, 0, 0, // DESFire (Not has blocks, File base system)
55+
42, 19, 16, 40, 44, 134, 230 // NTAG
5556
};
5657

5758
// [min/max]
@@ -60,6 +61,7 @@ constexpr uint8_t user_block_table[][2] = {
6061
// Classic
6162
{1, 19},
6263
{1, 63},
64+
{0, 127},
6365
{0, 255},
6466
// Light
6567
{4, 15},
@@ -82,10 +84,10 @@ constexpr uint8_t user_block_table[][2] = {
8284
};
8385

8486
constexpr uint8_t max_sector_table[] = {
85-
0, //
86-
5, 16, 40, // Classic
87-
0, 0, // Light
88-
32, 40, // Plus
87+
0, //
88+
5, 16, 32, 40, // Classic
89+
0, 0, // Light
90+
32, 40, // Plus
8991
};
9092

9193
} // namespace
@@ -117,14 +119,13 @@ Type get_type(const uint8_t sak)
117119
case 0x09:
118120
return Type::MIFARE_Classic;
119121
case 0x10:
122+
return Type::MIFARE_Plus_2K;
120123
case 0x11:
121-
return Type::MIFARE_Plus_2K; // or 4K
124+
return Type::MIFARE_Plus_4K;
122125
case 0x18:
123126
return Type::MIFARE_Classic_4K;
124127
case 0x19:
125-
// AN10833 says Classic 2K but does not exist as a product?
126-
[[fallthrough]];
127-
// Fall through
128+
return Type::MIFARE_Classic_2K;
128129
default:
129130
break;
130131
}

src/rfid/rfid.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ enum class Type : uint8_t {
7272
Unknown, //!< Unknown type
7373
MIFARE_Classic, //!< Also known as MIFARE Standard mini
7474
MIFARE_Classic_1K, //!< Also known as MIFARE Standard 1K
75+
MIFARE_Classic_2K, //!< Also known as MIFARE Standard 2K
7576
MIFARE_Classic_4K, //!< Also known as MIFARE Standard 4K
7677
MIFARE_UltraLight, //!< MIFARE Ultralight
7778
MIFARE_UltraLightC, //!< MIFARE UltralightC

test/embedded/test_ws1850s/ws1850s_test.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#include <googletest/test_template.hpp>
1414
#include <unit/unit_WS1850S.hpp>
1515
#include <M5Utility.hpp>
16-
//#include <chrono>
17-
//#include <cmath>
16+
// #include <chrono>
17+
// #include <cmath>
1818
#include <random>
19-
//#include <array>
19+
// #include <array>
2020
#include <cstring>
2121

2222
namespace {
@@ -30,7 +30,30 @@ using namespace m5::rfid;
3030
using namespace m5::rfid::mifare;
3131
using namespace m5::rfid::mifare::classic;
3232

33-
const ::testing::Environment* global_fixture = ::testing::AddGlobalTestEnvironment(new GlobalFixture<100 * 1000U>());
33+
class GlobalFixtureWS1850S : public GlobalFixture<100 * 1000U, 0> {
34+
public:
35+
void SetUp() override
36+
{
37+
auto pin_num_sda = M5.getPin(m5::pin_name_t::port_a_sda);
38+
auto pin_num_scl = M5.getPin(m5::pin_name_t::port_a_scl);
39+
40+
if (M5.getBoard() == m5::board_t::board_M5Dial) {
41+
// Using inner WS1850S
42+
pin_num_sda = M5.getPin(m5::pin_name_t::in_i2c_sda);
43+
pin_num_scl = M5.getPin(m5::pin_name_t::in_i2c_scl);
44+
}
45+
46+
TwoWire* w[2] = {&Wire, &Wire1};
47+
if (i2cIsInit(0)) {
48+
M5_LOGW("Already inititlized Wire. Terminate and restart");
49+
w[0]->end();
50+
}
51+
w[0]->begin(pin_num_sda, pin_num_scl, 100 * 1000U);
52+
}
53+
};
54+
55+
// const ::testing::Environment* global_fixture = ::testing::AddGlobalTestEnvironment(new GlobalFixture<100 * 1000U>());
56+
const ::testing::Environment* global_fixture = ::testing::AddGlobalTestEnvironment(new GlobalFixtureWS1850S());
3457

3558
class TestWS1850S : public ComponentTestBase<UnitWS1850S, bool> {
3659
protected:

0 commit comments

Comments
 (0)