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 #1057 from microsoft/pre-release
Browse files Browse the repository at this point in the history
release 1.6.5
  • Loading branch information
hellyzh authored Dec 2, 2019
2 parents 81ac4ec + 0b77e71 commit 7ab7e3c
Show file tree
Hide file tree
Showing 81 changed files with 1,779 additions and 504 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/close-resolved-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Close resolved issues

on:
schedule:
- cron: "0 * * * *"

jobs:
stale:

runs-on: ubuntu-latest

steps:
- uses: blackchoey/stale@releases/v1.2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has been resolved and it will be closed if no further activity occurs within 3 days. Thank you for your contributions.'
stale-issue-label: 'pending close'
days-before-stale: 7
only-labels: 'resolved'
last-updated-user-type: 'collaborator'
days-before-close: 3
operations-per-run: 150
21 changes: 21 additions & 0 deletions .github/workflows/need-attention-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pickup issues that needs attention

on:
schedule:
- cron: "0 * * * *"

jobs:
stale:

runs-on: ubuntu-latest

steps:
- uses: blackchoey/stale@releases/v1.2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has no recent activities, please take a look and provide updates for it.'
stale-issue-label: 'need attention'
days-before-stale: 3
last-updated-user-type: 'non-collaborator'
days-before-close: 999
operations-per-run: 150
22 changes: 22 additions & 0 deletions .github/workflows/stale-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Mark stale issues and close them

on:
schedule:
- cron: "0 * * * *"

jobs:
stale:

runs-on: ubuntu-latest

steps:
- uses: blackchoey/stale@releases/v1.2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has been automatically marked as stale because it has no recent activities. It will be closed if no further activity occurs within 3 days. Thank you for your contributions.'
stale-issue-label: 'stale'
days-before-stale: 7
only-labels: 'need more info'
last-updated-user-type: 'collaborator'
days-before-close: 3
operations-per-run: 150
130 changes: 130 additions & 0 deletions AZ3166/jenkins/deployment/DevKitDeploy-forPnP.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
param(
[string]
$Environment = "staging",
$ArduinoConfigFileName = "package_pnp_mxchip_board_preview_index.json"
)

$ErrorActionPreference = "Stop"
$CurrentDir = (Get-Location).Path

Import-Module "C:\Program Files (x86)\WindowsPowerShell\Modules\AzureRM.Profile\4.6.0\AzureRM.Profile.psd1"
Import-Module "C:\Program Files (x86)\WindowsPowerShell\Modules\Azure.Storage\4.2.1\Azure.Storage.psd1"
Import-Module "C:\Program Files (x86)\WindowsPowerShell\Modules\Azure\5.1.2\Azure.psd1"


$StorageHashTable = @{"azureboard2" = $env:Azureboard2StorageKey;
"azureboard" = $env:AzureboardStorageKey};

foreach($StorageAccountName in $StorageHashTable.Keys)
{
Write-Host("[$Environment][$StorageAccountName]: Start $Environment Deployment.");

################################################################################
# Step 1: upload AZ3166 package to Azure blob storage #
################################################################################

Write-Host("Step 1: upload AZ3166 package to Azure blob storage");
$ArduinoPackageContainer = "arduinopackage"
$PackageInfoContainer = "packageinfo"

# We can move this credential to Azure Key Vault once we have deploy with production subscription
$Key = $StorageHashTable[$StorageAccountName];
$StorageContext = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $Key

# Get current package version
$CurrentVersion = Get-Content '.\system_version.txt' | Out-String
$CurrentVersion = $CurrentVersion.ToString().Trim() + "-preview"

# Upload Arduino package
$ArduinoPackageFilePath = Join-Path -Path (Get-Location).Path -ChildPath "\TestResult\AZ3166-$CurrentVersion.zip"
$ArduinoPackageBlobName = "AZ3166-" + $CurrentVersion + ".zip"
Set-AzureStorageBlobContent -Context $StorageContext -Container $Environment -File $ArduinoPackageFilePath -Blob "$ArduinoPackageContainer\$ArduinoPackageBlobName" -Force

# Upload Firmware bin file
$FirmwareFileName = "devkit-firmware-" + $CurrentVersion + "." + $env:BUILD_NUMBER + "bin"
$FirmwareFilePath = Join-Path -Path (Get-Location).Path -ChildPath "TestResult\$FirmwareFileName"
Set-AzureStorageBlobContent -Context $StorageContext -Container $Environment -File $FirmwareFilePath -Blob $FirmwareFileName -Force

#Upload Getstarted bin file
#$GetstartedFileName = "devkit-getstarted-" + $CurrentVersion + "." + $env:BUILD_NUMBER + "bin"
#$GetstartedFilePath = Join-Path -Path (Get-Location).Path -ChildPath "TestResult\$GetstartedFileName"
#Set-AzureStorageBlobContent -Context $StorageContext -Container $Environment -File $GetstartedFilePath -Blob $GetstartedFileName -Force

#Upload iotc bin file iotc-devkit-1.9.10.bin
$IoTCFileName = "iotc-devkit-" + $CurrentVersion + "." + $env:BUILD_NUMBER + "bin"
$IoTCFilePath = Join-Path -Path (Get-Location).Path -ChildPath "TestResult\$IoTCFileName"
Set-AzureStorageBlobContent -Context $StorageContext -Container $Environment -File $IoTCFilePath -Blob $IoTCFileName -Force

# Upload Firmware bin file for OTA
$OTAFirmwareFileName = "devkit-firmware-latest.ota-preview.bin"
$OTAFirmwareFilePath = Join-Path -Path (Get-Location).Path -ChildPath "TestResult\$OTAFirmwareFileName"
Set-AzureStorageBlobContent -Context $StorageContext -Container $Environment -File $OTAFirmwareFilePath -Blob $OTAFirmwareFileName -Force

################################################################################
# Step 2: Calculate package MD5 checksum and Update to configuration JSON file#
################################################################################

Write-Host("Step 2: Calculate package MD5 checksum and Update to configuration JSON file")

$MD5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$ArduinoPackageHash = [System.BitConverter]::ToString($MD5.ComputeHash([System.IO.File]::ReadAllBytes($ArduinoPackageFilePath)))
$ArduinoPackageHash = $ArduinoPackageHash.ToLower() -replace '-', ''
Write-Host($ArduinoPackageHash);

Get-AzureStorageBlobContent -Context $StorageContext -Container $Environment -Blob "$PackageInfoContainer\$ArduinoConfigFileName" -Destination $ArduinoConfigFileName -Force
$ArduinoConfigJson = Get-Content $ArduinoConfigFileName | Out-String | ConvertFrom-Json

$totalVersions = $ArduinoConfigJson.packages[0].platforms.Count
$LastPlatform = ([PSCustomObject]($ArduinoConfigJson.packages[0].platforms[$totalVersions - 1]))

if ($LastPlatform.version -eq $CurrentVersion)
{
echo LastPlatformversion ----> $LastPlatform.version
echo CurrentVersion -----> $CurrentVersion


# Update the latest version
$LastPlatform.url = "https://azureboard2.azureedge.net/$Environment/$ArduinoPackageContainer/$ArduinoPackageBlobName"
$LastPlatform.archiveFileName = $ArduinoPackageBlobName
$LastPlatform.checksum = "MD5:" + $ArduinoPackageHash
$LastPlatform.size = (Get-Item $ArduinoPackageFilePath).Length.ToString()
}
else
{
# Add new version
$NewPlatform = New-Object PSCustomObject

$LastPlatform.psobject.properties | % {
$newPlatform | Add-Member -MemberType $_.MemberType -Name $_.Name -Value $_.Value
}

$NewPlatform.version = $CurrentVersion
$NewPlatform.url = "https://azureboard2.azureedge.net/$Environment/$ArduinoPackageContainer/$ArduinoPackageBlobName"
$NewPlatform.archiveFileName = $ArduinoPackageBlobName
$NewPlatform.checksum = "MD5:" + $ArduinoPackageHash
$NewPlatform.size = (Get-Item $ArduinoPackageFilePath).Length.ToString()

$ArduinoConfigJson.packages[0].platforms += $newPlatform
$totalVersions += 1
}

Write-Host("Total packages versions: $totalVersions")

# We only maintain the latest 5 versions
if ($totalVersions -gt 5)
{
# Remove the oldest one
$ArduinoConfigJson.packages[0].platforms = $ArduinoConfigJson.packages[0].platforms[1..($totalVersions - 1)]
}

$ArduinoConfigJson | ConvertTo-Json -Depth 10 | Out-File $ArduinoConfigFileName -Encoding ascii

# Upload Arduino configuration file to Azure blob storage
$ArduinoConfigJsonBlobName = "$PackageInfoContainer/$ArduinoConfigFileName"
Set-AzureStorageBlobContent -Context $StorageContext -Container $Environment -File $ArduinoConfigFileName -Blob $ArduinoConfigJsonBlobName -Force

$ArduinoConfigJsonBlobURL = "https://azureboard2.azureedge.net/$Environment/$ArduinoConfigJsonBlobName"
Write-Host("Arduino board manager JSON file URI: $ArduinoConfigJsonBlobURL")

Write-Host("[$Environment][$StorageAccountName]: Deployment completed.");
}
17 changes: 11 additions & 6 deletions AZ3166/jenkins/deployment/DevKitDeploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ param(
$ErrorActionPreference = "Stop"
$CurrentDir = (Get-Location).Path

Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Profile\AzureRM.Profile.psd1"
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\Storage\Azure.Storage\Azure.Storage.psd1"
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1"
Import-Module "C:\Program Files (x86)\WindowsPowerShell\Modules\AzureRM.Profile\4.6.0\AzureRM.Profile.psd1"
Import-Module "C:\Program Files (x86)\WindowsPowerShell\Modules\Azure.Storage\4.2.1\Azure.Storage.psd1"
Import-Module "C:\Program Files (x86)\WindowsPowerShell\Modules\Azure\5.1.2\Azure.psd1"

$StorageHashTable = @{"azureboard2" = $env:Azureboard2StorageKey;
"azureboard" = $env:AzureboardStorageKey};
Expand Down Expand Up @@ -40,15 +40,20 @@ foreach($StorageAccountName in $StorageHashTable.Keys)
Set-AzureStorageBlobContent -Context $StorageContext -Container $Environment -File $ArduinoPackageFilePath -Blob "$ArduinoPackageContainer\$ArduinoPackageBlobName" -Force

# Upload Firmware bin file
$FirmwareFileName = "devkit-firmware-" + $CurrentVersion + "." + $env:BUILD_NUMBER + ".bin"
$FirmwareFileName = "devkit-firmware-" + $CurrentVersion + "." + $env:BUILD_NUMBER + "bin"
$FirmwareFilePath = Join-Path -Path (Get-Location).Path -ChildPath "TestResult\$FirmwareFileName"
Set-AzureStorageBlobContent -Context $StorageContext -Container $Environment -File $FirmwareFilePath -Blob $FirmwareFileName -Force

# Upload Firmware bin file for OTA
$OTAFirmwareFileName = "devkit-firmware-latest.ota.bin"
$OTAFirmwareFilePath = Join-Path -Path (Get-Location).Path -ChildPath "TestResult\$OTAFirmwareFileName"
Set-AzureStorageBlobContent -Context $StorageContext -Container $Environment -File $OTAFirmwareFilePath -Blob $OTAFirmwareFileName -Force


#Upload Getstarted bin file
$GetstartedFileName = "devkit-getstarted-" + $CurrentVersion + "." + $env:BUILD_NUMBER + "bin"
$GetstartedFilePath = Join-Path -Path (Get-Location).Path -ChildPath "TestResult\$GetstartedFileName"
Set-AzureStorageBlobContent -Context $StorageContext -Container $Environment -File $GetstartedFilePath -Blob $GetstartedFileName -Force

################################################################################
# Step 2: Calculate package MD5 checksum and Update to configuration JSON file#
################################################################################
Expand Down Expand Up @@ -112,4 +117,4 @@ foreach($StorageAccountName in $StorageHashTable.Keys)
Write-Host("Arduino board manager JSON file URI: $ArduinoConfigJsonBlobURL")

Write-Host("[$Environment][$StorageAccountName]: Deployment completed.");
}
}
2 changes: 1 addition & 1 deletion AZ3166/src/cores/arduino/UARTClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "HardwareSerial.h"
#include "BufferedSerial.h"

