From a61583fba4b83fb450eb5162676ff795e231293c Mon Sep 17 00:00:00 2001 From: keeramis Date: Thu, 11 Aug 2022 09:15:38 -0500 Subject: [PATCH] fix wlan interfaces and minor --- hal/src/rtl872x/gsm0710muxer/platform.h | 4 +-- hal/src/trackerm/network/network.cpp | 36 ++++++++--------------- hal/src/trackerm/ota_flash_hal.cpp | 11 +------ hal/src/trackerm/platform_ncp_quectel.cpp | 1 - hal/src/tron/network/network.cpp | 16 +++------- 5 files changed, 19 insertions(+), 49 deletions(-) diff --git a/hal/src/rtl872x/gsm0710muxer/platform.h b/hal/src/rtl872x/gsm0710muxer/platform.h index 4afbd4e637..e9daa8164e 100644 --- a/hal/src/rtl872x/gsm0710muxer/platform.h +++ b/hal/src/rtl872x/gsm0710muxer/platform.h @@ -43,10 +43,10 @@ const auto taskPriority = OS_THREAD_PRIORITY_NETWORK; #define GSM0710_ASSERT(x) SPARK_ASSERT(x) // #define GSM0710_MODEM_STATUS_SEND_EMPTY_BREAK -#define GSM0710_PUMP_INPUT_DATA 50 +// #define GSM0710_PUMP_INPUT_DATA 50 // #define GSM0710_ENABLE_DEBUG_LOGGING -// #define GSM0710_SHARED_STREAM_EVENT_GROUP +#define GSM0710_SHARED_STREAM_EVENT_GROUP #define GSM0710_SHARED_STREAM_EVENT_BASE (__builtin_ffs(HAL_USART_PVT_EVENT_MAX)) #if HAL_PLATFORM_WIFI diff --git a/hal/src/trackerm/network/network.cpp b/hal/src/trackerm/network/network.cpp index 0ef89c73a8..a81876e3df 100644 --- a/hal/src/trackerm/network/network.cpp +++ b/hal/src/trackerm/network/network.cpp @@ -33,6 +33,7 @@ #include "realtek/rtlncpnetif.h" #include "lwip_util.h" #include "core_hal.h" +#include "deviceid_hal.h" using namespace particle; using namespace particle::net; @@ -153,18 +154,10 @@ int if_init_platform(void*) { reserve_netif_index(); /* en2 - Ethernet FeatherWing (optional) */ - uint8_t mac[6] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; - { - // const uint32_t lsb = __builtin_bswap32(NRF_FICR->DEVICEADDR[0]); - // const uint32_t msb = NRF_FICR->DEVICEADDR[1] & 0xffff; - // memcpy(mac + 2, &lsb, sizeof(lsb)); - // mac[0] = msb >> 8; - // mac[1] = msb; - /* Drop 'multicast' bit */ - mac[0] &= 0b11111110; - /* Set 'locally administered' bit */ - mac[0] |= 0b10; - } + uint8_t deviceId[HAL_DEVICE_ID_SIZE] = {}; + hal_get_device_id(deviceId, sizeof(deviceId)); + uint8_t* mac = deviceId + HAL_DEVICE_ID_SIZE - 6; + mac[5] += 3; if (HAL_Feature_Get(FEATURE_ETHERNET_DETECTION)) { en2 = new WizNetif(HAL_SPI_INTERFACE1, D5, D3, D4, mac); @@ -178,15 +171,6 @@ int if_init_platform(void*) { reserve_netif_index(); } -#if !HAL_PLATFORM_WIFI_SCAN_ONLY - /* wl4 - Realtek NCP Station */ - wl4 = new RealtekNcpNetif(); - if (wl4) { - ((RealtekNcpNetif*)wl4)->setWifiManager(wifiNetworkManager()); - ((RealtekNcpNetif*)wl4)->init(); - } -#endif - /* pp3 - Cellular */ pp3 = new PppNcpNetif(); if (pp3) { @@ -194,7 +178,13 @@ int if_init_platform(void*) { ((PppNcpNetif*)pp3)->init(); } - reserve_netif_index(); // wl4 + /* wl4 - Realtek NCP Station */ + wl4 = new RealtekNcpNetif(); + if (wl4) { + ((RealtekNcpNetif*)wl4)->setWifiManager(wifiNetworkManager()); + ((RealtekNcpNetif*)wl4)->init(); + } + reserve_netif_index(); // wl5 /* TODO: wl5 - Realtek NCP Access Point */ (void)wl5; @@ -240,11 +230,9 @@ unsigned char* rltk_wlan_get_gwmask(int idx) { void rltk_wlan_set_netif_info(int idx_wlan, void* dev, unsigned char* dev_addr) { LOG(INFO, "rltk_wlan_set_netif_info: %d, %02x:%02x:%02x:%02x:%02x:%02x", idx_wlan, dev_addr[0], dev_addr[1], dev_addr[2], dev_addr[3], dev_addr[4], dev_addr[5]); -#if !HAL_PLATFORM_WIFI_SCAN_ONLY if (wl4) { memcpy(wl4->interface()->hwaddr, dev_addr, sizeof(wl4->interface()->hwaddr)); } -#endif } void netif_rx(int idx, unsigned int len) { diff --git a/hal/src/trackerm/ota_flash_hal.cpp b/hal/src/trackerm/ota_flash_hal.cpp index 204f61809a..3c044809b5 100644 --- a/hal/src/trackerm/ota_flash_hal.cpp +++ b/hal/src/trackerm/ota_flash_hal.cpp @@ -1,12 +1,4 @@ -/** - ****************************************************************************** - * @file ota_flash_hal.cpp - * @author Matthew McGowan, Satish Nair - * @version V1.0.0 - * @date 27-Jul-2022 - * @brief - ****************************************************************************** - * +/* * Copyright (c) 2022 Particle Industries, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or @@ -21,7 +13,6 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . - ****************************************************************************** */ #include diff --git a/hal/src/trackerm/platform_ncp_quectel.cpp b/hal/src/trackerm/platform_ncp_quectel.cpp index d317b82d7e..bcb69aea43 100644 --- a/hal/src/trackerm/platform_ncp_quectel.cpp +++ b/hal/src/trackerm/platform_ncp_quectel.cpp @@ -44,7 +44,6 @@ const auto NCP_IDX_PRIMARY_QUECTEL = 0; PlatformNCPIdentifier platform_primary_ncp_identifier() { // Check the DCT - return PlatformNCPIdentifier::PLATFORM_NCP_QUECTEL_BG95_M1; uint8_t ncpId = 0; int r = dct_read_app_data_copy(DCT_NCP_ID_OFFSET, &ncpId, 1); if (r < 0 || !isValidNcpId(ncpId)) { diff --git a/hal/src/tron/network/network.cpp b/hal/src/tron/network/network.cpp index 1d3e8c6713..08c120f167 100644 --- a/hal/src/tron/network/network.cpp +++ b/hal/src/tron/network/network.cpp @@ -105,18 +105,10 @@ int if_init_platform(void*) { reserve_netif_index(); /* en2 - Ethernet FeatherWing (optional) */ - uint8_t mac[6] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; - { - // const uint32_t lsb = __builtin_bswap32(NRF_FICR->DEVICEADDR[0]); - // const uint32_t msb = NRF_FICR->DEVICEADDR[1] & 0xffff; - // memcpy(mac + 2, &lsb, sizeof(lsb)); - // mac[0] = msb >> 8; - // mac[1] = msb; - /* Drop 'multicast' bit */ - mac[0] &= 0b11111110; - /* Set 'locally administered' bit */ - mac[0] |= 0b10; - } + uint8_t deviceId[HAL_DEVICE_ID_SIZE] = {}; + hal_get_device_id(deviceId, sizeof(deviceId)); + uint8_t* mac = deviceId + HAL_DEVICE_ID_SIZE - 6; + mac[5] += 3; if (HAL_Feature_Get(FEATURE_ETHERNET_DETECTION)) { en2 = new WizNetif(HAL_SPI_INTERFACE1, D5, D3, D4, mac);