need to refactor networking code
This commit is contained in:
@ -3,16 +3,20 @@
|
||||
#include "app_ethernet.h"
|
||||
#include "ethernetif.h"
|
||||
#include "app_dhcp.h"
|
||||
#include "networking.h"
|
||||
#include <hardware_init.h>
|
||||
|
||||
#include "fsfw/ipc/MutexGuard.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
|
||||
|
||||
|
||||
#include "lwip/timeouts.h"
|
||||
|
||||
UdpTcLwIpPollingTask::UdpTcLwIpPollingTask(object_id_t objectId, object_id_t bridgeId):
|
||||
SystemObject(objectId), periodicHandleCounter(0), bridgeId(bridgeId) {
|
||||
UdpTcLwIpPollingTask::UdpTcLwIpPollingTask(object_id_t objectId, object_id_t bridgeId,
|
||||
struct netif* gnetif):
|
||||
SystemObject(objectId), periodicHandleCounter(0), bridgeId(bridgeId), gnetif(gnetif) {
|
||||
}
|
||||
|
||||
UdpTcLwIpPollingTask::~UdpTcLwIpPollingTask() {
|
||||
@ -23,8 +27,8 @@ ReturnValue_t UdpTcLwIpPollingTask::initialize() {
|
||||
if(udpBridge == nullptr) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
if (netif_is_link_up(&gnetif)) {
|
||||
set_eth_cable_connected(true);
|
||||
if (netif_is_link_up(gnetif)) {
|
||||
networking::setEthCableConnected(true);
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
@ -34,28 +38,28 @@ ReturnValue_t UdpTcLwIpPollingTask::initialize() {
|
||||
ReturnValue_t UdpTcLwIpPollingTask::performOperation(uint8_t operationCode) {
|
||||
/* Read a received packet from the Ethernet buffers and send it
|
||||
to the lwIP for handling */
|
||||
ethernetif_input(&gnetif);
|
||||
ethernetif_input(gnetif);
|
||||
|
||||
/* Handle timeouts */
|
||||
sys_check_timeouts();
|
||||
|
||||
#if LWIP_NETIF_LINK_CALLBACK == 1
|
||||
ethernet_link_periodic_handle(&gnetif);
|
||||
ethernet_link_periodic_handle(gnetif);
|
||||
#endif
|
||||
|
||||
if(udpBridge != nullptr) {
|
||||
MutexGuard lg(udpBridge->bridgeLock);
|
||||
/* In case ethernet cable is disconnected */
|
||||
if(not get_eth_cable_connected() and udpBridge->comLinkUp()) {
|
||||
if(not networking::getEthCableConnected() and udpBridge->comLinkUp()) {
|
||||
udpBridge->physicalConnectStatusChange(false);
|
||||
}
|
||||
else if(get_eth_cable_connected() and not udpBridge->comLinkUp()) {
|
||||
else if(networking::getEthCableConnected() and not udpBridge->comLinkUp()) {
|
||||
udpBridge->physicalConnectStatusChange(true);
|
||||
}
|
||||
}
|
||||
|
||||
#if LWIP_DHCP == 1
|
||||
DHCP_Periodic_Handle(&gnetif);
|
||||
DHCP_Periodic_Handle(gnetif);
|
||||
#endif
|
||||
|
||||
return RETURN_OK;
|
||||
|
Reference in New Issue
Block a user