This commit is contained in:
Ajay Barboza 2019-01-17 11:51:35 -08:00
Родитель 5795857fb5
Коммит 35eedb5cfe
8 изменённых файлов: 55 добавлений и 78 удалений

Просмотреть файл

@ -14,7 +14,6 @@
PNP_INTERFACE_CLIENT_HANDLE pnpinterfaceHandle = NULL;
WCHAR* hardwareid = NULL;
void WindowsPnpSendEventCallback(PNP_SEND_TELEMETRY_STATUS pnpSendEventStatus, void* userContextCallback)
{
LogInfo("WindowsPnpSendEventCallback called, result=%d, userContextCallback=%p", pnpSendEventStatus, userContextCallback);

Просмотреть файл

@ -1 +0,0 @@
// Create a jump table for AzureIotApi's

Просмотреть файл

@ -7,7 +7,7 @@
#include "PnpAdapterInterface.h"
#include "PnpAdapterManager.h"
#include "CoreDeviceManagement.h"
#include "CoreDeviceHealth.h"
// TODO: Decide where the extern are present for CoreDeviceHealth
PPNP_INTERFACE_MODULE INTERFACE_MANIFEST[] = {

Просмотреть файл

@ -2,26 +2,17 @@
//
#include "common.h"
#include "PnpBridgeCommon.h"
#include "ConfigurationParser.h"
#include "DiscoveryManager.h"
#include "PnpAdapterInterface.h"
#include "PnpAdapterManager.h"
#include "PnpBridge.h"
// Things to implement
//
// 1. Allow a module to intercept traffic anf execute commands
// 2. Clean up all warnings
// 3. Restart mechanism
//////////////////////////// GLOBALS ///////////////////////////////////
PPNP_BRIDGE g_PnpBridge = NULL;
bool g_Shutdown = false;
////////////////////////////////////////////////////////////////////////
//const char* connectionString = "HostName=iot-pnp-hub1.azure-devices.net;DeviceId=win-gateway;SharedAccessKey=GfbYy7e2PikTf2qHyabvEDBaJB5S4T+H+b9TbLsXfns=";
@ -82,7 +73,7 @@ PNPBRIDGE_RESULT PnpBridge_Initialize() {
g_PnpBridge->dispatchLock = Lock_Init();
g_PnpBridge->shuttingDown = false;
g_Shutdown = false;
// Connect to Iot Hub and create a PnP device client handle
if ((g_PnpBridge->deviceHandle = InitializeIotHubDeviceHandle()) == NULL)
@ -103,17 +94,24 @@ void PnpBridge_Release() {
LogInfo("Cleaning DeviceAggregator resources");
// Stop Device Disovery Modules
Lock(g_PnpBridge->dispatchLock);
// Stop Disovery Modules
if (g_PnpBridge->discoveryMgr) {
DiscoveryAdapterManager_Stop(g_PnpBridge->discoveryMgr);
g_PnpBridge->discoveryMgr = NULL;
}
// Stop Pnp Modules
if (g_PnpBridge->interfaceMgr) {
PnpAdapterManager_Release(g_PnpBridge->interfaceMgr);
g_PnpBridge->interfaceMgr = NULL;
}
Unlock(g_PnpBridge->dispatchLock);
Lock_Deinit(g_PnpBridge->dispatchLock);
if (g_PnpBridge) {
free(g_PnpBridge);
}
@ -133,7 +131,7 @@ static PNPBRIDGE_RESULT PnpBridge_Worker_Thread(void* threadArgument)
while (true)
{
ThreadAPI_Sleep(1 * 1000);
if (g_PnpBridge->shuttingDown) {
if (g_Shutdown) {
return PNPBRIDGE_OK;
}
}
@ -212,7 +210,7 @@ PNPBRIDGE_RESULT PnpBridge_DeviceChangeCallback(PPNPBRIDGE_DEVICE_CHANGE_PAYLOAD
Lock(g_PnpBridge->dispatchLock);
if (g_PnpBridge->shuttingDown) {
if (g_Shutdown) {
LogInfo("PnpBridge is shutting down. Dropping the change notification");
result = PNPBRIDGE_OK;
goto end;
@ -325,7 +323,7 @@ PNPBRIDGE_RESULT PnpBridge_Main() {
void PnpBridge_Stop() {
Lock(g_PnpBridge->dispatchLock);
g_PnpBridge->shuttingDown = true;
g_Shutdown = true;
Unlock(g_PnpBridge->dispatchLock);
}

Просмотреть файл

@ -20,6 +20,4 @@ typedef struct _PNP_BRIDGE {
LOCK_HANDLE dispatchLock;
bool shuttingDown;
} PNP_BRIDGE, *PPNP_BRIDGE;

Просмотреть файл

@ -159,14 +159,13 @@
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Adapters\CoreDeviceHealth\CoreDeviceManagement.h" />
<ClInclude Include="Adapters\CoreDeviceHealth\CoreDeviceHealth.h" />
<ClInclude Include="Adapters\CoreDeviceHealth\WindowsPnpDeviceDiscovery.h" />
<ClInclude Include="common.h" />
<ClInclude Include="ConfigurationParser.h" />
<ClInclude Include="DiscoveryAdapterInterface.h" />
<ClInclude Include="PnpAdapterInterface.h" />
<ClInclude Include="DiscoveryManager.h" />
<ClInclude Include="Errors.h" />
<ClInclude Include="PnpAdapterManager.h" />
<ClInclude Include="PnpBridge.h" />
<ClInclude Include="PnpBridgeCommon.h" />
@ -181,7 +180,6 @@
<ClCompile Include="DiscoveryManager.c" />
<ClCompile Include="PnpAdapterManger.c" />
<ClCompile Include="PnpBridgeService.c" />
<ClCompile Include="SerialDevice.c" />
<ClCompile Include="utility.c" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -13,27 +13,18 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="common">
<UniqueIdentifier>{25d83aa5-41e0-46a6-8795-0a4a201a426a}</UniqueIdentifier>
<Filter Include="Source Files\Adapters">
<UniqueIdentifier>{3524bf36-1d0b-46dc-ada9-78d0803fe1ec}</UniqueIdentifier>
</Filter>
<Filter Include="inc">
<Filter Include="Source Files\Adapters\Serial">
<UniqueIdentifier>{611fd0c7-a77f-4116-bf8a-c41bded6d8a3}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Adapters\CoreDeviceHealth">
<UniqueIdentifier>{28fe5595-e94e-4bac-ac50-03299b219cd8}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\inc">
<UniqueIdentifier>{92a538f9-7056-4277-a567-906bc28ce6a8}</UniqueIdentifier>
</Filter>
<Filter Include="configuration">
<UniqueIdentifier>{0329e27d-0e6f-466f-95d1-3749ca7dcba7}</UniqueIdentifier>
</Filter>
<Filter Include="pnpinterface">
<UniqueIdentifier>{df63643c-8046-4f8c-9993-c8697c94c0c8}</UniqueIdentifier>
</Filter>
<Filter Include="pnpinterface\Modules">
<UniqueIdentifier>{7f915d09-7994-4c58-947e-5d0d6133ebf5}</UniqueIdentifier>
</Filter>
<Filter Include="discovery">
<UniqueIdentifier>{e845b3ea-044d-4c18-b3ac-79eadb3aa765}</UniqueIdentifier>
</Filter>
<Filter Include="discovery\Modules">
<UniqueIdentifier>{030cf99a-0879-4d3d-bdfc-580b70e86191}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
@ -42,73 +33,67 @@
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Errors.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="DiscoveryManager.h">
<Filter>inc</Filter>
<Filter>Source Files\inc</Filter>
</ClInclude>
<ClInclude Include="PnpAdapterInterface.h">
<Filter>inc</Filter>
<Filter>Source Files\inc</Filter>
</ClInclude>
<ClInclude Include="PnpAdapterManager.h">
<Filter>inc</Filter>
<Filter>Source Files\inc</Filter>
</ClInclude>
<ClInclude Include="common.h">
<Filter>inc</Filter>
<Filter>Source Files\inc</Filter>
</ClInclude>
<ClInclude Include="ConfigurationParser.h">
<Filter>inc</Filter>
<Filter>Source Files\inc</Filter>
</ClInclude>
<ClInclude Include="PnpBridge.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="PnpBridgeCommon.h" />
<ClInclude Include="DiscoveryAdapterInterface.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="Adapters\CoreDeviceHealth\CoreDeviceManagement.h">
<Filter>Header Files</Filter>
<Filter>Source Files\inc</Filter>
</ClInclude>
<ClInclude Include="Adapters\CoreDeviceHealth\WindowsPnpDeviceDiscovery.h">
<Filter>Header Files</Filter>
<Filter>Source Files\Adapters\CoreDeviceHealth</Filter>
</ClInclude>
<ClInclude Include="PnpBridgeCommon.h">
<Filter>Source Files\inc</Filter>
</ClInclude>
<ClInclude Include="PnpBridge.h">
<Filter>Source Files\inc</Filter>
</ClInclude>
<ClInclude Include="Adapters\CoreDeviceHealth\CoreDeviceHealth.h">
<Filter>Source Files\Adapters\CoreDeviceHealth</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="PnpBridge.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DiscoveryManager.c">
<Filter>discovery</Filter>
</ClCompile>
<ClCompile Include="SerialDevice.c">
<Filter>pnpinterface\Modules</Filter>
</ClCompile>
<ClCompile Include="PnpAdapterManger.c">
<Filter>pnpinterface</Filter>
</ClCompile>
<ClCompile Include="ConfigurationParser.c">
<Filter>configuration</Filter>
</ClCompile>
<ClCompile Include="utility.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PnpBridgeService.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Adapters\Serial\SerialDevice.c">
<ClCompile Include="Adapters\CoreDeviceHealth\WindowsPnPDeviceDiscovery.c">
<Filter>Source Files\Adapters\CoreDeviceHealth</Filter>
</ClCompile>
<ClCompile Include="PnpAdapterManger.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DiscoveryManager.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ConfigurationParser.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Adapters\Serial\SerialDevice.c">
<Filter>Source Files\Adapters\Serial</Filter>
</ClCompile>
<ClCompile Include="Adapters\CoreDeviceHealth\CoreDeviceHealth.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Adapters\CoreDeviceHealth\WindowsPnPDeviceDiscovery.c">
<Filter>Source Files</Filter>
<Filter>Source Files\Adapters\CoreDeviceHealth</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="config.json">
<Filter>configuration</Filter>
</None>
<None Include="config.json" />
</ItemGroup>
</Project>