Add NCI 2.0 tests.
Add tests for initialize/deinitialize and discovery start/stop using NCI 2.0.
This commit is contained in:
Родитель
8f60fb9124
Коммит
35536d7419
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// Copyright (c) Microsoft Corporation. All Rights Reserved
|
||||
//
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#include "DeviceQuery.h"
|
||||
#include "DriverHandleFactory.h"
|
||||
|
||||
std::wstring
|
||||
DriverHandleFactory::FindProximityInterfaceForDevice(_In_ PCWSTR deviceName)
|
||||
{
|
||||
// Find the proximity interface for the device.
|
||||
std::vector<std::wstring> nfpInterfaces = DeviceQuery::FindDriverInterfaces(deviceName, GUID_DEVINTERFACE_NFP);
|
||||
|
||||
// Only a single interface is expected to be found.
|
||||
VERIFY_ARE_EQUAL(1u, nfpInterfaces.size());
|
||||
return std::move(nfpInterfaces[0]);
|
||||
}
|
||||
|
||||
std::wstring
|
||||
DriverHandleFactory::FindSmartcardInterfaceForDevice(
|
||||
_In_ PCWSTR deviceName,
|
||||
_In_ ::ABI::Windows::Devices::SmartCards::SmartCardReaderKind readerKind)
|
||||
{
|
||||
std::vector<std::wstring> nfcScInterfaces = DeviceQuery::GetSmartcardInterfacesOfType(deviceName, BYTE(readerKind));
|
||||
VERIFY_ARE_EQUAL(1u, nfcScInterfaces.size());
|
||||
|
||||
return std::move(nfcScInterfaces[0]);
|
||||
}
|
||||
|
||||
UniqueHandle
|
||||
DriverHandleFactory::OpenSubscriptionHandle(_In_ PCWSTR deviceName, _In_ PCWSTR messageType)
|
||||
{
|
||||
// Find the proximity interface for the device.
|
||||
std::wstring subId = FindProximityInterfaceForDevice(deviceName);
|
||||
|
||||
// Create the name for the subscription.
|
||||
subId += L"\\Subs\\";
|
||||
subId += messageType;
|
||||
|
||||
// Open the device handle.
|
||||
UniqueHandle nfpSubInterface(CreateFile(
|
||||
subId.c_str(),
|
||||
GENERIC_READ,
|
||||
0,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
nullptr));
|
||||
VERIFY_WIN32_BOOL_SUCCEEDED(INVALID_HANDLE_VALUE != nfpSubInterface.Get());
|
||||
|
||||
return std::move(nfpSubInterface);
|
||||
}
|
||||
|
||||
UniqueHandle
|
||||
DriverHandleFactory::OpenSmartcardHandle(
|
||||
_In_ PCWSTR deviceName,
|
||||
_In_ ::ABI::Windows::Devices::SmartCards::SmartCardReaderKind readerKind)
|
||||
{
|
||||
std::wstring smartcardInterfaceName = FindSmartcardInterfaceForDevice(deviceName, readerKind);
|
||||
|
||||
UniqueHandle scInterface(CreateFile(
|
||||
smartcardInterfaceName.c_str(),
|
||||
GENERIC_READ,
|
||||
0,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
nullptr));
|
||||
VERIFY_WIN32_BOOL_SUCCEEDED(INVALID_HANDLE_VALUE != scInterface.Get());
|
||||
|
||||
return std::move(scInterface);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// Copyright (c) Microsoft Corporation. All Rights Reserved
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "UniqueHandle.h"
|
||||
|
||||
class DriverHandleFactory
|
||||
{
|
||||
public:
|
||||
static std::wstring FindProximityInterfaceForDevice(_In_ PCWSTR deviceName);
|
||||
static std::wstring FindSmartcardInterfaceForDevice(
|
||||
_In_ PCWSTR deviceName,
|
||||
_In_ ::ABI::Windows::Devices::SmartCards::SmartCardReaderKind readerKind);
|
||||
static UniqueHandle OpenSubscriptionHandle(_In_ PCWSTR deviceName, _In_ PCWSTR messageType);
|
||||
static UniqueHandle OpenSmartcardHandle(
|
||||
_In_ PCWSTR deviceName,
|
||||
_In_ ::ABI::Windows::Devices::SmartCards::SmartCardReaderKind readerKind);
|
||||
};
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// Copyright (c) Microsoft Corporation. All Rights Reserved
|
||||
//
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#include "DeviceQuery.h"
|
||||
#include "ProximityHandleFactory.h"
|
||||
|
||||
std::wstring
|
||||
ProximityHandleFactory::FindProximityInterfaceForDevice(_In_ PCWSTR deviceName)
|
||||
{
|
||||
// Find the proximity interface for the device.
|
||||
std::vector<std::wstring> nfpInterfaces = DeviceQuery::FindDriverInterfaces(deviceName, GUID_DEVINTERFACE_NFP);
|
||||
|
||||
// Only a single interface is expected to be found.
|
||||
VERIFY_ARE_EQUAL(1u, nfpInterfaces.size());
|
||||
return std::move(nfpInterfaces[0]);
|
||||
}
|
||||
|
||||
UniqueHandle
|
||||
ProximityHandleFactory::OpenSubscriptionHandle(_In_ PCWSTR deviceName, _In_ PCWSTR messageType)
|
||||
{
|
||||
// Find the proximity interface for the device.
|
||||
std::wstring subId = FindProximityInterfaceForDevice(deviceName);
|
||||
|
||||
// Create the name for the subscription.
|
||||
subId += L"\\Subs\\";
|
||||
subId += messageType;
|
||||
|
||||
// Open the device handle.
|
||||
UniqueHandle nfpSubInterface(CreateFile(
|
||||
subId.c_str(),
|
||||
GENERIC_READ,
|
||||
0,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
nullptr));
|
||||
VERIFY_WIN32_BOOL_SUCCEEDED(INVALID_HANDLE_VALUE != nfpSubInterface.Get());
|
||||
|
||||
return std::move(nfpSubInterface);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
//
|
||||
// Copyright (c) Microsoft Corporation. All Rights Reserved
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "UniqueHandle.h"
|
||||
|
||||
class ProximityHandleFactory
|
||||
{
|
||||
public:
|
||||
static std::wstring FindProximityInterfaceForDevice(_In_ PCWSTR deviceName);
|
||||
static UniqueHandle OpenSubscriptionHandle(_In_ PCWSTR deviceName, _In_ PCWSTR messageType);
|
||||
};
|
|
@ -79,9 +79,9 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="IOHelpers\DeviceQuery.h" />
|
||||
<ClInclude Include="IOHelpers\DriverHandleFactory.h" />
|
||||
<ClInclude Include="IOHelpers\IoOperation.h" />
|
||||
<ClInclude Include="IOHelpers\Precomp.h" />
|
||||
<ClInclude Include="IOHelpers\ProximityHandleFactory.h" />
|
||||
<ClInclude Include="IOHelpers\RadioManager.h" />
|
||||
<ClInclude Include="IOHelpers\UniqueHandle.h" />
|
||||
<ClInclude Include="SimulationSequences\InitSequences.h" />
|
||||
|
@ -95,6 +95,7 @@
|
|||
<ClInclude Include="Simulation\Precomp.h" />
|
||||
<ClInclude Include="Simulation\SimSequenceRunner.h" />
|
||||
<ClInclude Include="Simulation\SimSequenceStep.h" />
|
||||
<ClInclude Include="Simulation\SimSequenceView.h" />
|
||||
<ClInclude Include="Simulation\TagPayloads.h" />
|
||||
<ClInclude Include="Simulation\VerifyHelpers.h" />
|
||||
<ClInclude Include="Tests\Module.h" />
|
||||
|
@ -103,8 +104,8 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="IOHelpers\DeviceQuery.cpp" />
|
||||
<ClCompile Include="IOHelpers\DriverHandleFactory.cpp" />
|
||||
<ClCompile Include="IOHelpers\IoOperation.cpp" />
|
||||
<ClCompile Include="IOHelpers\ProximityHandleFactory.cpp" />
|
||||
<ClCompile Include="IOHelpers\RadioManager.cpp" />
|
||||
<ClCompile Include="IOHelpers\UniqueHandle.cpp" />
|
||||
<ClCompile Include="SimulationSequences\InitSequences.cpp" />
|
||||
|
@ -116,6 +117,7 @@
|
|||
<ClCompile Include="Simulation\NciSimConnector.cpp" />
|
||||
<ClCompile Include="Simulation\SimSequenceRunner.cpp" />
|
||||
<ClCompile Include="Simulation\SimSequenceStep.cpp" />
|
||||
<ClCompile Include="Simulation\SimSequenceView.cpp" />
|
||||
<ClCompile Include="Simulation\TagPayloads.cpp" />
|
||||
<ClCompile Include="Simulation\VerifyHelpers.cpp" />
|
||||
<ClCompile Include="Tests\AirplaneModeTests.cpp" />
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
<ClInclude Include="IOHelpers\Precomp.h">
|
||||
<Filter>IOHelpers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IOHelpers\ProximityHandleFactory.h">
|
||||
<Filter>IOHelpers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IOHelpers\RadioManager.h">
|
||||
<Filter>IOHelpers</Filter>
|
||||
</ClInclude>
|
||||
|
@ -81,6 +78,12 @@
|
|||
<ClInclude Include="Tests\TestLogging.h">
|
||||
<Filter>Tests</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IOHelpers\DriverHandleFactory.h">
|
||||
<Filter>IOHelpers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Simulation\SimSequenceView.h">
|
||||
<Filter>Simulation</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="IOHelpers\DeviceQuery.cpp">
|
||||
|
@ -89,9 +92,6 @@
|
|||
<ClCompile Include="IOHelpers\IoOperation.cpp">
|
||||
<Filter>IOHelpers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IOHelpers\ProximityHandleFactory.cpp">
|
||||
<Filter>IOHelpers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IOHelpers\RadioManager.cpp">
|
||||
<Filter>IOHelpers</Filter>
|
||||
</ClCompile>
|
||||
|
@ -146,5 +146,11 @@
|
|||
<ClCompile Include="Tests\TestLogging.cpp">
|
||||
<Filter>Tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IOHelpers\DriverHandleFactory.cpp">
|
||||
<Filter>IOHelpers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Simulation\SimSequenceView.cpp">
|
||||
<Filter>Simulation</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -11,48 +11,54 @@
|
|||
void
|
||||
SimSequenceRunner::Run(
|
||||
_In_ NciSimConnector& simConnector,
|
||||
_In_reads_(stepListSize) const SimSequenceStep* stepList,
|
||||
_In_ size_t stepListSize)
|
||||
_In_ const SimSequenceStep& step)
|
||||
{
|
||||
for (const SimSequenceStep* itr = stepList; itr != stepList + stepListSize; ++itr)
|
||||
LOG_COMMENT(L"# Step: %s.", step.StepName.c_str());
|
||||
|
||||
switch (step.Type)
|
||||
{
|
||||
const SimSequenceStep& step = *itr;
|
||||
case SimSequenceStepType::NciWrite:
|
||||
{
|
||||
NciSimCallbackView message = simConnector.ReceiveCallback();
|
||||
VerifyNciPacket(step.NciPacketData, message);
|
||||
|
||||
LOG_COMMENT(L"# Step: %s.", step.StepName.c_str());
|
||||
simConnector.SendNciWriteCompleted();
|
||||
|
||||
switch (step.Type)
|
||||
{
|
||||
case SimSequenceStepType::NciWrite:
|
||||
{
|
||||
NciSimCallbackView message = simConnector.ReceiveCallback();
|
||||
VerifyNciPacket(step.NciPacketData, message);
|
||||
break;
|
||||
}
|
||||
case SimSequenceStepType::NciRead:
|
||||
{
|
||||
LogByteBuffer(L"Packet", step.NciPacketData.PacketBytes(), step.NciPacketData.PacketBytesLength());
|
||||
simConnector.SendNciRead(step.NciPacketData);
|
||||
break;
|
||||
}
|
||||
case SimSequenceStepType::SequenceHandler:
|
||||
{
|
||||
NciSimCallbackView message = simConnector.ReceiveCallback();
|
||||
VerifySequenceHandler(step.SequenceHandlerType, message);
|
||||
|
||||
simConnector.SendNciWriteCompleted();
|
||||
|
||||
break;
|
||||
}
|
||||
case SimSequenceStepType::NciRead:
|
||||
{
|
||||
LogByteBuffer(L"Packet", step.NciPacketData.PacketBytes(), step.NciPacketData.PacketBytesLength());
|
||||
simConnector.SendNciRead(step.NciPacketData);
|
||||
break;
|
||||
}
|
||||
case SimSequenceStepType::SequenceHandler:
|
||||
{
|
||||
NciSimCallbackView message = simConnector.ReceiveCallback();
|
||||
VerifySequenceHandler(step.SequenceHandlerType, message);
|
||||
|
||||
simConnector.SendSequenceCompleted(step.SequenceHandlerStatus, step.SequenceHandlerFlags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
simConnector.SendSequenceCompleted(step.SequenceHandlerStatus, step.SequenceHandlerFlags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SimSequenceRunner::Run(
|
||||
_In_ NciSimConnector& simConnector,
|
||||
_In_ const SimSequenceStep& step)
|
||||
_In_reads_(stepListSize) const SimSequenceStep* stepList,
|
||||
_In_ size_t stepListSize)
|
||||
{
|
||||
Run(simConnector, &step, 1);
|
||||
for (const SimSequenceStep* itr = stepList; itr != stepList + stepListSize; ++itr)
|
||||
{
|
||||
Run(simConnector, *itr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SimSequenceRunner::Run(
|
||||
NciSimConnector& simConnector,
|
||||
SimSequenceView sequence)
|
||||
{
|
||||
Run(simConnector, sequence.GetList(), sequence.GetListSize());
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "NciControlPacket.h"
|
||||
#include "NciSimConnector.h"
|
||||
#include "SimSequenceView.h"
|
||||
#include "SimSequenceStep.h"
|
||||
|
||||
class SimSequenceRunner
|
||||
|
@ -13,12 +14,12 @@ class SimSequenceRunner
|
|||
public:
|
||||
static void Run(
|
||||
_In_ NciSimConnector& simConnector,
|
||||
_In_reads_(stepListSize) const SimSequenceStep* stepList,
|
||||
_In_ size_t stepListSize);
|
||||
_In_ const SimSequenceStep& step);
|
||||
|
||||
static void Run(
|
||||
_In_ NciSimConnector& simConnector,
|
||||
_In_ const SimSequenceStep& step);
|
||||
_In_reads_(stepListSize) const SimSequenceStep* stepList,
|
||||
_In_ size_t stepListSize);
|
||||
|
||||
template <size_t ArraySize>
|
||||
static void Run(
|
||||
|
@ -27,4 +28,8 @@ public:
|
|||
{
|
||||
Run(simConnector, stepList, ArraySize);
|
||||
}
|
||||
|
||||
static void Run(
|
||||
NciSimConnector& simConnector,
|
||||
SimSequenceView sequence);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// Copyright (c) Microsoft Corporation. All Rights Reserved
|
||||
//
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#include "SimSequenceView.h"
|
||||
|
||||
SimSequenceView::SimSequenceView(
|
||||
_In_reads_(stepListSize) const SimSequenceStep* list,
|
||||
_In_ size_t listSize)
|
||||
:
|
||||
_List(list),
|
||||
_ListSize(listSize)
|
||||
{
|
||||
}
|
||||
|
||||
const SimSequenceStep*
|
||||
SimSequenceView::GetList() const
|
||||
{
|
||||
return _List;
|
||||
}
|
||||
|
||||
size_t
|
||||
SimSequenceView::GetListSize() const
|
||||
{
|
||||
return _ListSize;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// Copyright (c) Microsoft Corporation. All Rights Reserved
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SimSequenceStep.h"
|
||||
|
||||
// A array view of SimSequenceStep.
|
||||
// WARNING: This type does not own the memory that it references.
|
||||
class SimSequenceView
|
||||
{
|
||||
public:
|
||||
SimSequenceView(
|
||||
_In_reads_(stepListSize) const SimSequenceStep* list,
|
||||
_In_ size_t listSize);
|
||||
|
||||
template <size_t ArraySize>
|
||||
SimSequenceView(
|
||||
const SimSequenceStep (&list)[ArraySize])
|
||||
:
|
||||
SimSequenceView(list, ArraySize)
|
||||
{
|
||||
}
|
||||
|
||||
const SimSequenceStep* GetList() const;
|
||||
size_t GetListSize() const;
|
||||
|
||||
private:
|
||||
const SimSequenceStep* _List = nullptr;
|
||||
size_t _ListSize = 0;
|
||||
};
|
|
@ -24,7 +24,7 @@ const SimSequenceStep InitSequences::NciResetCommand = SimSequenceStep::NciContr
|
|||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::NciResetResponse = SimSequenceStep::NciControlRead(
|
||||
const SimSequenceStep InitSequences::NciResetResponse_Nci1 = SimSequenceStep::NciControlRead(
|
||||
L"CORE_RESET_RSP",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 1.1, Section 4.1, CORE_RESET_RSP
|
||||
|
@ -39,6 +39,36 @@ const SimSequenceStep InitSequences::NciResetResponse = SimSequenceStep::NciCont
|
|||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::NciResetResponse_Nci2 = SimSequenceStep::NciControlRead(
|
||||
L"CORE_RESET_RSP",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 2.0, Section 4.1, CORE_RESET_RSP
|
||||
phNciNfc_e_NciCoreMsgTypeCntrlRsp,
|
||||
phNciNfc_e_CoreNciCoreGid,
|
||||
phNciNfc_e_NciCoreResetCmdOid,
|
||||
{
|
||||
PH_NCINFC_STATUS_OK, // Status
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::NciResetNotification_Nci2 = SimSequenceStep::NciControlRead(
|
||||
L"CORE_RESET_NTF",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 2.0, Section 4.1, CORE_RESET_NTF
|
||||
phNciNfc_e_NciCoreMsgTypeCntrlNtf,
|
||||
phNciNfc_e_CoreNciCoreGid,
|
||||
phNciNfc_e_NciCoreResetCmdOid,
|
||||
{
|
||||
0x02, // Reset trigger
|
||||
0x00, // Configuration status (configuration kept)
|
||||
0x20, // Nci version
|
||||
0x00, // Manufacturer ID
|
||||
0x00, // Manufacturer info length
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::PreInitialize = SimSequenceStep::SequenceHandler(
|
||||
L"SequencePreInit",
|
||||
SequencePreInit,
|
||||
|
@ -46,7 +76,7 @@ const SimSequenceStep InitSequences::InitializeNoSEs::PreInitialize = SimSequenc
|
|||
NFC_CX_SEQUENCE_PRE_INIT_FLAG_SKIP_CONFIG
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::InitializeCommand = SimSequenceStep::NciControlWrite(
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::InitializeCommand_Nci1 = SimSequenceStep::NciControlWrite(
|
||||
L"CORE_INIT_CMD",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 1.1, Section 4.2, CORE_INIT_CMD
|
||||
|
@ -56,7 +86,20 @@ const SimSequenceStep InitSequences::InitializeNoSEs::InitializeCommand = SimSeq
|
|||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::InitializeResponse = SimSequenceStep::NciControlRead(
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::InitializeCommand_Nci2 = SimSequenceStep::NciControlWrite(
|
||||
L"CORE_INIT_CMD",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 2.0, Section 4.2, CORE_INIT_CMD
|
||||
phNciNfc_e_NciCoreMsgTypeCntrlCmd,
|
||||
phNciNfc_e_CoreNciCoreGid,
|
||||
phNciNfc_e_NciCoreInitCmdOid,
|
||||
{
|
||||
0x00, 0x00, // Feature enable (disable all post NCI 2.0 features)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::InitializeResponse_Nci1 = SimSequenceStep::NciControlRead(
|
||||
L"CORE_INIT_RSP",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 1.1, Section 4.2, CORE_INIT_RSP
|
||||
|
@ -65,9 +108,9 @@ const SimSequenceStep InitSequences::InitializeNoSEs::InitializeResponse = SimSe
|
|||
phNciNfc_e_NciCoreInitCmdOid,
|
||||
{
|
||||
PH_NCINFC_STATUS_OK, // Status
|
||||
0b00000011, // Supported discovery config
|
||||
0b00011110, // Supported routing types
|
||||
0b00000011, // Supported routing power modes
|
||||
0b00000011, // Supported discovery config (Merges RF config, Frequency config supported)
|
||||
0b00011110, // Supported routing types (Technology, Protocol, AID, NFCID2)
|
||||
0b00000011, // Supported routing power modes (Switched off, Battery off)
|
||||
0b00000000, // Proprietary capabilities
|
||||
5, // Number of supported interfaces, that follow.
|
||||
phNciNfc_e_RfInterfacesNfceeDirect_RF,
|
||||
|
@ -85,6 +128,45 @@ const SimSequenceStep InitSequences::InitializeNoSEs::InitializeResponse = SimSe
|
|||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::InitializeResponse_Nci2 = SimSequenceStep::NciControlRead(
|
||||
L"CORE_INIT_RSP",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 2.0, Section 4.2, CORE_INIT_RSP
|
||||
phNciNfc_e_NciCoreMsgTypeCntrlRsp,
|
||||
phNciNfc_e_CoreNciCoreGid,
|
||||
phNciNfc_e_NciCoreInitCmdOid,
|
||||
{
|
||||
PH_NCINFC_STATUS_OK,
|
||||
0b00000011, // Supported discovery config (Merges RF config, Frequency config supported)
|
||||
0b00011110, // Supported routing types (Technology, Protocol, AID, System code)
|
||||
0b00000011, // Supported routing power modes (Switched off, Battery off)
|
||||
0b00000000, // Proprietary capabilities
|
||||
0xFF, 0xFF, // Max routing table size
|
||||
0xFF, // Max control packet payload size
|
||||
0xFF, // Max static HCI packet size
|
||||
0xFF, // Number of static HCI credits (no flow control)
|
||||
0xFF, 0xFF, // Max NFC-V RF frame size
|
||||
5, // Number of supported interfaces, that follow.
|
||||
phNciNfc_e_RfInterfacesNfceeDirect_RF, // Interface
|
||||
0, // Number of extensions
|
||||
|
||||
phNciNfc_e_RfInterfacesFrame_RF, // Interface
|
||||
0, // Number of extensions
|
||||
|
||||
phNciNfc_e_RfInterfacesISODEP_RF, // Interface
|
||||
0, // Number of extensions
|
||||
|
||||
phNciNfc_e_RfInterfacesNFCDEP_RF, // Interface
|
||||
0, // Number of extensions
|
||||
|
||||
phNciNfc_e_RfInterfacesTagCmd_RF, // Interface
|
||||
0, // Number of extensions
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::InitializeComplete = SimSequenceStep::SequenceHandler(
|
||||
L"SequenceInitComplete",
|
||||
SequenceInitComplete,
|
||||
|
@ -146,7 +228,7 @@ const SimSequenceStep InitSequences::InitializeNoSEs::PreNfceeDiscovery = SimSeq
|
|||
0
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::NfceeDiscoverCommand = SimSequenceStep::NciControlWrite(
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::NfceeDiscoverCommand_Nci1 = SimSequenceStep::NciControlWrite(
|
||||
L"NFCEE_DISCOVER_CMD",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 1.1, Section 9.2, NFCEE_DISCOVER_CMD
|
||||
|
@ -159,6 +241,16 @@ const SimSequenceStep InitSequences::InitializeNoSEs::NfceeDiscoverCommand = Sim
|
|||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::NfceeDiscoverCommand_Nci2 = SimSequenceStep::NciControlWrite(
|
||||
L"NFCEE_DISCOVER_CMD",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 1.1, Section 9.2, NFCEE_DISCOVER_CMD
|
||||
phNciNfc_e_NciCoreMsgTypeCntrlCmd,
|
||||
phNciNfc_e_CoreNfceeMgtGid,
|
||||
phNciNfc_e_NfceeMgtNfceeDiscCmdOid,
|
||||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::NfceeDiscoverResponse = SimSequenceStep::NciControlRead(
|
||||
L"NFCEE_DISCOVER_RSP",
|
||||
{
|
||||
|
@ -194,29 +286,80 @@ const SimSequenceStep InitSequences::Uninitialize::ShutdownComplete = SimSequenc
|
|||
0
|
||||
);
|
||||
|
||||
// Error-free NCI initialize.
|
||||
// Error-free NCI 1.1 initialize.
|
||||
// Reports 0 attached SEs.
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::Sequence[12] =
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::Sequence_Nci1[12] =
|
||||
{
|
||||
PreInitialize,
|
||||
NciResetCommand,
|
||||
NciResetResponse,
|
||||
InitializeCommand,
|
||||
InitializeResponse,
|
||||
NciResetResponse_Nci1,
|
||||
InitializeCommand_Nci1,
|
||||
InitializeResponse_Nci1,
|
||||
InitializeComplete,
|
||||
GetConfigCommand,
|
||||
GetConfigResponse,
|
||||
PreNfceeDiscovery,
|
||||
NfceeDiscoverCommand,
|
||||
NfceeDiscoverCommand_Nci1,
|
||||
NfceeDiscoverResponse,
|
||||
NfceeDiscoveryComplete,
|
||||
};
|
||||
|
||||
// Error-free NCI uninitialize.
|
||||
const SimSequenceStep InitSequences::Uninitialize::Sequence[4] =
|
||||
// Error-free NCI 2.0 initialize.
|
||||
// Reports 0 attached SEs.
|
||||
const SimSequenceStep InitSequences::InitializeNoSEs::Sequence_Nci2[13] =
|
||||
{
|
||||
PreInitialize,
|
||||
NciResetCommand,
|
||||
NciResetResponse_Nci2,
|
||||
NciResetNotification_Nci2,
|
||||
InitializeCommand_Nci2,
|
||||
InitializeResponse_Nci2,
|
||||
InitializeComplete,
|
||||
GetConfigCommand,
|
||||
GetConfigResponse,
|
||||
PreNfceeDiscovery,
|
||||
NfceeDiscoverCommand_Nci2,
|
||||
NfceeDiscoverResponse,
|
||||
NfceeDiscoveryComplete,
|
||||
};
|
||||
|
||||
const SimSequenceView
|
||||
InitSequences::InitializeNoSEs::Sequence(bool isNci2)
|
||||
{
|
||||
if (isNci2)
|
||||
{
|
||||
return Sequence_Nci2;
|
||||
}
|
||||
|
||||
return Sequence_Nci1;
|
||||
}
|
||||
|
||||
// Error-free NCI 1.1 uninitialize.
|
||||
const SimSequenceStep InitSequences::Uninitialize::Sequence_Nci1[4] =
|
||||
{
|
||||
PreShutdown,
|
||||
NciResetCommand,
|
||||
NciResetResponse,
|
||||
NciResetResponse_Nci1,
|
||||
ShutdownComplete,
|
||||
};
|
||||
|
||||
// Error-free NCI 2.0 uninitialize.
|
||||
const SimSequenceStep InitSequences::Uninitialize::Sequence_Nci2[5] =
|
||||
{
|
||||
PreShutdown,
|
||||
NciResetCommand,
|
||||
NciResetResponse_Nci2,
|
||||
NciResetNotification_Nci2,
|
||||
ShutdownComplete,
|
||||
};
|
||||
|
||||
const SimSequenceView
|
||||
InitSequences::Uninitialize::Sequence(bool isNci2)
|
||||
{
|
||||
if (isNci2)
|
||||
{
|
||||
return Sequence_Nci2;
|
||||
}
|
||||
|
||||
return Sequence_Nci1;
|
||||
}
|
||||
|
|
|
@ -4,28 +4,36 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <Simulation/SimSequenceView.h>
|
||||
#include <Simulation/SimSequenceStep.h>
|
||||
|
||||
// Common NCI command/response sequences relating to NCI initialize and uninitialize.
|
||||
struct InitSequences
|
||||
{
|
||||
static const SimSequenceStep NciResetCommand;
|
||||
static const SimSequenceStep NciResetResponse;
|
||||
static const SimSequenceStep NciResetResponse_Nci1;
|
||||
static const SimSequenceStep NciResetResponse_Nci2;
|
||||
static const SimSequenceStep NciResetNotification_Nci2;
|
||||
|
||||
struct InitializeNoSEs
|
||||
{
|
||||
static const SimSequenceStep PreInitialize;
|
||||
static const SimSequenceStep InitializeCommand;
|
||||
static const SimSequenceStep InitializeResponse;
|
||||
static const SimSequenceStep InitializeCommand_Nci1;
|
||||
static const SimSequenceStep InitializeCommand_Nci2;
|
||||
static const SimSequenceStep InitializeResponse_Nci1;
|
||||
static const SimSequenceStep InitializeResponse_Nci2;
|
||||
static const SimSequenceStep InitializeComplete;
|
||||
static const SimSequenceStep GetConfigCommand;
|
||||
static const SimSequenceStep GetConfigResponse;
|
||||
static const SimSequenceStep PreNfceeDiscovery;
|
||||
static const SimSequenceStep NfceeDiscoverCommand;
|
||||
static const SimSequenceStep NfceeDiscoverCommand_Nci1;
|
||||
static const SimSequenceStep NfceeDiscoverCommand_Nci2;
|
||||
static const SimSequenceStep NfceeDiscoverResponse;
|
||||
static const SimSequenceStep NfceeDiscoveryComplete;
|
||||
|
||||
static const SimSequenceStep Sequence[12];
|
||||
static const SimSequenceStep Sequence_Nci1[12];
|
||||
static const SimSequenceStep Sequence_Nci2[13];
|
||||
static const SimSequenceView Sequence(bool isNci2);
|
||||
};
|
||||
|
||||
struct Uninitialize
|
||||
|
@ -33,6 +41,8 @@ struct InitSequences
|
|||
static const SimSequenceStep PreShutdown;
|
||||
static const SimSequenceStep ShutdownComplete;
|
||||
|
||||
static const SimSequenceStep Sequence[4];
|
||||
static const SimSequenceStep Sequence_Nci1[4];
|
||||
static const SimSequenceStep Sequence_Nci2[5];
|
||||
static const SimSequenceView Sequence(bool isNci2);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -64,7 +64,7 @@ const SimSequenceStep RfDiscoverySequences::DiscoveryStart::GetConfigResponse =
|
|||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep RfDiscoverySequences::DiscoveryStart::DiscoverCommand = SimSequenceStep::NciControlWrite(
|
||||
const SimSequenceStep RfDiscoverySequences::DiscoveryStart::DiscoverCommand_Nci1 = SimSequenceStep::NciControlWrite(
|
||||
L"RF_DISCOVER_CMD",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 1.1, Section 7.1, RF_DISCOVER_CMD
|
||||
|
@ -109,6 +109,45 @@ const SimSequenceStep RfDiscoverySequences::DiscoveryStart::DiscoverCommand = Si
|
|||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep RfDiscoverySequences::DiscoveryStart::DiscoverCommand_Nci2 = SimSequenceStep::NciControlWrite(
|
||||
L"RF_DISCOVER_CMD",
|
||||
{
|
||||
// NFC Controller Interface (NCI), Version 1.1, Section 7.1, RF_DISCOVER_CMD
|
||||
phNciNfc_e_NciCoreMsgTypeCntrlCmd,
|
||||
phNciNfc_e_CoreRfMgtGid,
|
||||
phNciNfc_e_RfMgtRfDiscoverCmdOid,
|
||||
{
|
||||
9, // Number of parameters, that follow.
|
||||
phNciNfc_NFCA_Active_Poll,
|
||||
1, // Poll every discovery loop
|
||||
|
||||
phNciNfc_NFCA_Poll,
|
||||
1, // Poll every discovery loop
|
||||
|
||||
phNciNfc_NFCB_Poll,
|
||||
1, // Poll every discovery loop
|
||||
|
||||
phNciNfc_NFCF_Poll,
|
||||
1, // Poll every discovery loop
|
||||
|
||||
phNciNfc_NFCISO15693_Poll,
|
||||
1, // Poll every discovery loop
|
||||
|
||||
phNciNfc_NFCA_Kovio_Poll,
|
||||
1, // Poll every discovery loop
|
||||
|
||||
phNciNfc_NFCA_Listen,
|
||||
1, // Poll every discovery loop
|
||||
|
||||
phNciNfc_NFCA_Active_Listen,
|
||||
1, // Poll every discovery loop
|
||||
|
||||
phNciNfc_NFCF_Listen,
|
||||
1, // Poll every discovery loop
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const SimSequenceStep RfDiscoverySequences::DiscoveryStart::DiscoverResponse = SimSequenceStep::NciControlRead(
|
||||
L"RF_DISCOVER_RSP",
|
||||
{
|
||||
|
@ -169,12 +208,33 @@ const SimSequenceStep RfDiscoverySequences::DiscoveryStop::DiscoverStopComplete
|
|||
0
|
||||
);
|
||||
|
||||
const SimSequenceStep RfDiscoverySequences::DiscoveryStart::Sequence[6] =
|
||||
const SimSequenceStep RfDiscoverySequences::DiscoveryStart::Sequence_Nci1[6] =
|
||||
{
|
||||
PreDiscoveryStart,
|
||||
GetConfigCommand,
|
||||
GetConfigResponse,
|
||||
DiscoverCommand,
|
||||
DiscoverCommand_Nci1,
|
||||
DiscoverResponse,
|
||||
DiscoverStartComplete,
|
||||
};
|
||||
|
||||
const SimSequenceView
|
||||
RfDiscoverySequences::DiscoveryStart::Sequence(bool isNci2)
|
||||
{
|
||||
if (isNci2)
|
||||
{
|
||||
return Sequence_Nci2;
|
||||
}
|
||||
|
||||
return Sequence_Nci1;
|
||||
}
|
||||
|
||||
const SimSequenceStep RfDiscoverySequences::DiscoveryStart::Sequence_Nci2[6] =
|
||||
{
|
||||
PreDiscoveryStart,
|
||||
GetConfigCommand,
|
||||
GetConfigResponse,
|
||||
DiscoverCommand_Nci2,
|
||||
DiscoverResponse,
|
||||
DiscoverStartComplete,
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <Simulation/SimSequenceView.h>
|
||||
#include <Simulation/SimSequenceStep.h>
|
||||
|
||||
// Standard NCI command/response sequences relating to NCI discovery.
|
||||
|
@ -14,11 +15,14 @@ struct RfDiscoverySequences
|
|||
static const SimSequenceStep PreDiscoveryStart;
|
||||
static const SimSequenceStep GetConfigCommand;
|
||||
static const SimSequenceStep GetConfigResponse;
|
||||
static const SimSequenceStep DiscoverCommand;
|
||||
static const SimSequenceStep DiscoverCommand_Nci1;
|
||||
static const SimSequenceStep DiscoverCommand_Nci2;
|
||||
static const SimSequenceStep DiscoverResponse;
|
||||
static const SimSequenceStep DiscoverStartComplete;
|
||||
|
||||
static const SimSequenceStep Sequence[6];
|
||||
static const SimSequenceStep Sequence_Nci1[6];
|
||||
static const SimSequenceStep Sequence_Nci2[6];
|
||||
static const SimSequenceView Sequence(bool isNci2);
|
||||
};
|
||||
|
||||
struct DiscoveryStop
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Precomp.h"
|
||||
|
||||
#include <SimulationSequences\InitSequences.h>
|
||||
#include <IOHelpers\ProximityHandleFactory.h>
|
||||
#include <IOHelpers\DriverHandleFactory.h>
|
||||
#include <Simulation\NciSimConnector.h>
|
||||
#include <IOHelpers\RadioManager.h>
|
||||
#include <SimulationSequences\RfDiscoverySequences.h>
|
||||
|
@ -37,13 +37,13 @@ AirplaneModeTests::RadioStateBasicTest()
|
|||
simConnector.AddD0PowerReference();
|
||||
|
||||
// Verify NCI is initialized.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1);
|
||||
|
||||
// Drop the D0 power reference.
|
||||
simConnector.RemoveD0PowerReference();
|
||||
|
||||
// Verify NCI is uninitialized.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
|
||||
// Open radio manager
|
||||
RadioManager radioManager(simConnector.DeviceId().c_str());
|
||||
|
@ -57,11 +57,11 @@ AirplaneModeTests::RadioStateBasicTest()
|
|||
VERIFY_ARE_EQUAL(true, radioManager.GetNfcRadioState());
|
||||
|
||||
// Open a handle for proximity subscription.
|
||||
UniqueHandle nfpSubInterface = ProximityHandleFactory::OpenSubscriptionHandle(simConnector.DeviceId().c_str(), L"NDEF");
|
||||
UniqueHandle nfpSubInterface = DriverHandleFactory::OpenSubscriptionHandle(simConnector.DeviceId().c_str(), L"NDEF");
|
||||
|
||||
// Verify NCI is initialized and discovery mode is started.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Verify enabling airplane mode disables radio.
|
||||
LOG_COMMENT(L"== 1 ==");
|
||||
|
@ -69,15 +69,15 @@ AirplaneModeTests::RadioStateBasicTest()
|
|||
VERIFY_ARE_EQUAL(false, radioManager.GetNfcRadioState());
|
||||
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
|
||||
// Verify disabling airplane mode re-enables the radio.
|
||||
LOG_COMMENT(L"== 2 ==");
|
||||
radioManager.SetAirplaneMode(false);
|
||||
VERIFY_ARE_EQUAL(true, radioManager.GetNfcRadioState());
|
||||
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Verify disabling the radio actually disables the radio.
|
||||
LOG_COMMENT(L"== 3 ==");
|
||||
|
@ -85,7 +85,7 @@ AirplaneModeTests::RadioStateBasicTest()
|
|||
VERIFY_ARE_EQUAL(false, radioManager.GetNfcRadioState());
|
||||
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
|
||||
// Verify enabling airplane mode doesn't enable the radio.
|
||||
LOG_COMMENT(L"== 4 ==");
|
||||
|
@ -102,8 +102,8 @@ AirplaneModeTests::RadioStateBasicTest()
|
|||
radioManager.SetNfcRadioState(true);
|
||||
VERIFY_ARE_EQUAL(true, radioManager.GetNfcRadioState());
|
||||
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Verify enabling airplane mode disables radio.
|
||||
LOG_COMMENT(L"== 7 ==");
|
||||
|
@ -111,15 +111,15 @@ AirplaneModeTests::RadioStateBasicTest()
|
|||
VERIFY_ARE_EQUAL(false, radioManager.GetNfcRadioState());
|
||||
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
|
||||
// Verify that the user can enable the radio while airplane mode is enabled.
|
||||
LOG_COMMENT(L"== 8 ==");
|
||||
radioManager.SetNfcRadioState(true);
|
||||
VERIFY_ARE_EQUAL(true, radioManager.GetNfcRadioState());
|
||||
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Verify disabling the radio actually disables the radio (while airplane mode is enabled).
|
||||
LOG_COMMENT(L"== 9 ==");
|
||||
|
@ -127,15 +127,15 @@ AirplaneModeTests::RadioStateBasicTest()
|
|||
VERIFY_ARE_EQUAL(false, radioManager.GetNfcRadioState());
|
||||
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
|
||||
// Verify disabling airplane mode re-enables radio (even though the NFC radio was manually enabled and then disabled).
|
||||
LOG_COMMENT(L"== 10 ==");
|
||||
radioManager.SetAirplaneMode(false);
|
||||
VERIFY_ARE_EQUAL(true, radioManager.GetNfcRadioState());
|
||||
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Verify disabling the radio actually disables the radio.
|
||||
LOG_COMMENT(L"== 11 ==");
|
||||
|
@ -143,7 +143,7 @@ AirplaneModeTests::RadioStateBasicTest()
|
|||
VERIFY_ARE_EQUAL(false, radioManager.GetNfcRadioState());
|
||||
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
|
||||
// Verify enabling airplane mode doesn't enable the radio.
|
||||
LOG_COMMENT(L"== 12 ==");
|
||||
|
@ -155,8 +155,8 @@ AirplaneModeTests::RadioStateBasicTest()
|
|||
radioManager.SetNfcRadioState(true);
|
||||
VERIFY_ARE_EQUAL(true, radioManager.GetNfcRadioState());
|
||||
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Verify disabling airplane mode doesn't disable the radio (even though the radio was disabled when airplane mode was first enabled).
|
||||
LOG_COMMENT(L"== 14 ==");
|
||||
|
@ -167,5 +167,5 @@ AirplaneModeTests::RadioStateBasicTest()
|
|||
nfpSubInterface.Reset();
|
||||
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <SimulationSequences\RfDiscoverySequences.h>
|
||||
#include <Simulation\SimSequenceRunner.h>
|
||||
#include "TestLogging.h"
|
||||
#include <IOHelpers\DriverHandleFactory.h>
|
||||
#include <IOHelpers\UniqueHandle.h>
|
||||
#include <Simulation\VerifyHelpers.h>
|
||||
|
||||
|
@ -23,22 +24,33 @@ class InitTests
|
|||
{
|
||||
TEST_CLASS(InitTests);
|
||||
|
||||
BEGIN_TEST_METHOD(InitAndDeinitTest)
|
||||
BEGIN_TEST_METHOD(InitAndDeinitNci1Test)
|
||||
TEST_METHOD_PROPERTY(L"Category", L"GoldenPath")
|
||||
END_TEST_METHOD()
|
||||
|
||||
BEGIN_TEST_METHOD(InitAndDeinitWithSlowIoTest)
|
||||
BEGIN_TEST_METHOD(InitAndDeinitNci2Test)
|
||||
TEST_METHOD_PROPERTY(L"Category", L"GoldenPath")
|
||||
END_TEST_METHOD()
|
||||
|
||||
BEGIN_TEST_METHOD(InitAndDeinitNci1WithSlowIoTest)
|
||||
TEST_METHOD_PROPERTY(L"Category", L"Reliability")
|
||||
END_TEST_METHOD()
|
||||
|
||||
BEGIN_TEST_METHOD(DiscoveryInitAndDeinitTest)
|
||||
BEGIN_TEST_METHOD(DiscoveryInitAndDeinitNci1Test)
|
||||
TEST_METHOD_PROPERTY(L"Category", L"GoldenPath")
|
||||
END_TEST_METHOD()
|
||||
|
||||
BEGIN_TEST_METHOD(DiscoveryInitAndDeinitNci2Test)
|
||||
TEST_METHOD_PROPERTY(L"Category", L"GoldenPath")
|
||||
END_TEST_METHOD()
|
||||
|
||||
private:
|
||||
void InitAndDeinitTest(bool isNci2);
|
||||
void DiscoveryInitAndDeinitTest(bool isNci2);
|
||||
};
|
||||
|
||||
// Tests NFC controller initialization and deinitialization.
|
||||
void
|
||||
InitTests::InitAndDeinitTest()
|
||||
InitTests::InitAndDeinitTest(bool isNci2)
|
||||
{
|
||||
LOG_COMMENT(L"# Open connection to NCI Simulator Driver.");
|
||||
NciSimConnector simConnector;
|
||||
|
@ -46,17 +58,31 @@ InitTests::InitAndDeinitTest()
|
|||
LOG_COMMENT(L"# Pull device into D0.");
|
||||
simConnector.AddD0PowerReference();
|
||||
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence(isNci2));
|
||||
|
||||
LOG_COMMENT(L"# Allow device to drop out of D0.");
|
||||
simConnector.RemoveD0PowerReference();
|
||||
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence(isNci2));
|
||||
}
|
||||
|
||||
// Tests NFC controller initialization and deinitialization for NCI 1.1.
|
||||
void
|
||||
InitTests::InitAndDeinitNci1Test()
|
||||
{
|
||||
InitAndDeinitTest(false);
|
||||
}
|
||||
|
||||
// Tests NFC controller initialization and deinitialization for NCI 2.0
|
||||
void
|
||||
InitTests::InitAndDeinitNci2Test()
|
||||
{
|
||||
InitAndDeinitTest(true);
|
||||
}
|
||||
|
||||
// Ensures driver can properly handle when the NCI write I/O request takes a long time to complete.
|
||||
void
|
||||
InitTests::InitAndDeinitWithSlowIoTest()
|
||||
InitTests::InitAndDeinitNci1WithSlowIoTest()
|
||||
{
|
||||
LOG_COMMENT(L"# Open connection to NCI Simulator Driver.");
|
||||
NciSimConnector simConnector;
|
||||
|
@ -66,7 +92,7 @@ InitTests::InitAndDeinitWithSlowIoTest()
|
|||
simConnector.AddD0PowerReference();
|
||||
|
||||
// Run through the first half of the initialization sequence, stopping just before the GetConfigCommand step.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence, 6);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1, 6);
|
||||
|
||||
// Manually process the GetConfigCommand step.
|
||||
LOG_COMMENT(L"# Manually processing GetConfigCommand step.");
|
||||
|
@ -78,19 +104,18 @@ InitTests::InitAndDeinitWithSlowIoTest()
|
|||
simConnector.SendNciWriteCompleted();
|
||||
|
||||
// Process the remainder of the initialization sequence.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence + 7, std::size(InitSequences::InitializeNoSEs::Sequence) - 7);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1 + 7, std::size(InitSequences::InitializeNoSEs::Sequence_Nci1) - 7);
|
||||
|
||||
// Allow device to drop out of D0, so that NCI is deinitialized.
|
||||
LOG_COMMENT(L"# Allow device to drop out of D0.");
|
||||
simConnector.RemoveD0PowerReference();
|
||||
|
||||
// Run through the deinitialization sequence.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
}
|
||||
|
||||
// Tests entering and exiting RF discovery mode.
|
||||
void
|
||||
InitTests::DiscoveryInitAndDeinitTest()
|
||||
InitTests::DiscoveryInitAndDeinitTest(bool isNci2)
|
||||
{
|
||||
LOG_COMMENT(L"# Open connection to NCI Simulator Driver.");
|
||||
NciSimConnector simConnector;
|
||||
|
@ -99,23 +124,10 @@ InitTests::DiscoveryInitAndDeinitTest()
|
|||
simConnector.AddD0PowerReference();
|
||||
|
||||
// Verify NCI is initialized.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence(isNci2));
|
||||
|
||||
// Try to find the smartcard (NFC) interface and open it.
|
||||
std::vector<std::wstring> nfcScInterfaces = DeviceQuery::GetSmartcardInterfacesOfType(simConnector.DeviceId().c_str(), SmartCardReaderKind_Nfc);
|
||||
VERIFY_ARE_NOT_EQUAL(static_cast<size_t>(0), nfcScInterfaces.size());
|
||||
|
||||
const std::wstring& nfcScInterfaceId = nfcScInterfaces[0];
|
||||
|
||||
UniqueHandle nfcScInterface(CreateFile(
|
||||
nfcScInterfaceId.c_str(),
|
||||
GENERIC_READ,
|
||||
0,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
nullptr));
|
||||
VERIFY_WIN32_BOOL_SUCCEEDED(INVALID_HANDLE_VALUE != nfcScInterface.Get());
|
||||
UniqueHandle nfcScInterface = DriverHandleFactory::OpenSmartcardHandle(simConnector.DeviceId().c_str(), SmartCardReaderKind_Nfc);
|
||||
|
||||
// Start an IOCTL_SMARTCARD_IS_PRESENT request, so that the driver considers the smartcard reader handle to be in use.
|
||||
// This should result in the radio being initialized.
|
||||
|
@ -125,7 +137,7 @@ InitTests::DiscoveryInitAndDeinitTest()
|
|||
simConnector.RemoveD0PowerReference();
|
||||
|
||||
// Verify discovery mode is started.
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence(isNci2));
|
||||
|
||||
// Cancel the IOCTL_SMARTCARD_IS_PRESENT I/O, so that the smartcard reader handle is no longer considered active.
|
||||
ioIsPresent->Cancel();
|
||||
|
@ -134,5 +146,19 @@ InitTests::DiscoveryInitAndDeinitTest()
|
|||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
|
||||
// Verify NCI is uninitialized.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence(isNci2));
|
||||
}
|
||||
|
||||
// Tests entering and exiting RF discovery mode for NCI 1.1.
|
||||
void
|
||||
InitTests::DiscoveryInitAndDeinitNci1Test()
|
||||
{
|
||||
DiscoveryInitAndDeinitTest(false);
|
||||
}
|
||||
|
||||
// Tests entering and exiting RF discovery mode for NCI 2.0.
|
||||
void
|
||||
InitTests::DiscoveryInitAndDeinitNci2Test()
|
||||
{
|
||||
DiscoveryInitAndDeinitTest(true);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <SimulationSequences\InitSequences.h>
|
||||
#include <IOHelpers\IoOperation.h>
|
||||
#include <Simulation\NciSimConnector.h>
|
||||
#include <IOHelpers\ProximityHandleFactory.h>
|
||||
#include <IOHelpers\DriverHandleFactory.h>
|
||||
#include <SimulationSequences\RfDiscoverySequences.h>
|
||||
#include <Simulation\SimSequenceRunner.h>
|
||||
#include <Simulation\TagPayloads.h>
|
||||
|
@ -50,10 +50,10 @@ TagTests::SimpleNdefSubscriptionTest()
|
|||
simConnector.AddD0PowerReference();
|
||||
|
||||
// Verify NCI is initialized.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1);
|
||||
|
||||
// Open handle for NDEF subscription.
|
||||
UniqueHandle nfpSubInterface = ProximityHandleFactory::OpenSubscriptionHandle(simConnector.DeviceId().c_str(), L"NDEF");
|
||||
UniqueHandle nfpSubInterface = DriverHandleFactory::OpenSubscriptionHandle(simConnector.DeviceId().c_str(), L"NDEF");
|
||||
|
||||
// Start an I/O request for the next message,
|
||||
constexpr DWORD messageBufferSize = 2048;
|
||||
|
@ -63,7 +63,7 @@ TagTests::SimpleNdefSubscriptionTest()
|
|||
simConnector.RemoveD0PowerReference();
|
||||
|
||||
// Verify discovery mode is started.
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Provide a tag for the subscription to read.
|
||||
SimSequenceRunner::Run(simConnector, TagSequences::Ntag216Activated::Sequence);
|
||||
|
@ -71,7 +71,7 @@ TagTests::SimpleNdefSubscriptionTest()
|
|||
|
||||
// The driver has finished with the tag. So it will restart discovery to look for new tags.
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Ensure subscription receives the tag's message.
|
||||
VERIFY_WIN32_SUCCEEDED(ioGetMessage->WaitForResult(/*wait (ms)*/ 1'000));
|
||||
|
@ -87,7 +87,7 @@ TagTests::SimpleNdefSubscriptionTest()
|
|||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
|
||||
// Verify NCI is uninitialized.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -101,10 +101,10 @@ TagTests::NdefSubscriptionWithEarlyTagArrivalTest()
|
|||
simConnector.AddD0PowerReference();
|
||||
|
||||
// Verify NCI is initialized.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1);
|
||||
|
||||
// Open handle for NDEF subscription.
|
||||
UniqueHandle nfpSubInterface = ProximityHandleFactory::OpenSubscriptionHandle(simConnector.DeviceId().c_str(), L"NDEF");
|
||||
UniqueHandle nfpSubInterface = DriverHandleFactory::OpenSubscriptionHandle(simConnector.DeviceId().c_str(), L"NDEF");
|
||||
|
||||
// Start an I/O request for the next message,
|
||||
constexpr DWORD messageBufferSize = 2048;
|
||||
|
@ -114,7 +114,7 @@ TagTests::NdefSubscriptionWithEarlyTagArrivalTest()
|
|||
simConnector.RemoveD0PowerReference();
|
||||
|
||||
// Verify discovery mode is started. But don't complete the SequenceRfDiscStartComplete sequence handler yet.
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence, 5);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1, 5);
|
||||
|
||||
NciSimCallbackView simCallback = simConnector.ReceiveCallback();
|
||||
VerifySequenceHandler(SequenceRfDiscStartComplete, simCallback);
|
||||
|
@ -131,7 +131,7 @@ TagTests::NdefSubscriptionWithEarlyTagArrivalTest()
|
|||
|
||||
// The driver has finished with the tag. So it will restart discovery to look for new tags.
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Ensure subscription receives the tag's message.
|
||||
VERIFY_WIN32_SUCCEEDED(ioGetMessage->WaitForResult(/*wait (ms)*/ 1'000));
|
||||
|
@ -147,7 +147,7 @@ TagTests::NdefSubscriptionWithEarlyTagArrivalTest()
|
|||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
|
||||
// Verify NCI is uninitialized.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -161,10 +161,10 @@ TagTests::SimpleNdefSubscriptionTestWithSlowIO()
|
|||
simConnector.AddD0PowerReference();
|
||||
|
||||
// Verify NCI is initialized.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::InitializeNoSEs::Sequence_Nci1);
|
||||
|
||||
// Open handle for NDEF subscription.
|
||||
UniqueHandle nfpSubInterface = ProximityHandleFactory::OpenSubscriptionHandle(simConnector.DeviceId().c_str(), L"NDEF");
|
||||
UniqueHandle nfpSubInterface = DriverHandleFactory::OpenSubscriptionHandle(simConnector.DeviceId().c_str(), L"NDEF");
|
||||
|
||||
// Start an I/O request for the next message,
|
||||
constexpr DWORD messageBufferSize = 2048;
|
||||
|
@ -174,7 +174,7 @@ TagTests::SimpleNdefSubscriptionTestWithSlowIO()
|
|||
simConnector.RemoveD0PowerReference();
|
||||
|
||||
// Verify discovery mode is started.
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Provide a tag for the subscription to read.
|
||||
SimSequenceRunner::Run(simConnector, TagSequences::Ntag216Activated::Sequence);
|
||||
|
@ -193,7 +193,7 @@ TagTests::SimpleNdefSubscriptionTestWithSlowIO()
|
|||
|
||||
// The driver has finished with the tag. So it will restart discovery to look for new tags.
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStart::Sequence_Nci1);
|
||||
|
||||
// Ensure subscription receives the tag's message.
|
||||
VERIFY_WIN32_SUCCEEDED(ioGetMessage->WaitForResult(/*wait (ms)*/ 1'000));
|
||||
|
@ -209,5 +209,5 @@ TagTests::SimpleNdefSubscriptionTestWithSlowIO()
|
|||
SimSequenceRunner::Run(simConnector, RfDiscoverySequences::DiscoveryStop::Sequence);
|
||||
|
||||
// Verify NCI is uninitialized.
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence);
|
||||
SimSequenceRunner::Run(simConnector, InitSequences::Uninitialize::Sequence_Nci1);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче