Skip to content

Commit

Permalink
Merge branch 'release/v0.7.0-rc.7' into develop. Rebuilt wiced agains…
Browse files Browse the repository at this point in the history
…t commit 0eeac588ae5c48739f051db674fcd031b9ccecf2

#	hal/src/photon/lib/FreeRTOS/Lib_DNS_Redirect_Daemon.a
#	hal/src/photon/lib/Lib_HTTP_Server.a
  • Loading branch information
m-mcgowan committed Feb 5, 2018
2 parents cc880e5 + a1605c5 commit b35150b
Show file tree
Hide file tree
Showing 53 changed files with 265 additions and 140 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 0.7.0-rc.7

### BUGFIX

- [Photon] Regression with SoftAP and URL-encoded form query [#1432](https://github.com/spark/firmware/issues/1432)
- Particle.connect() hard blocking since 0.6.1-rc.1 [#1399](https://github.com/spark/firmware/issues/1399)
- [Electron] Cellular resolve does not return 0 / false when it receives bad DNS resolution related to bad cell service [#1304](https://github.com/spark/firmware/issues/1304)
- [Core] Use the device ID as the USB serial number [#1367](https://github.com/spark/firmware/issues/1367)
- [Electron] Fix heap bounds for system part 1 [#1478](https://github.com/particle-iot/firmware/pull/1478)
- Fixed shadowing of `write(const unint_8_t*, sizte_t)` in USBKeyboard [#1372](https://github.com/particle-iot/firmware/pull/1372)


## 0.8.0-rc.1

## FEATURES
Expand All @@ -23,6 +35,7 @@
- Cloud random seed not working [#1312](https://github.com/spark/firmware/issues/1312)
- [Electron] Error handling in the data usage API [#1435](https://github.com/spark/firmware/pull/1435)


## 0.7.0-rc.6

### BUGFIX
Expand Down
63 changes: 23 additions & 40 deletions bootloader/src/core/dfu_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include "usb_pwr.h"
#include "dfu_mal.h"
#include "core_hal.h"
#include "deviceid_hal.h"
#include "bytes2hexbuf.h"
#include <string.h>

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
Expand All @@ -42,7 +45,6 @@ uint8_t DeviceStatus[6];

/* Extern variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
static void IntToUnicode(uint32_t value, uint8_t* pbuf, uint8_t len);

/* Private functions ---------------------------------------------------------*/

Expand Down Expand Up @@ -87,56 +89,37 @@ void HAL_DFU_USB_Init(void)
USB_Init();
}

/*******************************************************************************
* Function Name : Get_SerialNum.
* Description : Create the serial number string descriptor.
* Input : None.
* Return : None.
*******************************************************************************/
void Get_SerialNum(void)
const int device_id_len = 12;
/* Read the STM32 Device electronic signature */
unsigned HAL_device_ID(uint8_t* dest, unsigned destLen)
{
uint32_t Device_Serial0, Device_Serial1, Device_Serial2;

Device_Serial0 = *(uint32_t*)ID1;
Device_Serial1 = *(uint32_t*)ID2;
Device_Serial2 = *(uint32_t*)ID3;

Device_Serial0 += Device_Serial2;

if (Device_Serial0 != 0)
{
IntToUnicode(Device_Serial0, &DFU_StringSerial[2], 8);
IntToUnicode(Device_Serial1, &DFU_StringSerial[18], 4);
if (dest!=NULL && destLen!=0) {
memcpy(dest, (char*)ID1, destLen<device_id_len ? destLen : device_id_len);
}
return device_id_len;
}

/*******************************************************************************
* Function Name : HexToChar.
* Description : Convert Hex 32Bits value into char.
* Function Name : Get_SerialNum.
* Description : Create the serial number string descriptor.
* Input : None.
* Return : None.
*******************************************************************************/
static void IntToUnicode(uint32_t value, uint8_t* pbuf, uint8_t len)
void Get_SerialNum(void)
{
uint8_t idx = 0;

for (idx = 0; idx < len; idx++)
{
if (((value >> 28)) < 0xA)
{
pbuf[2 * idx] = (value >> 28) + '0';
}
else
{
pbuf[2 * idx] = (value >> 28) + 'A' - 10;
}

value = value << 4;

pbuf[2 * idx + 1] = 0;
}
uint8_t deviceId[16];
char deviceIdHex[sizeof(deviceId) * 2 + 1] = {0};
unsigned deviceIdLen = 0;
deviceIdLen = HAL_device_ID(deviceId, sizeof(deviceId));
bytes2hexbuf(deviceId, deviceIdLen, deviceIdHex);

for (unsigned i = 2, pos = 0; i < DFU_SIZ_STRING_SERIAL && pos < 2 * deviceIdLen; i += 2, pos++) {
DFU_StringSerial[i] = deviceIdHex[pos];
DFU_StringSerial[i + 1] = '\0';
}
}


void platform_startup()
{
}
2 changes: 1 addition & 1 deletion bootloader/src/core/usb_desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define DFU_SIZ_STRING_LANGID 4
#define DFU_SIZ_STRING_VENDOR 38
#define DFU_SIZ_STRING_PRODUCT 20
#define DFU_SIZ_STRING_SERIAL 26
#define DFU_SIZ_STRING_SERIAL 52
#define DFU_SIZ_STRING_INTERFACE0 98 /* Flash Bank 0 */
#define DFU_SIZ_STRING_INTERFACE1 98 /* SPI Flash */

Expand Down
53 changes: 10 additions & 43 deletions hal/src/core/usb_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "usb_prop.h"
#include "delay_hal.h"
#include "usb_settings.h"
#include "deviceid_hal.h"
#include "bytes2hexbuf.h"

/* Private typedef -----------------------------------------------------------*/

Expand Down Expand Up @@ -63,9 +65,6 @@ __IO uint8_t PrevXferComplete;
/* Extern variables ----------------------------------------------------------*/
extern volatile LINE_CODING linecoding;

/* Private function prototypes -----------------------------------------------*/
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len);

#if defined (USB_CDC_ENABLE) || defined (USB_HID_ENABLE)
/*******************************************************************************
* Function Name : SPARK_USB_Setup
Expand All @@ -92,18 +91,14 @@ void SPARK_USB_Setup(void)
*******************************************************************************/
void Get_SerialNum(void)
{
uint32_t Device_Serial0, Device_Serial1, Device_Serial2;

Device_Serial0 = *(uint32_t*)ID1;
Device_Serial1 = *(uint32_t*)ID2;
Device_Serial2 = *(uint32_t*)ID3;

Device_Serial0 += Device_Serial2;

if (Device_Serial0 != 0)
{
IntToUnicode (Device_Serial0, &USB_StringSerial[2] , 8);
IntToUnicode (Device_Serial1, &USB_StringSerial[18], 4);
uint8_t deviceId[16];
char deviceIdHex[sizeof(deviceId) * 2 + 1] = {0};
unsigned deviceIdLen = 0;
deviceIdLen = HAL_device_ID(deviceId, sizeof(deviceId));
bytes2hexbuf(deviceId, deviceIdLen, deviceIdHex);
for (unsigned i = 2, pos = 0; i < USB_SIZ_STRING_SERIAL && pos < 2 * deviceIdLen; i += 2, pos++) {
USB_StringSerial[i] = deviceIdHex[pos];
USB_StringSerial[i + 1] = '\0';
}
}
#endif
Expand Down Expand Up @@ -348,31 +343,3 @@ void USB_HID_Send_Report(void *pHIDReport, size_t reportSize)
}
}
#endif

/*******************************************************************************
* Function Name : HexToChar.
* Description : Convert Hex 32Bits value into char.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len)
{
uint8_t idx = 0;

for( idx = 0 ; idx < len ; idx ++)
{
if( ((value >> 28)) < 0xA )
{
pbuf[ 2* idx] = (value >> 28) + '0';
}
else
{
pbuf[2* idx] = (value >> 28) + 'A' - 10;
}

value = value << 4;

pbuf[ 2* idx + 1] = 0;
}
}
Binary file modified hal/src/photon/lib/BESL.ARM_CM3.release.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/FreeRTOS.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/Lib_DHCP_Server.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/Lib_DNS.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/Lib_DNS_Redirect_Daemon.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/LwIP.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/Platform_BCM9WCDUSI09.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/Platform_BCM9WCDUSI14.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/STM32F2xx.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/STM32F2xx_Peripheral_Drivers.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/STM32F2xx_bootloader.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/WICED.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/WICED_FreeRTOS_Interface.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/WICED_LwIP_Interface.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/WWD_LwIP_Interface_FreeRTOS.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/WWD_for_SDIO_FreeRTOS.a
Binary file not shown.
Binary file modified hal/src/photon/lib/FreeRTOS/Wiced_Network_LwIP_FreeRTOS.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_HTTP_Server.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_Linked_List.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_Ring_Buffer.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_SPI_Flash_Library_BCM9WCDUSI09.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_SPI_Flash_Library_BCM9WCDUSI14.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_TLV.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_Wiced_RO_FS.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_base64.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_crc.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_crypto_open.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_crypto_open_part2.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Lib_micro_ecc.a
Binary file not shown.
Binary file modified hal/src/photon/lib/STM32F2xx_Peripheral_Libraries.a
Binary file not shown.
Binary file modified hal/src/photon/lib/Supplicant_BESL.a
Binary file not shown.
Binary file modified hal/src/photon/lib/common_GCC.a
Binary file not shown.
Binary file modified hal/src/photon/lib/resources.a
Binary file not shown.
16 changes: 14 additions & 2 deletions hal/src/photon/softap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# include "http_server.h"

# ifndef SOFTAP_HTTP_MAXIMUM_CONNECTIONS
# define SOFTAP_HTTP_MAXIMUM_CONNECTIONS 5
# define SOFTAP_HTTP_MAXIMUM_CONNECTIONS (10)
# endif // SOFTAP_HTTP_MAXIMUM_CONNECTIONS

# define SOFTAP_HTTP_MAXIMUM_URL_LENGTH 255
Expand Down Expand Up @@ -1397,7 +1397,19 @@ class HTTPDispatcher {
} else {
PageProvider* p = (PageProvider*)arg;
if (p) {
p(req->url ? req->url : url, &writeHeader, req->stream, &r, &w, nullptr);
char* baseurl = (char*)(req->url ? req->url : url);
if (baseurl != nullptr) {
const size_t baseurl_len = strlen(baseurl);
// Restore full query string
if (url_query_string != nullptr &&
strlen(url_query_string) && url_query_string == (baseurl + baseurl_len + 1)) {
baseurl[baseurl_len] = '?';
p(baseurl, &writeHeader, req->stream, &r, &w, nullptr);
baseurl[baseurl_len] = '\0';
} else {
p(baseurl, &writeHeader, req->stream, &r, &w, nullptr);
}
}
}
}
// We need to deactivate chunked transfer mode here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#define USB_SIZ_STRING_LANGID 4
#define USB_SIZ_STRING_VENDOR 38
#define USB_SIZ_STRING_PRODUCT 50
#define USB_SIZ_STRING_SERIAL 26
#define USB_SIZ_STRING_SERIAL 52

#define STANDARD_ENDPOINT_DESC_SIZE 0x09

Expand Down
13 changes: 13 additions & 0 deletions system/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,17 +407,26 @@ void manage_safe_mode()
}
}

bool semi_automatic_connecting(bool threaded) {
return system_mode() == SEMI_AUTOMATIC && !threaded && spark_cloud_flag_auto_connect() && !spark_cloud_flag_connected();
}

void app_loop(bool threaded)
{
DECLARE_SYS_HEALTH(ENTERED_WLAN_Loop);
if (!threaded)
Spark_Idle();

static uint8_t SPARK_WIRING_APPLICATION = 0;
do {
if(threaded || SPARK_WLAN_SLEEP || !spark_cloud_flag_auto_connect() || spark_cloud_flag_connected() || SPARK_WIRING_APPLICATION || (system_mode()!=AUTOMATIC))
{
if(threaded || !SPARK_FLASH_UPDATE)
{
if (semi_automatic_connecting(threaded)) {
break;
}

if ((SPARK_WIRING_APPLICATION != 1))
{
//Execute user application setup only once
Expand All @@ -428,7 +437,10 @@ void app_loop(bool threaded)
#if !(defined(MODULAR_FIRMWARE) && MODULAR_FIRMWARE)
_post_loop();
#endif
if (semi_automatic_connecting(threaded)) {
break;
}
}

//Execute user application loop
DECLARE_SYS_HEALTH(ENTERED_Loop);
Expand All @@ -441,6 +453,7 @@ void app_loop(bool threaded)
}
}
}
} while(false);
#if PLATFORM_ID == 3 && SUSPEND_APPLICATION_THREAD_LOOP_COUNT
// Suspend thread execution for some minimum time on every Nth loop iteration in order to workaround
// 100% CPU usage on the virtual device platform
Expand Down
84 changes: 84 additions & 0 deletions user/tests/app/particle_connect_semi_automatic_issue_1399/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include "application.h"

SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(DISABLED);

LOG_SOURCE_CATEGORY("test")

namespace {

SerialLogHandler logHandler(LOG_LEVEL_NONE, {
{ "test", LOG_LEVEL_ALL }
});

static bool loopExecuted = false;
static bool testFinished = false;

static void fail() {
testFinished = true;
RGB.control(true);
RGB.color(0xff0000); // Red
LOG(ERROR, "TEST FAILED");
}

static void pass() {
testFinished = true;
RGB.control(true);
RGB.color(0x00ff00); // Green
LOG(INFO, "TEST SUCCEEDED");
}

} // namespace

void setup() {
waitUntil(Serial.isConnected);

LOG(INFO, "Test started");
LOG(INFO, "Connecting to WiFi network");
WiFi.on();
WiFi.connect();
waitUntil(WiFi.ready);
LOG(INFO, "Connected to WiFi network");

LOG(INFO, "Connecting to the cloud");
Particle.connect();
if (Particle.connected()) {
fail();
}
}

void loop() {
if (testFinished) {
return;
}

if (!loopExecuted) {
loopExecuted = true;

// First time the loop is running. We should be connected to the cloud
if (!Particle.connected()) {
fail();
return;
}

LOG(INFO, "Connected to the cloud");

// Disconnect from the cloud
LOG(INFO, "Disconnecting from the cloud");
Particle.disconnect();
waitUntil(Particle.disconnected);
LOG(INFO, "Disconnected from the cloud");

LOG(INFO, "Connecting to the cloud");
Particle.connect();
} else {
// Second time the loop is running, we should also be connected to the cloud again
if (!Particle.connected()) {
fail();
return;
}
LOG(INFO, "Connected to the cloud");

pass();
}
}
Loading

0 comments on commit b35150b

Please sign in to comment.