Skip to content

Commit

Permalink
Simpler refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-brust committed Dec 14, 2023
1 parent 8337d75 commit f346eab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
7 changes: 2 additions & 5 deletions system/src/system_cloud_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,11 @@ int system_cloud_set_inet_family_keepalive(int af, unsigned int value, int flags
return 0;
}

int system_cloud_get_inet_family_keepalive(int af, unsigned int* value, network_handle_t network) {
int system_cloud_get_inet_family_keepalive(int af, unsigned int* value) {
if (!value) {
return SYSTEM_ERROR_INVALID_ARGUMENT;
}

#if HAL_PLATFORM_AUTOMATIC_CONNECTION_MANAGEMENT
*value = (network == NETWORK_INTERFACE_CELLULAR ? HAL_PLATFORM_CELLULAR_CLOUD_KEEPALIVE_INTERVAL : HAL_PLATFORM_DEFAULT_CLOUD_KEEPALIVE_INTERVAL);
#else
switch (af) {
case AF_INET: {
*value = s_ipv4_cloud_keepalive;
Expand All @@ -355,6 +352,6 @@ int system_cloud_get_inet_family_keepalive(int af, unsigned int* value, network_
return SYSTEM_ERROR_INVALID_ARGUMENT;
}
}
#endif

return 0;
}
3 changes: 1 addition & 2 deletions system/src/system_cloud_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "ota_flash_hal.h"
#include "socket_hal.h"
#include <type_traits>
#include "system_network.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -42,7 +41,7 @@ int system_cloud_is_connected(void* reserved);
int system_internet_test(void* reserved);
int system_multicast_announce_presence(void* reserved);
int system_cloud_set_inet_family_keepalive(int af, unsigned int value, int flags);
int system_cloud_get_inet_family_keepalive(int af, unsigned int* value, network_handle_t network);
int system_cloud_get_inet_family_keepalive(int af, unsigned int* value);
sock_handle_t system_cloud_get_socket_handle();

#ifdef __cplusplus
Expand Down
6 changes: 5 additions & 1 deletion system/src/system_cloud_connection_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ int system_cloud_connect(int protocol, const ServerAddress* address, sockaddr* s
}

unsigned int keepalive = 0;
system_cloud_get_inet_family_keepalive(a->ai_family, &keepalive, cloudInterface);
#if HAL_PLATFORM_AUTOMATIC_CONNECTION_MANAGEMENT
keepalive = (cloudInterface == NETWORK_INTERFACE_CELLULAR ? HAL_PLATFORM_CELLULAR_CLOUD_KEEPALIVE_INTERVAL : HAL_PLATFORM_DEFAULT_CLOUD_KEEPALIVE_INTERVAL);
#else
system_cloud_get_inet_family_keepalive(a->ai_family, &keepalive);
#endif
system_cloud_set_inet_family_keepalive(a->ai_family, keepalive, 1);

#if HAL_PLATFORM_SOCKET_IOCTL_NOTIFY
Expand Down

0 comments on commit f346eab

Please sign in to comment.