+TCP pfGetPhyLinkStatus

Some questions in regards to tcp multi.

  1. Is there any usage of pfGetPhyLinkStatus anywhere? It doesn’t appear to be used in code
  2. Is there a proper way to check link status from the application? (vApplicationIPNetworkEventHook_Multi does not report link status rather network status)

Hi @friesen , thanks for your question.

In my applications, I sometimes call pfGetPhyLinkStatus() to show the status on a LED or in a UI.

Unfortunately, the Link Status have an application hook like `vApplicationIPNetworkEventHook_Multi()`.

In the network-interfaces that I wrote, the network status will follow the link status after a delay, see [xPhyCheckLinkStatus()](FreeRTOS-Plus-TCP/source/portable/NetworkInterface/Common/phyHandling.c at 71195119cbcd6f0368a9e4d0a50b43a2b45cfea3 · FreeRTOS/FreeRTOS-Plus-TCP · GitHub)

Note that pfGetPhyLinkStatus() returns the current link-status, whereas the internal xPhyCheckLinkStatus() returns a "debounced" value.

Some questions in regards to tcp multi

I hope that the older “single” version of FreeRTOS+TCP, and the ipconfigIPv4_BACKWARD_COMPATIBLEmode will soon be abandoned.

But is there a suggestion that you want to do?

I don’t know if I have a suggestion, but it seems funny to have pfGetPhyLinkStatus() in the api, but it never actually is used by the ip stack. It also seems a bit of an unknown to be calling this from user API, is it a thread safe call necessarily?

In my particular scenario, I have wifi and ethernet option, they connect to the same network, so I really just want wifi to turn off if ethernet is available. By the time the ethernet stack is up, the wifi was already connected, so In my case I really just want wifi to turn off when a cable is plugged in.

Here is what I’ve done, I don’t know if it is thread ready, as bInterfaceUp isn’t volatile.

      case BUSEV_100_MS_TICK:
        ret = xInterfaceETH.bits.bInterfaceUp;
        if (ret != isEthernetUp) {
          isEthernetUp = ret;
          if (isEthernetUp) {
            activeEndpoint = &xEndPointETH;
            MULTI_TRACE(("ETH UP\n"));
          } else {
            activeEndpoint = &xEndPointWLAN;
            MULTI_TRACE(("ETH DN\n"));
          }
          event_value_t* out = eventAlloc(
              sizeof(event_value_t), BUSEV_ETHLINK_STATUS, BUS_PUBLISHER_NET);
          out->value = ret;
          publishEvent((event_t*)out, false);
          vARPAgeCache();
        }
        break