This commit is contained in:
Shyamal Varma 2019-08-23 11:25:18 -07:00
Родитель 10d9f22de3
Коммит 6457ce86a6
6 изменённых файлов: 16 добавлений и 21 удалений

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

@ -76,14 +76,14 @@ To try out Azure IoT PnP Bridge, follow the steps bellow:
"dps_parameters" : { "dps_parameters" : {
"global_prov_uri" : "[GLOABL PROVISIONING URI]", "global_prov_uri" : "[GLOABL PROVISIONING URI]",
"id_scope": "[IOT HUB ID SCOPE]", "id_scope": "[IOT HUB ID SCOPE]",
"device_id": "[DEVICE ID", "device_id": "[DEVICE ID]",
"device_capability_model_uri": "[DEVICE CAPABILITY MODEL URI]", "device_capability_model_id": "[DEVICE CAPABILITY MODEL ID]",
"model_repository_uri": "[MODEL REPOSITORY URI]" "model_repository_uri": "[MODEL REPOSITORY URI]"
} }
} }
} }
``` ```
> Note: If using Azure IoT Central, the primary connection fields you will need to change in the default config file are id_scope, device_id, symmetric_key, and device_capability_model_uri. Refer to the [Azure IoT Central documentation on device connectivity](https://docs.microsoft.com/en-us/azure/iot-central/concepts-connectivity) for how to generate the id_scope, device_id, and symmetric_key for your device. The device_capability_model_uri is the "Id" that is listed for your device's Device Capability Model in Azure IoT Central. > Note: If using Azure IoT Central, the primary connection fields you will need to change in the default config file are id_scope, device_id, symmetric_key, and device_capability_model_id. Refer to the [Azure IoT Central documentation on device connectivity](https://docs.microsoft.com/en-us/azure/iot-central/concepts-connectivity) for how to generate the id_scope, device_id, and symmetric_key for your device. The device_capability_model_uri is the "Id" that is listed for your device's Device Capability Model in Azure IoT Central.
* Start PnpBridge by running it in a command prompt. * Start PnpBridge by running it in a command prompt.

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

@ -47,7 +47,7 @@ typedef struct _DPS_PARAMETERS {
const char* GlobalProvUri; const char* GlobalProvUri;
const char* IdScope; const char* IdScope;
const char* DeviceId; const char* DeviceId;
const char* ModelRepositoryUri; const char* DcmModelId;
} DPS_PARAMETERS; } DPS_PARAMETERS;
// Transport used to connect with IoTHub Device/Module // Transport used to connect with IoTHub Device/Module

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

@ -93,8 +93,8 @@ int Map_GetIndexValueFromKey(MAP_HANDLE handle, const char* key);
#define PNP_CONFIG_CONNECTION_DPS_GLOBAL_PROV_URI "global_prov_uri" #define PNP_CONFIG_CONNECTION_DPS_GLOBAL_PROV_URI "global_prov_uri"
#define PNP_CONFIG_CONNECTION_DPS_ID_SCOPE "id_scope" #define PNP_CONFIG_CONNECTION_DPS_ID_SCOPE "id_scope"
#define PNP_CONFIG_CONNECTION_DPS_DEVICE_ID "device_id" #define PNP_CONFIG_CONNECTION_DPS_DEVICE_ID "device_id"
#define PNP_CONFIG_CONNECTION_DPS_MODEL_ID "device_capability_model_id"
#define PNP_CONFIG_CONNECTION_DEVICE_CAPS_MODEL_URI "device_capability_model_uri" #define PNP_CONFIG_CONNECTION_DEVICE_CAPS_MODEL_URI "device_capability_model_uri"
#define PNP_CONFIG_CONNECTION_DPS_MODEL_REPO_URI "model_repository_uri"
#define PNP_CONFIG_CONNECTION_AUTH_PARAMETERS "auth_parameters" #define PNP_CONFIG_CONNECTION_AUTH_PARAMETERS "auth_parameters"
#define PNP_CONFIG_CONNECTION_AUTH_TYPE "auth_type" #define PNP_CONFIG_CONNECTION_AUTH_TYPE "auth_type"

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

@ -98,9 +98,9 @@ PCONNECTION_PARAMETERS PnpBridgeConfig_GetConnectionDetails(JSON_Object* Connect
LEAVE; LEAVE;
} }
dpsParams->ModelRepositoryUri = json_object_get_string(dpsSettings, PNP_CONFIG_CONNECTION_DPS_MODEL_REPO_URI); dpsParams->DcmModelId = json_object_get_string(dpsSettings, PNP_CONFIG_CONNECTION_DPS_MODEL_ID);
if (NULL == dpsParams->ModelRepositoryUri) { if (NULL == dpsParams->DcmModelId) {
LogError("%s is missing in config", PNP_CONFIG_CONNECTION_DPS_MODEL_REPO_URI); LogError("%s is missing in config", PNP_CONFIG_CONNECTION_DPS_MODEL_ID);
result = PNPBRIDGE_INVALID_ARGS; result = PNPBRIDGE_INVALID_ARGS;
LEAVE; LEAVE;
} }

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

