Skip to content

Commit

Permalink
Merge pull request #1719 from particle-iot/fix/wiring-tests
Browse files Browse the repository at this point in the history
[Gen 3] Fix/wiring tests
  • Loading branch information
technobly committed Apr 11, 2019
2 parents 31eef09 + 7cf10ff commit e8aad04
Show file tree
Hide file tree
Showing 30 changed files with 1,858 additions and 542 deletions.
16 changes: 9 additions & 7 deletions ci/enumerate_build_matrix.sh
Expand Up @@ -44,17 +44,13 @@ MAKE=runmake

# define build matrix dimensions
# "" means execute execute the $MAKE command without that var specified
# DEBUG_BUILD=( y n )
DEBUG_BUILD=( y n )
PLATFORM=( core photon P1 electron xenon argon boron xenon-som argon-som boron-som )
# P1 bootloader built with gcc 4.8.4 doesn't fit flash, disabling for now
PLATFORM_BOOTLOADER=( core photon electron xenon argon boron xenon-som argon-som boron-som )
SPARK_CLOUD=( y n )
APP=( "" tinker product_id_and_version )
# TEST=( wiring/api wiring/no_fixture )

# FIXME: not building tests and not building DEBUG_BUILD=y for now
DEBUG_BUILD=( n )
TEST=()
APP=( "" tinker product_id_and_version)
TEST=( wiring/api wiring/no_fixture )

MODULAR_PLATFORM=( photon P1 electron xenon argon boron xenon-som argon-som boron-som )

Expand Down Expand Up @@ -143,6 +139,12 @@ for db in "${DEBUG_BUILD[@]}"
do
for p in "${MODULAR_PLATFORM[@]}"
do
# Gen 3 overflow with modular DEBUG_BUILD=y, so skip those
if [[ "$db" = "y" ]]; then
if [[ "$p" = "xenon" ]] || [[ "$p" = "argon" ]] || [[ "$p" = "boron" ]] || [[ "$p" = "xenon-som" ]] || [[ "$p" = "argon-som" ]] || [[ "$p" = "boron-som" ]]; then
continue
fi
fi
cmd="${MAKE} DEBUG_BUILD=\"$db\" PLATFORM=\"$p\" COMPILE_LTO=\"n\""
BUILD_JOBS+=("modules ${#BUILD_JOBS[@]} ${cmd}")
done
Expand Down
4 changes: 4 additions & 0 deletions hal/inc/hal_platform.h
Expand Up @@ -238,4 +238,8 @@
#define HAL_PLATFORM_POWER_MANAGEMENT_OPTIONAL (0)
#endif // HAL_PLATFORM_POWER_MANAGEMENT_OPTIONAL

#ifndef HAL_PLATFORM_IPV6
#define HAL_PLATFORM_IPV6 (0)
#endif // HAL_PLATFORM_IPV6

#endif /* HAL_PLATFORM_H */
2 changes: 2 additions & 0 deletions hal/src/nRF52840/hal_platform_nrf52840_config.h
Expand Up @@ -81,3 +81,5 @@
#define HAL_PLATFORM_NETWORK_MULTICAST (1)

#define HAL_PLATFORM_BUTTON_DEBOUNCE_IN_SYSTICK (1)

#define HAL_PLATFORM_IPV6 (1)
7 changes: 6 additions & 1 deletion system/inc/system_network.h
Expand Up @@ -61,6 +61,11 @@ typedef enum network_disconnect_reason {
NETWORK_DISCONNECT_REASON_RESET = 6 // Disconnected to recover from cloud connection errors
} network_disconnect_reason;

