commit initial changes
This commit is contained in:
Родитель
10d9f22de3
Коммит
6457ce86a6
|
@ -76,14 +76,14 @@ To try out Azure IoT PnP Bridge, follow the steps bellow:
|
|||
"dps_parameters" : {
|
||||
"global_prov_uri" : "[GLOABL PROVISIONING URI]",
|
||||
"id_scope": "[IOT HUB ID SCOPE]",
|
||||
"device_id": "[DEVICE ID",
|
||||
"device_capability_model_uri": "[DEVICE CAPABILITY MODEL URI]",
|
||||
"device_id": "[DEVICE ID]",
|
||||
"device_capability_model_id": "[DEVICE CAPABILITY MODEL ID]",
|
||||
"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.
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef struct _DPS_PARAMETERS {
|
|||
const char* GlobalProvUri;
|
||||
const char* IdScope;
|
||||
const char* DeviceId;
|
||||
const char* ModelRepositoryUri;
|
||||
const char* DcmModelId;
|
||||
} DPS_PARAMETERS;
|
||||
|
||||
// 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_ID_SCOPE "id_scope"
|
||||
#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_DPS_MODEL_REPO_URI "model_repository_uri"
|
||||
|
||||
#define PNP_CONFIG_CONNECTION_AUTH_PARAMETERS "auth_parameters"
|
||||
#define PNP_CONFIG_CONNECTION_AUTH_TYPE "auth_type"
|
||||
|
|
|
@ -98,9 +98,9 @@ PCONNECTION_PARAMETERS PnpBridgeConfig_GetConnectionDetails(JSON_Object* Connect
|
|||
LEAVE;
|
||||
}
|
||||
|
||||
dpsParams->ModelRepositoryUri = json_object_get_string(dpsSettings, PNP_CONFIG_CONNECTION_DPS_MODEL_REPO_URI);
|
||||
if (NULL == dpsParams->ModelRepositoryUri) {
|
||||
LogError("%s is missing in config", PNP_CONFIG_CONNECTION_DPS_MODEL_REPO_URI);
|
||||
dpsParams->DcmModelId = json_object_get_string(dpsSettings, PNP_CONFIG_CONNECTION_DPS_MODEL_ID);
|
||||
if (NULL == dpsParams->DcmModelId) {
|
||||
LogError("%s is missing in config", PNP_CONFIG_CONNECTION_DPS_MODEL_ID);
|
||||
result = PNPBRIDGE_INVALID_ARGS;
|
||||
LEAVE;
|
||||
}
|
||||
|
|
|
@ -44,8 +44,7 @@ static const int pnpSampleDevice_dpsRegistrationMaxPolls = 60;
|
|||
static const char* pnpSample_CustomProvisioningData = "{ \
|
||||
\"__iot:interfaces\": \
|
||||
{ \
|
||||
\"CapabilityModelUri\": \"%s\", \
|
||||
\"ModelRepositoryUri\": \"%s\" \
|
||||
\"CapabilityModelId\": \"%s\" \
|
||||
} \
|
||||
}";
|
||||
#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* deviceId = ConnectionParams->u1.Dps.DeviceId;
|
||||
const char* deviceKey = ConnectionParams->AuthParameters.u1.DeviceKey;
|
||||
const char* dcmUri = ConnectionParams->DeviceCapabilityModelUri;
|
||||
const char* ModelUri = ConnectionParams->u1.Dps.ModelRepositoryUri;
|
||||
const char* dcmModelId = ConnectionParams->u1.Dps.DcmModelId;
|
||||
|
||||
SECURE_DEVICE_TYPE secureDeviceTypeForProvisioning;
|
||||
IOTHUB_SECURITY_TYPE secureDeviceTypeForIotHub;
|
||||
|
@ -112,15 +110,15 @@ IOTHUB_DEVICE_HANDLE IotComms_InitializeIotHubViaProvisioning(bool TraceOn, PCON
|
|||
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));
|
||||
if (NULL == customProvisioningData) {
|
||||
LogError("Failed to allocate memory fo the customProvisiongData.");
|
||||
LEAVE;
|
||||
}
|
||||
|
||||
if (-1 == sprintf_s(customProvisioningData, customProvDataLength, pnpSample_CustomProvisioningData, dcmUri, ModelUri)) {
|
||||
LogError("Failed to create the customProvisiongData. URI's is too long.");
|
||||
if (-1 == sprintf_s(customProvisioningData, customProvDataLength, pnpSample_CustomProvisioningData, dcmModelId)) {
|
||||
LogError("Failed to create the customProvisiongData. DcmModelId is too long.");
|
||||
}
|
||||
else if (IoTHub_Init() != 0) {
|
||||
LogError("IoTHub_Init failed");
|
||||
|
@ -192,6 +190,7 @@ IOTHUB_DEVICE_HANDLE IotComms_InitializeIotHubViaProvisioning(bool TraceOn, PCON
|
|||
deviceHandle = NULL;
|
||||
}
|
||||
|
||||
// TODO: Fix this. Issue is now resolved
|
||||
// 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.
|
||||
else if ((iothubClientResult = IoTHubDeviceClient_SetOption(deviceHandle, OPTION_AUTO_URL_ENCODE_DECODE, &urlEncodeOn)) != IOTHUB_CLIENT_OK)
|
||||
|
|
|
@ -127,10 +127,7 @@
|
|||
"device_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"device_capability_model_uri": {
|
||||
"type": "string"
|
||||
},
|
||||
"model_repository_uri": {
|
||||
"device_capability_model_id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
|
@ -138,8 +135,7 @@
|
|||
"global_prov_uri",
|
||||
"id_scope",
|
||||
"device_id",
|
||||
"device_capability_model_uri",
|
||||
"model_repository_uri"
|
||||
"device_capability_model_id"
|
||||
]
|
||||
},
|
||||
"device_schema" : {
|
||||
|
|
Загрузка…
Ссылка в новой задаче