#define UART_RCV_SIZE 128
#define UART_RCV_SIZE 256

class UARTClass : public HardwareSerial
{
Expand Down
41 changes: 32 additions & 9 deletions AZ3166/src/cores/arduino/cli/console_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,20 @@ static void wifi_ssid_command(int argc, char **argv);
static void wifi_pwd_Command(int argc, char **argv);
static void az_iothub_command(int argc, char **argv);
static void dps_uds_command(int argc, char **argv);
static void az_iotdps_command(int argc, char **argv);
static void enable_secure_command(int argc, char **argv);

static const struct console_command cmds[] = {
{"help", "Help document", false, help_command},
{"version", "System version", false, get_version_command},
{"exit", "Exit and reboot", false, reboot_and_exit_command},
{"scan", "Scan Wi-Fi AP", false, wifi_scan},
{"set_wifissid", "Set Wi-Fi SSID", false, wifi_ssid_command},
{"set_wifipwd", "Set Wi-Fi password", true, wifi_pwd_Command},
{"set_az_iothub", "Set the connection string of Microsoft Azure IoT Hub", false, az_iothub_command},
{"set_dps_uds", "Set DPS Unique Device Secret (DPS)", true, dps_uds_command},
{"enable_secure", "Enable secure channel between AZ3166 and secure chip", false, enable_secure_command},
{"help", "Help document", false, help_command},
{"version", "System version", false, get_version_command},
{"exit", "Exit and reboot", false, reboot_and_exit_command},
{"scan", "Scan Wi-Fi AP", false, wifi_scan},
{"set_wifissid", "Set Wi-Fi SSID", false, wifi_ssid_command},
{"set_wifipwd", "Set Wi-Fi password", true, wifi_pwd_Command},
{"set_az_iothub", "Set IoT Hub device connection string", false, az_iothub_command},
{"set_dps_uds", "Set DPS Unique Device Secret (UDS) for X.509 certificates.", true, dps_uds_command},
{"set_az_iotdps", "Set DPS Symmetric Key. Format: \"DPSEndpoint=global.azure-devices-provisioning.net;IdScope=XXX;DeviceId=XXX;SymmetricKey=XXX\"", false, az_iotdps_command},
{"enable_secure", "Enable secure channel between AZ3166 and secure chip", false, enable_secure_command},
};

static const int cmd_count = sizeof(cmds) / sizeof(struct console_command);
Expand Down Expand Up @@ -245,6 +247,27 @@ static void dps_uds_command(int argc, char **argv)
}
}