typedef enum network_ready_type {
NETWORK_READY_TYPE_ANY = 0x00,
NETWORK_READY_TYPE_IPV4 = 0x01,
NETWORK_READY_TYPE_IPV6 = 0x02
} network_ready_type;
/**
* network_handle_t used to differentiate between two networks
* on the same device, e.g. WLAN and AP modes on Photon.
Expand All @@ -78,7 +83,7 @@ const void* network_config(network_handle_t network, uint32_t param1, void* rese
void network_connect(network_handle_t network, uint32_t flags, uint32_t param1, void* reserved);
bool network_connecting(network_handle_t network, uint32_t param1, void* reserved);
void network_disconnect(network_handle_t network, uint32_t reason, void* reserved);
bool network_ready(network_handle_t network, uint32_t param1, void* reserved);
bool network_ready(network_handle_t network, uint32_t type, void* reserved);
void network_on(network_handle_t network, uint32_t flags, uint32_t param1, void* reserved);
void network_off(network_handle_t network, uint32_t flags, uint32_t param1, void* reserved);
int network_connect_cancel(network_handle_t network, uint32_t flags, uint32_t param1, void* reserved);
Expand Down
31 changes: 23 additions & 8 deletions system/src/system_network_manager_api.cpp
Expand Up @@ -190,23 +190,38 @@ void network_disconnect(network_handle_t network, uint32_t reason, void* reserve
}());
}

bool network_ready(network_handle_t network, uint32_t param, void* reserved) {
bool network_ready(network_handle_t network, uint32_t type, void* reserved) {
if (network == NETWORK_INTERFACE_ALL) {
return NetworkManager::instance()->isConnectivityAvailable();
if ((network_ready_type)type == NETWORK_READY_TYPE_ANY) {
return NetworkManager::instance()->isConnectivityAvailable();
} else {
if ((network_ready_type)type == NETWORK_READY_TYPE_IPV4) {
return NetworkManager::instance()->isIp4ConnectivityAvailable();
} else if ((network_ready_type)type == NETWORK_READY_TYPE_IPV6) {
return NetworkManager::instance()->isIp6ConnectivityAvailable();
}
}
} else {
if_t iface;
if (!if_get_by_index(network, &iface)) {
if (NetworkManager::instance()->isInterfaceEnabled(iface)) {
auto ip4 = NetworkManager::instance()->getInterfaceIp4State(iface);
auto ip6 = NetworkManager::instance()->getInterfaceIp6State(iface);
// FIXME
if (network != NETWORK_INTERFACE_MESH) {
if (ip4 == NetworkManager::ProtocolState::CONFIGURED || ip6 == NetworkManager::ProtocolState::CONFIGURED) {
return true;
if ((network_ready_type)type == NETWORK_READY_TYPE_ANY) {
if (network != NETWORK_INTERFACE_MESH) {
if (ip4 == NetworkManager::ProtocolState::CONFIGURED || ip6 == NetworkManager::ProtocolState::CONFIGURED) {
return true;
}
} else {
if (ip4 != NetworkManager::ProtocolState::UNCONFIGURED || ip6 != NetworkManager::ProtocolState::UNCONFIGURED) {
return true;
}
}
} else {
if (ip4 != NetworkManager::ProtocolState::UNCONFIGURED || ip6 != NetworkManager::ProtocolState::UNCONFIGURED) {
return true;
if ((network_ready_type)type == NETWORK_READY_TYPE_IPV4) {
return ip4 == NetworkManager::ProtocolState::CONFIGURED;
} else if ((network_ready_type)type == NETWORK_READY_TYPE_IPV6) {
return ip6 == NetworkManager::ProtocolState::CONFIGURED;
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion system/src/system_power.cpp
Expand Up @@ -16,10 +16,13 @@ BatteryChargeDiagnosticData::BatteryChargeDiagnosticData(uint16_t id, const char
}

int BatteryChargeDiagnosticData::get(IntType& val) {
if (g_batteryState == BATTERY_STATE_DISCONNECTED) {
// Do not report battery SoC in disconnected and unknown states
if (g_batteryState == BATTERY_STATE_DISCONNECTED || g_batteryState == BATTERY_STATE_UNKNOWN) {
return SYSTEM_ERROR_INVALID_STATE;
}
FuelGauge fuel(true);
// Call begin here just in case to initialize I2C if needed
fuel.begin();
float soc = fuel.getNormalizedSoC();
val = particle::FixedPointUQ<8, 8>(soc);
return SYSTEM_ERROR_NONE;
Expand Down
2 changes: 1 addition & 1 deletion system/src/system_power_manager.cpp
Expand Up @@ -56,7 +56,7 @@ void PowerManager::init() {
#if defined(DEBUG_BUILD)
4 * 1024);
#else
512);
1024);
#endif // defined(DEBUIG_BUILD)
SPARK_ASSERT(thread_ != nullptr);
}
Expand Down

0 comments on commit e8aad04

Please sign in to comment.