This commit is contained in:
Ajay Barboza 2019-02-14 14:33:11 -08:00
Родитель 5c15e1c40f
Коммит c045d0cb95
3 изменённых файлов: 57 добавлений и 1 удалений

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

@ -160,7 +160,7 @@ CameraPnpInterfaceBind(
RETURN_HR_IF (E_UNEXPECTED, 0 != PnpAdapterInterface_Create(adapterHandle, interfaceId, pnpInterfaceClient, &adapterInterface, &interfaceParams))
pIotPnp = std::make_unique<CameraIotPnpDevice>();
RETURN_IF_FAILED (pIotPnp->Initialize(PnpAdapterInterface_GetPnpInterfaceClient(adapterInterface), nullptr /* cameraName.c_str() */));
RETURN_IF_FAILED(pIotPnp->Initialize(PnpAdapterInterface_GetPnpInterfaceClient(adapterInterface), pnpDeviceClientHandle, nullptr /* cameraName.c_str() */));
RETURN_IF_FAILED (pIotPnp->StartTelemetryWorker());
RETURN_HR_IF (E_UNEXPECTED, 0 != PnpAdapterInterface_SetContext(adapterInterface, (void*)pIotPnp.get()));

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

@ -9,6 +9,7 @@
#include "IotHubComms.h"
#include "PnpBridgeh.h"
#include <iothub_client.h>
// Global instance of PnpBridge
PPNP_BRIDGE g_PnpBridge = NULL;
@ -340,6 +341,52 @@ void PnpBridge_Stop(PPNP_BRIDGE pnpBridge) {
#include <windows.h>
int
PnpBridge_UploadToBlobAsync(
_In_z_ const char* pszDestination,
_In_reads_bytes_(cbData) const unsigned char* pbData,
_In_ size_t cbData,
_In_ IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK iotHubClientFileUploadCallback,
_In_opt_ void* context
)
{
IOTHUB_CLIENT_RESULT iotResult = IOTHUB_CLIENT_OK;
if (NULL == g_PnpBridge->deviceHandle)
{
return PNPBRIDGE_FAILED;
}
if (NULL == pszDestination || (NULL == pbData && cbData > 0) ||
(NULL != pbData && cbData == 0) ||
NULL == iotHubClientFileUploadCallback)
{
return PNPBRIDGE_INVALID_ARGS;
}
iotResult = IoTHubClient_UploadToBlobAsync(g_PnpBridge->deviceHandle,
pszDestination,
pbData,
cbData,
iotHubClientFileUploadCallback,
context);
switch (iotResult)
{
case IOTHUB_CLIENT_OK:
return PNPBRIDGE_OK;
break;
case IOTHUB_CLIENT_INVALID_ARG:
case IOTHUB_CLIENT_INVALID_SIZE:
return PNPBRIDGE_INVALID_ARGS;
break;
case IOTHUB_CLIENT_INDEFINITE_TIME:
case IOTHUB_CLIENT_ERROR:
default:
return PNPBRIDGE_FAILED;
break;
}
}
BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
{
switch (fdwCtrlType)

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

@ -36,6 +36,15 @@ typedef struct _PNPBRIDGE_DEVICE_CHANGE_PAYLOAD {
#include <DiscoveryAdapterInterface.h>
#include <PnpAdapterInterface.h>
int
PnpBridge_UploadToBlobAsync(
_In_z_ const char* pszDestination,
_In_reads_bytes_(cbData) const unsigned char* pbData,
_In_ size_t cbData,
_In_ IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK iotHubClientFileUploadCallback,
_In_opt_ void* context
);
#ifdef __cplusplus
}
#endif