Skip to content

Commit 86c7fd2

Browse files
committed
Fix scan global
1 parent 48c1a54 commit 86c7fd2

File tree

5 files changed

+64
-19
lines changed

5 files changed

+64
-19
lines changed

plugins/logicalaccess/plugins/readers/stidstr/readercardadapters/stidstrreadercardadapter.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ typedef enum {
2828
STID_CMD_MIFARE_PLUS = 0x03, /**< Mifare plus command type */
2929
STID_CMD_RESERVED = 0x04, /**< Reserved command type */
3030
STID_CMD_MIFARE_ULTRALIGHTC = 0x05, /**< Mifare ultralight C command type */
31-
STID_CMD_RFIDCHIP = 0x06 /**< RFID chip command type */
31+
STID_CMD_RFIDCHIP = 0x06, /**< RFID chip command type */
32+
STID_CMD_BLUENFC = 0x0f /**< Blue NFC command type */
3233
} STidCmdType;
3334

3435
/**

plugins/logicalaccess/plugins/readers/stidstr/stidstrreaderunit.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,18 @@ bool STidSTRReaderUnit::waitInsertion(unsigned int maxwait)
110110
do
111111
{
112112
std::shared_ptr<Chip> chip;
113-
if (!getSTidSTRConfiguration()->getUseScanGlobal())
113+
if (getSTidSTRConfiguration()->getScanMode() == STID_SCAN_LEGACY)
114114
{
115115
chip = scanARaw(); // scan14443A() => Obsolete. It's just used for testing purpose !
116116
if (!chip)
117117
{
118118
chip = scan14443B();
119119
}
120120
}
121+
else if (getSTidSTRConfiguration()->getScanMode() == STID_SCAN_LEGACY)
122+
{
123+
chip = scanBlueNFC();
124+
}
121125
else
122126
{
123127
chip = scanGlobal();
@@ -181,7 +185,7 @@ bool STidSTRReaderUnit::waitRemoval(unsigned int maxwait)
181185
do
182186
{
183187
std::shared_ptr<Chip> chip;
184-
if (!getSTidSTRConfiguration()->getUseScanGlobal())
188+
if (getSTidSTRConfiguration()->getScanMode() == STID_SCAN_LEGACY)
185189
{
186190
chip = scanARaw(); // scan14443A() => Obsolete. It's
187191
// just used for testing purpose
@@ -191,6 +195,10 @@ bool STidSTRReaderUnit::waitRemoval(unsigned int maxwait)
191195
chip = scan14443B();
192196
}
193197
}
198+
else if (getSTidSTRConfiguration()->getScanMode() == STID_SCAN_VIRTUAL)
199+
{
200+
chip = scanBlueNFC();
201+
}
194202
else
195203
{
196204
chip = scanGlobal();
@@ -705,6 +713,22 @@ std::shared_ptr<Chip> STidSTRReaderUnit::createGenericChipFromBuffer(const ByteV
705713
return chip;
706714
}
707715

716+
std::shared_ptr<Chip> STidSTRReaderUnit::scanBlueNFC(bool use_selected_key)
717+
{
718+
LOG(LogLevel::INFOS) << "Scanning for Blue NFC...";
719+
ByteVector command;
720+
command.push_back(use_selected_key ? 0x01 : 0x00);
721+
auto rca = std::make_shared<STidSTRReaderCardAdapter>(STID_PM_NORMAL, STID_CMD_BLUENFC);
722+
rca->setDataTransport(getDataTransport());
723+
ByteVector response = rca->sendCommand(0x000A, command);
724+
std::shared_ptr<Chip> chip;
725+
if (response.size() > 0)
726+
{
727+
chip = createGenericChipFromBuffer(response);
728+
}
729+
return chip;
730+
}
731+
708732
std::shared_ptr<Chip> STidSTRReaderUnit::scanGlobal()
709733
{
710734
return scanGlobal(true, true, true, true, true, false, true, true);
@@ -721,11 +745,11 @@ std::shared_ptr<Chip> STidSTRReaderUnit::scanGlobal(bool iso14443a, bool activeR
721745
//((touchCoordinates ? 1 : 0) << 2) |
722746
((imageScanEngine ? 1 : 0) << 1) |
723747
(keyboard ? 1 : 0);
724-
unsigned char filter2 = ((selectedKeyBlueNfc) ? 1 : 0 << 5) |
725-
((blueNfc) ? 1 : 0 << 4) |
726-
((lf125khz) ? 1 : 0 << 3) |
727-
((iso14443b) ? 1 : 0 << 2) |
728-
((activeRats) ? 1 : 0 << 1) |
748+
unsigned char filter2 = ((selectedKeyBlueNfc ? 1 : 0) << 5) |
749+
((blueNfc ? 1 : 0) << 4) |
750+
((lf125khz ? 1 : 0) << 3) |
751+
((iso14443b ? 1 : 0) << 2) |
752+
((activeRats ? 1 : 0) << 1) |
729753
(iso14443a ? 1 : 0);
730754

731755
command.push_back(filter1);
@@ -770,6 +794,9 @@ std::shared_ptr<Chip> STidSTRReaderUnit::scanGlobal(bool iso14443a, bool activeR
770794
case 0x40: // Config Card
771795
{
772796
} break;
797+
case 0x00: // No information
798+
{
799+
} break;
773800
default:
774801
{
775802
LOG(LogLevel::INFOS) << "Unknown info type.";

plugins/logicalaccess/plugins/readers/stidstr/stidstrreaderunit.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ class LLA_READERS_STIDSTR_API STidSTRReaderUnit : public ISO7816ReaderUnit
212212
*/
213213
std::shared_ptr<Chip> scan14443B();
214214

