Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1073 from microsoft/pre-release
Browse files Browse the repository at this point in the history
Merge branch "pre-release" to release
  • Loading branch information
hellyzh authored Jul 20, 2020
2 parents 7ab7e3c + b6b6ed9 commit a90ea6b
Show file tree
Hide file tree
Showing 22 changed files with 153 additions and 19 deletions.
22 changes: 22 additions & 0 deletions AZ3166/src/cores/arduino/system/SystemDns.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.

#include "mbed.h"
#include "SystemDns.h"
#include "lwip/err.h"
#include "lwip/ip_addr.h"
#include "lwip/dns.h"

int SystemDnsLocalRemoveHost(const char *hostname, const char *addr)
{
ip_addr_t *address = new ip_addr_t;
ip4_addr_set_u32(address, ipaddr_addr(addr));
return dns_local_removehost(hostname, address);
}

int SystemDnsLocalAddHost(const char *hostname, const char *addr)
{
ip_addr_t *address = new ip_addr_t;
ip4_addr_set_u32(address, ipaddr_addr(addr));
return dns_local_addhost(hostname, address);
}
36 changes: 36 additions & 0 deletions AZ3166/src/cores/arduino/system/SystemDns.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.

#ifndef __SYSTEM_DNS_H__
#define __SYSTEM_DNS_H__

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

/*
* @brief Remove all entries from the local host-list for a specific hostname and/or IP addess.
*
* @param hostname hostname for which entries shall be removed from the local host-list.
* addr address for which entries shall be removed from the local host-list.
*
* @return the number of removed entries.
*/
int SystemDnsLocalRemoveHost(const char *hostname, const char *addr);

/*
* @brief Add a hostname/IP address pair to the local host-list. Duplicates are not checked.
*
* @param hostname hostname of the new entry.
* addr IP address of the new entry.
*
* @return Return 0 on success, otherwise return -1.
*/
int SystemDnsLocalAddHost(const char *hostname, const char *addr);

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // __SYSTEM_DNS_H__
6 changes: 3 additions & 3 deletions AZ3166/src/cores/arduino/system/SystemVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#ifndef __VERSION_H__
#define __VERSION_H__

#define DEVKIT_MAJOR_VERSION 1
#define DEVKIT_MINOR_VERSION 6
#define DEVKIT_PATCH_VERSION 5
#define DEVKIT_MAJOR_VERSION 2
#define DEVKIT_MINOR_VERSION 0
#define DEVKIT_PATCH_VERSION 0
#define DEVKIT_SDK_VERSION (DEVKIT_MAJOR_VERSION * 10000 + DEVKIT_MINOR_VERSION * 100 + DEVKIT_PATCH_VERSION)

#ifdef __cplusplus
Expand Down
12 changes: 11 additions & 1 deletion AZ3166/src/libraries/AzureIoT/src/DevKitMQTTClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ void DevKitMQTTClient_Event_AddProp(EVENT_INSTANCE *message, const char *key, co
Map_AddOrUpdate(propMap, key, value);
}

