Skip to content

Commit f9d15fa

Browse files
committed
Network: Move code
1 parent 7dd8628 commit f9d15fa

File tree

1 file changed

+70
-70
lines changed

1 file changed

+70
-70
lines changed

Firmware/RTK_Everywhere/Network.ino

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -586,30 +586,6 @@ const char *networkGetNameByPriority(NetPriority_t priority)
586586
return "None";
587587
}
588588

589-
//----------------------------------------
590-
// Determine if the network interface is online
591-
//----------------------------------------
592-
bool networkInterfaceHasInternet(NetIndex_t index)
593-
{
594-
// Validate the index
595-
networkValidateIndex(index);
596-
597-
// Return the network interface state
598-
return (networkHasInternet_bm & (1 << index)) ? true : false;
599-
}
600-
601-
//----------------------------------------
602-
// Determine if the network interface has completed its start routine
603-
//----------------------------------------
604-
bool networkIsInterfaceStarted(NetIndex_t index)
605-
{
606-
// Validate the index
607-
networkValidateIndex(index);
608-
609-
// Return the network started state
610-
return (networkStarted & (1 << index)) ? true : false;
611-
}
612-
613589
//----------------------------------------
614590
// Determine if any network interface is online
615591
//----------------------------------------
@@ -620,23 +596,23 @@ bool networkHasInternet()
620596
}
621597

622598
//----------------------------------------
623-
// Determine if the network is present on the platform
599+
// Interface stop event
624600
//----------------------------------------
625-
bool networkIsPresent(NetIndex_t index)
601+
void networkInterfaceEventStop(NetIndex_t index)
626602
{
627-
// Validate the index
628-
networkValidateIndex(index);
629-
630-
// Present if nullptr or bool set to true
631-
return ((!networkInterfaceTable[index].present) || *(networkInterfaceTable[index].present));
603+
networkEventStop[index] = true;
632604
}
633605

634606
//----------------------------------------
635-
// Interface stop event
607+
// Determine if the network interface is online
636608
//----------------------------------------
637-
void networkInterfaceEventStop(NetIndex_t index)
609+
bool networkInterfaceHasInternet(NetIndex_t index)
638610
{
639-
networkEventStop[index] = true;
611+
// Validate the index
612+
networkValidateIndex(index);
613+
614+
// Return the network interface state
615+
return (networkHasInternet_bm & (1 << index)) ? true : false;
640616
}
641617

642618
//----------------------------------------
@@ -780,6 +756,30 @@ void networkInterfaceEventInternetAvailable(NetIndex_t index)
780756
networkMulticastDNSStart(previousIndex);
781757
}
782758

759+
//----------------------------------------
760+
// Determine if the network interface has completed its start routine
761+
//----------------------------------------
762+
bool networkIsInterfaceStarted(NetIndex_t index)
763+
{
764+
// Validate the index
765+
networkValidateIndex(index);
766+
767+
// Return the network started state
768+
return (networkStarted & (1 << index)) ? true : false;
769+
}
770+
771+
//----------------------------------------
772+
// Determine if the network is present on the platform
773+
//----------------------------------------
774+
bool networkIsPresent(NetIndex_t index)
775+
{
776+
// Validate the index
777+
networkValidateIndex(index);
778+
779+
// Present if nullptr or bool set to true
780+
return ((!networkInterfaceTable[index].present) || *(networkInterfaceTable[index].present));
781+
}
782+
783783
//----------------------------------------
784784
// Change multicast DNS to a given network
785785
//----------------------------------------
@@ -1326,42 +1326,6 @@ void networkStartDelayed(NetIndex_t index, uintptr_t parameter, bool debug)
13261326
}
13271327
}
13281328

1329-
//----------------------------------------
1330-
// Validate the network index
1331-
//----------------------------------------
1332-
void networkValidateIndex(NetIndex_t index)
1333-
{
1334-
// Validate the index
1335-
if (index >= NETWORK_OFFLINE)
1336-
{
1337-
systemPrintf("HALTED: Invalid index value %d, valid range (0 - %d)!\r\n", index, NETWORK_OFFLINE - 1);
1338-
reportFatalError("Invalid index value!");
1339-
}
1340-
}
1341-
1342-
//----------------------------------------
1343-
// Validate the network priority
1344-
//----------------------------------------
1345-
void networkValidatePriority(NetPriority_t priority)
1346-
{
1347-
// Validate the priority
1348-
if (priority >= NETWORK_OFFLINE)
1349-
{
1350-
systemPrintf("HALTED: Invalid priority value %d, valid range (0 - %d)!\r\n", priority, NETWORK_OFFLINE - 1);
1351-
reportFatalError("Invalid priority value!");
1352-
}
1353-
}
1354-
1355-
//----------------------------------------
1356-
// Verify the network layer tables
1357-
//----------------------------------------
1358-
void networkVerifyTables()
1359-
{
1360-
// Verify the table lengths
1361-
if (NETWORK_OFFLINE != NETWORK_MAX)
1362-
reportFatalError("Fix networkInterfaceTable to match NetworkType");
1363-
}
1364-
13651329
//----------------------------------------
13661330
// Maintain the network connections
13671331
//----------------------------------------
@@ -1570,6 +1534,42 @@ void networkUpdate()
15701534
}
15711535
}
15721536

1537+
//----------------------------------------
1538+
// Validate the network index
1539+
//----------------------------------------
1540+
void networkValidateIndex(NetIndex_t index)
1541+
{
1542+
// Validate the index
1543+
if (index >= NETWORK_OFFLINE)
1544+
{
1545+
systemPrintf("HALTED: Invalid index value %d, valid range (0 - %d)!\r\n", index, NETWORK_OFFLINE - 1);
1546+
reportFatalError("Invalid index value!");
1547+
}
1548+
}
1549+
1550+
//----------------------------------------
1551+
// Validate the network priority
1552+
//----------------------------------------
1553+
void networkValidatePriority(NetPriority_t priority)
1554+
{
1555+
// Validate the priority
1556+
if (priority >= NETWORK_OFFLINE)
1557+
{
1558+
systemPrintf("HALTED: Invalid priority value %d, valid range (0 - %d)!\r\n", priority, NETWORK_OFFLINE - 1);
1559+
reportFatalError("Invalid priority value!");
1560+
}
1561+
}
1562+
1563+
//----------------------------------------
1564+
// Verify the network layer tables
1565+
//----------------------------------------
1566+
void networkVerifyTables()
1567+
{
1568+
// Verify the table lengths
1569+
if (NETWORK_OFFLINE != NETWORK_MAX)
1570+
reportFatalError("Fix networkInterfaceTable to match NetworkType");
1571+
}
1572+
15731573
// Return the bitfield containing the type of consumers currently using the network
15741574
uint16_t networkGetConsumerTypes()
15751575
{

0 commit comments

Comments
 (0)