more refactoring

This commit is contained in:
Robin Müller 2021-07-16 13:39:50 +02:00
parent d5a342a509
commit 253780d5d4
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 18 additions and 12 deletions

View File

@ -1,7 +1,7 @@
# These are part of the RTEMS BSP for RTEMS # These are part of the RTEMS BSP for RTEMS
if(FSFW_OSAL MATCHES freertos) if(FSFW_OSAL MATCHES freertos)
target_sources(${TARGET_NAME} PRIVATE target_sources(${TARGET_NAME} PRIVATE
app_ethernet.c app_ethernet.cpp
ethernetif.c ethernetif.c
) )
endif() endif()
@ -11,4 +11,5 @@ target_sources(${TARGET_NAME} PRIVATE
TmTcLwIpUdpBridge.cpp TmTcLwIpUdpBridge.cpp
networking.cpp networking.cpp
app_dhcp.cpp app_dhcp.cpp
) )

View File

@ -44,7 +44,7 @@ ReturnValue_t UdpTcLwIpPollingTask::performOperation(uint8_t operationCode) {
sys_check_timeouts(); sys_check_timeouts();
#if LWIP_NETIF_LINK_CALLBACK == 1 #if LWIP_NETIF_LINK_CALLBACK == 1
ethernet_link_periodic_handle(gnetif); networking::ethernetLinkPeriodicHandle(gnetif);
#endif #endif
if(udpBridge != nullptr) { if(udpBridge != nullptr) {

View File

@ -2,6 +2,7 @@
#include "app_ethernet.h" #include "app_ethernet.h"
#include "ethernetif.h" #include "ethernetif.h"
#include "udp_config.h" #include "udp_config.h"
#include "networking.h"
#if LWIP_DHCP #if LWIP_DHCP
#include "app_dhcp.h" #include "app_dhcp.h"
@ -28,16 +29,16 @@ void handle_status_change(struct netif* netif, bool link_up);
* @param netif: the network interface * @param netif: the network interface
* @retval None * @retval None
*/ */
void ethernet_link_status_updated(struct netif *netif) void networking::ethernetLinkStatusUpdated(struct netif *netif)
{ {
if (netif_is_link_up(netif)) if (netif_is_link_up(netif))
{ {
set_eth_cable_connected(true); networking::setEthCableConnected(true);
handle_status_change(netif, true); handle_status_change(netif, true);
} }
else else
{ {
set_eth_cable_connected(false); networking::setEthCableConnected(false);
handle_status_change(netif, false); handle_status_change(netif, false);
} }
} }
@ -79,7 +80,7 @@ void handle_status_change(struct netif* netif, bool link_up) {
* @param netif * @param netif
* @retval None * @retval None
*/ */
void ethernet_link_periodic_handle(struct netif *netif) void networking::ethernetLinkPeriodicHandle(struct netif *netif)
{ {
/* Ethernet Link every 100ms */ /* Ethernet Link every 100ms */
if (HAL_GetTick() - ethernetLinkTimer >= 100) if (HAL_GetTick() - ethernetLinkTimer >= 100)

View File

@ -44,8 +44,8 @@
*/ */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __APP_ETHERNET_H #ifndef EXAMPLE_COMMON_APP_ETHERNET_H
#define __APP_ETHERNET_H #define EXAMPLE_COMMON_APP_ETHERNET_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -53,21 +53,25 @@
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include <lwip/netif.h> #include <lwip/netif.h>
#include <stdbool.h>
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void ethernet_link_status_updated(struct netif *netif); namespace networking {
void ethernet_link_periodic_handle(struct netif *netif);
void ethernetLinkStatusUpdated(struct netif *netif);
void ethernetLinkPeriodicHandle(struct netif *netif);
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __APP_ETHERNET_H */ #endif /* EXAMPLE_COMMON_APP_ETHERNET_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/