bool DevKitMQTTClient_Init(bool hasDeviceTwin, bool traceOn)
bool DevKitMQTTClient_Init(bool hasDeviceTwin, bool traceOn, const char * modelId)
{
if (iotHubClientHandle != NULL)
{
Expand Down Expand Up @@ -527,6 +527,16 @@ bool DevKitMQTTClient_Init(bool hasDeviceTwin, bool traceOn)
int keepalive = MQTT_KEEPALIVE_INTERVAL_S;
IoTHubClient_LL_SetOption(iotHubClientHandle, "keepalive", &keepalive);
IoTHubClient_LL_SetOption(iotHubClientHandle, "logtrace", &traceOn);

// Sets the name of ModelId for PnP device.
if (modelId != NULL) {
if (IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_MODEL_ID, modelId) != IOTHUB_CLIENT_OK)
{
LogError("Failed to set option \"model_id\"");
return false;
}
}

if (IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_TRUSTED_CERT, trustedCerts) != IOTHUB_CLIENT_OK)
{
LogError("Failed to set option \"TrustedCerts\"");
Expand Down
4 changes: 3 additions & 1 deletion AZ3166/src/libraries/AzureIoT/src/DevKitMQTTClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extern "C"
#endif

#define OPTION_MINI_SOLUTION_NAME "MiniSolution"
#define OPTION_MODEL_ID "model_id"

enum EVENT_TYPE
{
Expand Down Expand Up @@ -49,10 +50,11 @@ void DevKitMQTTClient_Event_AddProp(EVENT_INSTANCE *message, const char * key, c
* The connection string is load from the EEPROM.
* @param hasDeviceTwin Enable / disable device twin, default is disable.
* @param traceOn Enable / disable IoT Hub trace, default is disable.
* @param modelId Sets the name of ModelId for PnP device. Null means disable, default is NULL.
*
* @return Return true if initialize successfully, or false if fails.
*/
bool DevKitMQTTClient_Init(bool hasDeviceTwin = false, bool traceOn = false);
bool DevKitMQTTClient_Init(bool hasDeviceTwin = false, bool traceOn = false, const char * modelId = NULL);

/**
* @brief This API sets a runtime option identified by parameter @p optionName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ typedef struct
* LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
* transport.
*/
#define LWIP_DNS (1)
#define LWIP_DNS 1
#define DNS_LOCAL_HOSTLIST 1
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 1


#ifdef LWIP_SO_RCVBUF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@

#include "lwip/opt.h"

#ifdef __cplusplus
extern "C"
{
#else
#endif

#if LWIP_DNS /* don't build if not configured for use in lwipopts.h */

/** DNS timer period */
Expand Down Expand Up @@ -113,4 +119,8 @@ err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr);

#endif /* LWIP_DNS */

#ifdef __cplusplus
}
#endif

#endif /* __LWIP_DNS_H__ */
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@
* transport.
*/
#ifndef LWIP_DNS
#define LWIP_DNS 0
#define LWIP_DNS 1
#endif

/** DNS maximum number of entries to maintain locally. */
Expand Down Expand Up @@ -827,13 +827,13 @@
* that returns the IP address or INADDR_NONE if not found.
*/
#ifndef DNS_LOCAL_HOSTLIST
#define DNS_LOCAL_HOSTLIST 0
#define DNS_LOCAL_HOSTLIST 1
#endif /* DNS_LOCAL_HOSTLIST */

/** If this is turned on, the local host-list can be dynamically changed
* at runtime. */
#ifndef DNS_LOCAL_HOSTLIST_IS_DYNAMIC
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 1
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern "C"

static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_INITIAL_WAIT_TIME_IN_SECS = "initial_wait_time_in_secs";
static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_MAX_JITTER_PERCENT = "max_jitter_percent";
static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_MAX_DELAY_IN_SECS = "max_delay_in_secs";
static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_SAVED_OPTIONS = "retry_control_saved_options";

typedef enum RETRY_ACTION_TAG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ extern "C"
{
#endif

static const char* IOTHUB_API_VERSION = "2017-11-08-preview";
static const char* IOTHUB_API_VERSION = "2019-10-01";
// TODO: https://github.com/Azure/azure-iot-sdk-c/issues/1547 tracks removing this preview
// variable once the underlying logic is enabled on all IoTHubs.
static const char* IOTHUB_API_PREVIEW_VERSION = "2020-05-31-preview";

static const char* SECURITY_INTERFACE_INTERNAL_ID = "iothub-interface-internal-id";
static const char* SECURITY_INTERFACE_INTERNAL_ID_VALUE = "security*azureiot*com^SecurityAgent^1*0*0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ extern "C"
typedef void (*pfTransport_Twin_ReportedStateComplete_Callback)(uint32_t item_id, int status_code, void* ctx);
typedef void (*pfTransport_Twin_RetrievePropertyComplete_Callback)(DEVICE_TWIN_UPDATE_STATE update_state, const unsigned char* payLoad, size_t size, void* ctx);
typedef int (*pfTransport_DeviceMethod_Complete_Callback)(const char* method_name, const unsigned char* payLoad, size_t size, METHOD_HANDLE response_id, void* ctx);
typedef const char* (*pfTransport_GetOption_Model_Id_Callback)(void* ctx);

/** @brief This struct captures device configuration. */
typedef struct IOTHUB_DEVICE_CONFIG_TAG
Expand Down Expand Up @@ -67,6 +68,7 @@ extern "C"
pfTransport_Twin_ReportedStateComplete_Callback twin_rpt_state_complete_cb;
pfTransport_Twin_RetrievePropertyComplete_Callback twin_retrieve_prop_complete_cb;
pfTransport_DeviceMethod_Complete_Callback method_complete_cb;
pfTransport_GetOption_Model_Id_Callback get_model_id_cb;
} TRANSPORT_CALLBACKS_INFO;

typedef STRING_HANDLE (*pfIoTHubTransport_GetHostname)(TRANSPORT_LL_HANDLE handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/** @file iothub_client.h
* @brief Extends the IoTHubCLient_LL module with additional features.
*
* @note DEPRECATED. New users use iothub_device_client.h for IoTHubClient APIs.
* @details IoTHubClient is a module that extends the IoTHubCLient_LL
* module with 2 features:
* - scheduling the work for the IoTHubCLient from a
Expand Down Expand Up @@ -120,7 +121,10 @@ extern "C"
*
* @b NOTE: The application behavior is undefined if the user calls
* the ::IoTHubClient_Destroy function from within any callback.
*
* @remarks
* The IOTHUB_MESSAGE_HANDLE instance provided as argument is copied by the function,
* so this argument can be destroyed by the calling application right after IoTHubClient_SendEventAsync returns.
* The copy of @c eventMessageHandle is later destroyed by the iothub client when the message is effectively sent, if a failure sending it occurs, or if the client is destroyed.
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SendEventAsync, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ extern "C"
IOTHUB_CLIENT_CONNECTION_RETRY_EXPIRED, \
IOTHUB_CLIENT_CONNECTION_NO_NETWORK, \
IOTHUB_CLIENT_CONNECTION_COMMUNICATION_ERROR, \
IOTHUB_CLIENT_CONNECTION_NO_PING_RESPONSE, \
IOTHUB_CLIENT_CONNECTION_OK \
IOTHUB_CLIENT_CONNECTION_OK, \
IOTHUB_CLIENT_CONNECTION_NO_PING_RESPONSE \

/** @brief Enumeration passed in by the IoT Hub when the connection status
* callback is invoked to indicate status of the connection in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_CLIENT_LL_HANDLE;
*
* @b NOTE: The application behavior is undefined if the user calls
* the ::IoTHubClient_LL_Destroy function from within any callback.
*
* @remarks
* The IOTHUB_MESSAGE_HANDLE instance provided as argument is copied by the function,
* so this argument can be destroyed by the calling application right after IoTHubClient_LL_SendEventAsync returns.
* The copy of @c eventMessageHandle is later destroyed by the iothub client when the message is effectively sent, if a failure sending it occurs, or if the client is destroyed.
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SendEventAsync, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern "C"
} IOTHUB_PROXY_OPTIONS;

static STATIC_VAR_UNUSED const char* OPTION_RETRY_INTERVAL_SEC = "retry_interval_sec";
static STATIC_VAR_UNUSED const char* OPTION_RETRY_MAX_DELAY_SECS = "retry_max_delay_secs";

static STATIC_VAR_UNUSED const char* OPTION_LOG_TRACE = "logtrace";
static STATIC_VAR_UNUSED const char* OPTION_X509_CERT = "x509certificate";
Expand All @@ -42,6 +43,11 @@ extern "C"
static STATIC_VAR_UNUSED const char* OPTION_BLOB_UPLOAD_TIMEOUT_SECS = "blob_upload_timeout_secs";
static STATIC_VAR_UNUSED const char* OPTION_PRODUCT_INFO = "product_info";

/*
* @brief Specifies the Digital Twin Model Id of the connection. Only valid for use with MQTT Transport
*/
static STATIC_VAR_UNUSED const char* OPTION_MODEL_ID = "model_id";

/*
* @brief Turns on automatic URL encoding of message properties + system properties. Only valid for use with MQTT Transport
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef IOTHUB_CLIENT_VERSION_H
#define IOTHUB_CLIENT_VERSION_H

#define IOTHUB_SDK_VERSION "1.3.6"
#define IOTHUB_SDK_VERSION "1.3.8"

#include "umock_c/umock_c_prod.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ extern "C"
*
* @b NOTE: The application behavior is undefined if the user calls
* the ::IoTHubDeviceClient_Destroy function from within any callback.
*
* @remarks
* The IOTHUB_MESSAGE_HANDLE instance provided as argument is copied by the function,
* so this argument can be destroyed by the calling application right after IoTHubDeviceClient_SendEventAsync returns.
* The copy of @c eventMessageHandle is later destroyed by the iothub client when the message is effectively sent, if a failure sending it occurs, or if the client is destroyed.
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_SendEventAsync, IOTHUB_DEVICE_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HA
*
* @b NOTE: The application behavior is undefined if the user calls
* the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
*
* @remarks
* The IOTHUB_MESSAGE_HANDLE instance provided as argument is copied by the function,
* so this argument can be destroyed by the calling application right after IoTHubDeviceClient_LL_SendEventAsync returns.
* The copy of @c eventMessageHandle is later destroyed by the iothub client when the message is effectively sent, if a failure sending it occurs, or if the client is destroyed.
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SendEventAsync, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ extern "C"
*
* @b NOTE: The application behavior is undefined if the user calls
* the ::IoTHubModuleClient_Destroy function from within any callback.
*
* @remarks
* The IOTHUB_MESSAGE_HANDLE instance provided as argument is copied by the function,
* so this argument can be destroyed by the calling application right after IoTHubModuleClient_SendEventAsync returns.
* The copy of @c eventMessageHandle is later destroyed by the iothub client when the message is effectively sent, if a failure sending it occurs, or if the client is destroyed.
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SendEventAsync, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ extern "C"
*
* @b NOTE: The application behavior is undefined if the user calls
* the ::IoTHubModuleClient_LL_Destroy function from within any callback.
*
* @remarks
* The IOTHUB_MESSAGE_HANDLE instance provided as argument is copied by the function,
* so this argument can be destroyed by the calling application right after IoTHubModuleClient_LL_SendEventAsync returns.
* The copy of @c eventMessageHandle is later destroyed by the iothub client when the message is effectively sent, if a failure sending it occurs, or if the client is destroyed.
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SendEventAsync, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
Expand Down
Binary file modified AZ3166/src/system/libdevkit-sdk-core-lib.a
Binary file not shown.
21 changes: 21 additions & 0 deletions azure-pipelines-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

pool:
vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'

- script: |
npm install
npm run build
displayName: 'npm install and build'

0 comments on commit a90ea6b

Please sign in to comment.