@ -44,8 +44,7 @@ static const int pnpSampleDevice_dpsRegistrationMaxPolls = 60;
static const char* pnpSample_CustomProvisioningData = "{ \ static const char* pnpSample_CustomProvisioningData = "{ \
\"__iot:interfaces\": \ \"__iot:interfaces\": \
{ \ { \
\"CapabilityModelUri\": \"%s\", \ \"CapabilityModelId\": \"%s\" \
\"ModelRepositoryUri\": \"%s\" \
} \ } \
}"; }";
#endif // ENABLE_IOT_CENTRAL #endif // ENABLE_IOT_CENTRAL
@ -91,8 +90,7 @@ IOTHUB_DEVICE_HANDLE IotComms_InitializeIotHubViaProvisioning(bool TraceOn, PCON
const char* idScope = ConnectionParams->u1.Dps.IdScope; const char* idScope = ConnectionParams->u1.Dps.IdScope;
const char* deviceId = ConnectionParams->u1.Dps.DeviceId; const char* deviceId = ConnectionParams->u1.Dps.DeviceId;
const char* deviceKey = ConnectionParams->AuthParameters.u1.DeviceKey; const char* deviceKey = ConnectionParams->AuthParameters.u1.DeviceKey;
const char* dcmUri = ConnectionParams->DeviceCapabilityModelUri; const char* dcmModelId = ConnectionParams->u1.Dps.DcmModelId;
const char* ModelUri = ConnectionParams->u1.Dps.ModelRepositoryUri;
SECURE_DEVICE_TYPE secureDeviceTypeForProvisioning; SECURE_DEVICE_TYPE secureDeviceTypeForProvisioning;
IOTHUB_SECURITY_TYPE secureDeviceTypeForIotHub; IOTHUB_SECURITY_TYPE secureDeviceTypeForIotHub;
@ -112,15 +110,15 @@ IOTHUB_DEVICE_HANDLE IotComms_InitializeIotHubViaProvisioning(bool TraceOn, PCON
LEAVE; LEAVE;
} }
size_t customProvDataLength = strlen(pnpSample_CustomProvisioningData) + strlen(dcmUri) + strlen(ModelUri) + 1; size_t customProvDataLength = strlen(pnpSample_CustomProvisioningData) + strlen(dcmModelId) + 1;
customProvisioningData = calloc(1, customProvDataLength * sizeof(char)); customProvisioningData = calloc(1, customProvDataLength * sizeof(char));
if (NULL == customProvisioningData) { if (NULL == customProvisioningData) {
LogError("Failed to allocate memory fo the customProvisiongData."); LogError("Failed to allocate memory fo the customProvisiongData.");
LEAVE; LEAVE;
} }
if (-1 == sprintf_s(customProvisioningData, customProvDataLength, pnpSample_CustomProvisioningData, dcmUri, ModelUri)) { if (-1 == sprintf_s(customProvisioningData, customProvDataLength, pnpSample_CustomProvisioningData, dcmModelId)) {
LogError("Failed to create the customProvisiongData. URI's is too long."); LogError("Failed to create the customProvisiongData. DcmModelId is too long.");
} }
else if (IoTHub_Init() != 0) { else if (IoTHub_Init() != 0) {
LogError("IoTHub_Init failed"); LogError("IoTHub_Init failed");
@ -192,6 +190,7 @@ IOTHUB_DEVICE_HANDLE IotComms_InitializeIotHubViaProvisioning(bool TraceOn, PCON
deviceHandle = NULL; deviceHandle = NULL;
} }
// TODO: Fix this. Issue is now resolved
// Setting OPTION_AUTO_URL_ENCODE_DECODE is required by callers only for private-preview. // Setting OPTION_AUTO_URL_ENCODE_DECODE is required by callers only for private-preview.
// https://github.com/Azure/azure-iot-sdk-c-pnp/issues/2 tracks making underlying PnP set this automatically. // https://github.com/Azure/azure-iot-sdk-c-pnp/issues/2 tracks making underlying PnP set this automatically.
else if ((iothubClientResult = IoTHubDeviceClient_SetOption(deviceHandle, OPTION_AUTO_URL_ENCODE_DECODE, &urlEncodeOn)) != IOTHUB_CLIENT_OK) else if ((iothubClientResult = IoTHubDeviceClient_SetOption(deviceHandle, OPTION_AUTO_URL_ENCODE_DECODE, &urlEncodeOn)) != IOTHUB_CLIENT_OK)

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

@ -127,10 +127,7 @@
"device_id": { "device_id": {
"type": "string" "type": "string"
}, },
"device_capability_model_uri": { "device_capability_model_id": {
"type": "string"
},
"model_repository_uri": {
"type": "string" "type": "string"
} }
}, },
@ -138,8 +135,7 @@
"global_prov_uri", "global_prov_uri",
"id_scope", "id_scope",
"device_id", "device_id",
"device_capability_model_uri", "device_capability_model_id"
"model_repository_uri"
] ]
}, },
"device_schema" : { "device_schema" : {