static void az_iotdps_command(int argc, char **argv)
{
if (argc == 1 || argv[1] == NULL)
{
Serial.printf("Usage: set_az_iotdps <connection string>. Please provide the connection string of DPS.\r\n");
return;
}
int len = strlen(argv[1]) + 1;
if (len == 0 || len > AZ_IOT_HUB_MAX_LEN)
{
Serial.printf("Invalid DPS connection string.\r\n");
return;
}

int result = write_eeprom(argv[1], AZ_IOT_HUB_ZONE_IDX);
if (result == 0)
{
Serial.printf("INFO: Set DPS connection string successfully.\r\n");
}
}

static void enable_secure_command(int argc, char **argv)
{
int ret = -2;
Expand Down
2 changes: 1 addition & 1 deletion AZ3166/src/cores/arduino/system/SystemVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int status = WL_IDLE_STATUS;
int arrivedcount = 0;
bool hasWifi = false;

const char* mqttServer = "iot.eclipse.org"; //"m2m.eclipse.org";
const char* mqttServer = "mqtt.eclipse.org";
int port = 1883;

void initWifi()
Expand Down
10 changes: 10 additions & 0 deletions AZ3166/src/libraries/WiFi/src/AZ3166WiFiServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ void WiFiServer::begin()
}
}

void WiFiServer::setTimeout(int timeout = -1)
{
if (_pTcpServer == NULL)
{
return;
}

_pTcpServer->set_timeout(timeout);
}

WiFiClient WiFiServer::available()
{
if (_pTcpServer == NULL )
Expand Down
8 changes: 8 additions & 0 deletions AZ3166/src/libraries/WiFi/src/AZ3166WiFiServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ class WiFiServer : public Print

WiFiClient available();
void begin();

/** Set timeout on blocking socket operations
*
* setTimeout(0) is equivalent to set blocking = false
* setTimeout(-1) is equivalent to set blocking = true
* @param timeout Timeout in milliseconds
*/
void setTimeout(int timeout /*= -1*/);
void close();
void send(int code, char *content_type, const String &content);
virtual size_t write(unsigned char);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#ifndef BASE32_H
#define BASE32_H

#include "azure_c_shared_utility/strings.h"
#include "azure_c_shared_utility/buffer_.h"
#ifndef AZURE_BASE32_H
#define AZURE_BASE32_H

#ifdef __cplusplus
#include <cstddef>
extern "C" {
#else
#include <stddef.h>
#endif

#include "azure_c_shared_utility/strings.h"
#include "azure_c_shared_utility/buffer_.h"

#include "umock_c/umock_c_prod.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Encodes the BUFFER_HANDLE to a base 32 STRING_HANDLE
*
Expand Down Expand Up @@ -57,4 +60,4 @@ MOCKABLE_FUNCTION(, BUFFER_HANDLE, Azure_Base32_Decode_String, const char*, sour
}
#endif

#endif /* BASE64_H */
#endif /* AZURE_BASE32_H */
Loading

0 comments on commit 7ab7e3c

Please sign in to comment.