215+
/**
216+
* \brief Scan for virtual credential (BLE / NFC)
217+
* \param use_selected_key True to use key previously loaded with LoadKeyBlue_NFC + SelectKeyBlue_NFC, false to use key loaded by configuration with Load_Conf or LoadConf_xxxx.
218+
* \return The chip object if a tag is inserted.
219+
*/
220+
std::shared_ptr<Chip> scanBlueNFC(bool use_selected_key = false);
221+
215222
/**
216223
* \brief Scan the RFID field for a tag detection.
217224
* \return The chip object if a tag is inserted.

plugins/logicalaccess/plugins/readers/stidstr/stidstrreaderunitconfiguration.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void STidSTRReaderUnitConfiguration::resetConfiguration()
2828
d_communicationMode = STID_CM_PLAIN;
2929
d_protocolVersion = STID_SSCP_V1;
3030
d_pn532_direct = false;
31-
d_use_scan_global = true;
31+
d_scan_mode = STID_SCAN_LEGACY;
3232
d_key_hmac.reset(new HMAC1Key(""));
3333
d_key_aes.reset(new AES128Key(""));
3434
}
@@ -42,7 +42,7 @@ void STidSTRReaderUnitConfiguration::serialize(boost::property_tree::ptree &pare
4242
node.put("CommunicationMode", d_communicationMode);
4343
node.put("PN532Direct", d_pn532_direct);
4444
node.put("Protocolversion", d_protocolVersion);
45-
node.put("UseScanGlobal", d_use_scan_global);
45+
node.put("ScanMode", d_scan_mode);
4646
d_key_hmac->serialize(node);
4747
d_key_aes->serialize(node);
4848

@@ -61,7 +61,8 @@ void STidSTRReaderUnitConfiguration::unSerialize(boost::property_tree::ptree &no
6161
d_pn532_direct = node.get_child("PN532Direct").get_value<bool>();
6262
d_protocolVersion = static_cast<STidProtocolVersion>(
6363
node.get_child("ProtocolVersion").get_value<unsigned int>());
64-
d_use_scan_global = node.get_child("UseScanGlobal").get_value<bool>();
64+
d_scan_mode = static_cast<STidScanMode>(
65+
node.get_child("ScanMode").get_value<unsigned int>());
6566
d_key_hmac->unSerialize(node.get_child(d_key_hmac->getDefaultXmlNodeName()));
6667
d_key_aes->unSerialize(node.get_child(d_key_aes->getDefaultXmlNodeName()));
6768
}
@@ -95,14 +96,14 @@ void STidSTRReaderUnitConfiguration::setPN532Direct(bool direct)
9596
d_pn532_direct = direct;
9697
}
9798

98-
bool STidSTRReaderUnitConfiguration::getUseScanGlobal() const
99+
STidScanMode STidSTRReaderUnitConfiguration::getScanMode() const
99100
{
100-
return d_use_scan_global;
101+
return d_scan_mode;
101102
}
102103

103-
void STidSTRReaderUnitConfiguration::setUseScanGlobal(bool use)
104+
void STidSTRReaderUnitConfiguration::setScanMode(STidScanMode mode)
104105
{
105-
d_use_scan_global = use;
106+
d_scan_mode = mode;
106107
}
107108

108109
STidCommunicationType STidSTRReaderUnitConfiguration::getCommunicationType() const

plugins/logicalaccess/plugins/readers/stidstr/stidstrreaderunitconfiguration.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ typedef enum {
4141
STID_SSCP_V2 = 0x01 /**< SSCP v2 */
4242
} STidProtocolVersion;
4343

44+
/**
45+
* \brief The STid scan mode.
46+
*/
47+
typedef enum {
48+
STID_SCAN_LEGACY = 0x00, /** Use scanARaw/scan14443B */
49+
STID_SCAN_VIRTUAL = 0x0f, /** Use scanBlueNFC */
50+
STID_SCAN_GLOBAL = 0xff /** Use scanGlobal */
51+
} STidScanMode;
52+
4453
/**
4554
* \brief The STidSTR reader unit configuration base class.
4655
*/
@@ -157,9 +166,9 @@ class LLA_READERS_STIDSTR_API STidSTRReaderUnitConfiguration
157166

158167
void setPN532Direct(bool direct);
159168

160-
bool getUseScanGlobal() const;
169+
STidScanMode getScanMode() const;
161170

162-
void setUseScanGlobal(bool use);
171+
void setScanMode(STidScanMode mode);
163172

164173
protected:
165174
/**
@@ -198,9 +207,9 @@ class LLA_READERS_STIDSTR_API STidSTRReaderUnitConfiguration
198207
bool d_pn532_direct;
199208

200209
/**
201-
* \brief True to use Scan Global command. False to use the old way with scanARaw/scan14443B
210+
* \brief The scan mode.
202211
*/
203-
bool d_use_scan_global;
212+
STidScanMode d_scan_mode;
204213
};
205214
}
206215

0 commit comments

Comments
 (0)