• AVR Freaks

Hot!TCP/IP Announce Issue

Author
RowanT
Starting Member
  • Total Posts : 86
  • Reward points : 0
  • Joined: 2007/07/29 16:07:34
  • Location: Melbourne, Australia
  • Status: offline
2018/03/01 18:22:54 (permalink)
0

TCP/IP Announce Issue

Hi, 
 
I seem to be having issues with the Announce feature of Harmony. I'm using 2.04, but I just checked and the tcpip_accounce.c file is the same as in version 2.05.01. What's happening is that the first announce sent (triggered by DHCP lease) is sent to the correct destination port (30303), but any after that (triggered by calling TCPIP_ANNOUNCE_MessageRequest()) are sent to destination port 0.
 
I have the default options in Harmony config, except "Network Direct Broadcast" is set. I have tried it off as well, but I at least get the first packet with this option set. I don't see anything otherwise.

It also doesn't appear to be receiving anything, I've put breakpoints after 
 
if ( !TCPIP_UDP_GetIsReady( s ) ) {
            return;

But they never get there, using the latest Discovery tool (v2.6) to send Discover Devices. I can see the Discovery tool sending out "Discovery: Who is out there?" but nothing is received. Using a UDP tool on my phone I can see the Discovery tool packet being broadcast on the network, so it is definitely going out.
 
Wireshark capture of initial packet and packets thereafter show destination port 0.
 

post edited by RowanT - 2018/03/01 18:37:41
#1

13 Replies Related Threads

    RowanT
    Starting Member
    • Total Posts : 86
    • Reward points : 0
    • Joined: 2007/07/29 16:07:34
    • Location: Melbourne, Australia
    • Status: offline
    Re: TCP/IP Announce Issue 2018/03/01 18:47:32 (permalink)
    0
    I seem to have been able to fix both issues by adding the following in tcpip_annouce.c:
    TCPIP_UDP_RemoteBind( annSkt, IP_ADDRESS_TYPE_IPV4, TCPIP_ANNOUNCE_PORT, 0 );
     
    On line 513, just before TCPIP_UDP_ArrayPut( annSkt, outData, annDcpt.msgLen );
     

     
     
     
    TCPIP_UDP_SocketNetSet( annSkt, pNetIf );
    ifAdd.Val = _TCPIPStackNetAddress( pNetIf );
    TCPIP_UDP_SourceIPAddressSet( annSkt, IP_ADDRESS_TYPE_IPV4, ( IP_MULTI_ADDRESS* ) & ifAdd );
    TCPIP_UDP_RemoteBind( annSkt, IP_ADDRESS_TYPE_IPV4, TCPIP_ANNOUNCE_PORT, 0 ); // ADDED CODE
    TCPIP_UDP_ArrayPut( annSkt, outData, annDcpt.msgLen );
     
     
     

     
    It now also receives packets properly and replies, BUT only after I force an announce message to go out by calling TCPIP_ANNOUNCE_MessageRequest().
     
    So, somehow the remote binding is lost? Why does this also effect reception on port 30303?
    post edited by RowanT - 2018/03/01 18:55:37
    #2
    RowanT
    Starting Member
    • Total Posts : 86
    • Reward points : 0
    • Joined: 2007/07/29 16:07:34
    • Location: Melbourne, Australia
    • Status: offline
    Re: TCP/IP Announce Issue 2018/03/01 19:03:16 (permalink)
    0
    Ok, final update. All seems to be working now, I had to add functions to rebind both remote and the server bind.
     
    I'm now doing this at the end of the TCPIP_ANNOUNCE_SendIf function, on like ~521:
     
    TCPIP_UDP_RemoteBind( annSkt, IP_ADDRESS_TYPE_IPV4, TCPIP_ANNOUNCE_PORT, 0 );
    TCPIP_UDP_Bind( annSkt, IP_ADDRESS_TYPE_IPV4, TCPIP_ANNOUNCE_PORT, 0 );

     
    I would still love to know why this is happening and why there's noone else mentioning it. Am I doing something to cause this issue? I don't specifically use UDP in any custom functions outside of what Harmony uses it for.
    post edited by RowanT - 2018/03/01 19:04:26
    #3
    rainad
    Moderator
    • Total Posts : 1142
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP Announce Issue 2018/03/02 09:14:40 (permalink)
    0
    Hi RowanT,
     
    Another round of Bind/RemoteBind shouldn't be needed since this is the way the socket was opened, and I don't see any operation that changes/affects the destination port.
    But I'll have to make some tests to understand what's going on and see if I can replicate the behavior that you see.
    Thank you for reporting this, I'll look into it and let you know.
     
     
    #4
    rainad
    Moderator
    • Total Posts : 1142
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP Announce Issue 2018/03/05 17:28:37 (permalink)
    0
    I've created a simple command that calls the TCPIP_ANNOUNCE_MessageRequest() from the console.
    I've used it repeatedly with both limited and network directed broadcasts.
    I always see the messages going out on port 30303, as they should.
    Running the discoverer jar on the PC side is working for me as well and the board responds properly.
     
    Do you have a special setup, any idea what might be different that could trigger the issue?
     
     
    #5
    Luca Pascarella
    Starting Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2007/05/28 00:53:17
    • Location: The Netherlands
    • Status: offline
    Re: TCP/IP Announce Issue 2019/02/06 04:23:45 (permalink)
    0
    I have a similar problem with the announce module that changes the remotePort from 30303 to 0 after a network change.
     
    I am using Harmony 2.06 with a WINC1500 configurated in Ethernet Mode. I followed the wifi_easy_configuration example to start my board in AP mode and then switch to the infrastructure mode connecting to my router. Everything works properly, I am able to connect the web server and ping the board except for the announce module that stops after changing AP.
     
    With a serial console, I discovered that when the board boots, the UDP ports for the announce module are correct both set to 30303.
    >udpinfo
    UDP sockets: 10
            sktIx: 0, addType: 1, remotePort: 67, localPort: 68, rxQueueSize: 0, txSize: 0
            sktIx: 1, addType: 1, remotePort: 30303, localPort: 30303, rxQueueSize: 0, txSize: 0
            sktIx: 2, addType: 1, remotePort: 137, localPort: 137, rxQueueSize: 0, txSize: 0
            sktIx: 3, addType: 1, remotePort: 123, localPort: 62509, rxQueueSize: 0, txSize: 0
            sktIx: 4, addType: 1, remotePort: 53, localPort: 52431, rxQueueSize: 0, txSize: 512
    >

     
    But, when the board changes from AP to Infrastructure the remotePort becomes 0.
     
    >udpinfo
    UDP sockets: 10
            sktIx: 0, addType: 1, remotePort: 67, localPort: 68, rxQueueSize: 0, txSize: 512
            sktIx: 1, addType: 1, remotePort: 0, localPort: 30303, rxQueueSize: 0, txSize: 512
            sktIx: 2, addType: 1, remotePort: 137, localPort: 137, rxQueueSize: 0, txSize: 0
            sktIx: 3, addType: 1, remotePort: 123, localPort: 62509, rxQueueSize: 0, txSize: 512
            sktIx: 4, addType: 1, remotePort: 53, localPort: 52431, rxQueueSize: 0, txSize: 512
    >

     
    Should I reboot the announce module in some ways?
     Luca
    #6
    rainad
    Moderator
    • Total Posts : 1142
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP Announce Issue 2019/02/07 07:41:16 (permalink)
    0
    Can you please check if you have the TCPIP_STACK_INTERFACE_CHANGE_SIGNALING set to true in your system_config.h?
    In case that's set, please turn it off and try it like that.
    Maybe the Wi-Fi interface signals disconnection and then the socket is disconnected.
     
    #7
    Luca Pascarella
    Starting Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2007/05/28 00:53:17
    • Location: The Netherlands
    • Status: offline
    Re: TCP/IP Announce Issue 2019/02/07 08:33:31 (permalink)
    0
    The TCPIP_STACK_INTERFACE_CHANGE_SIGNALING flag was already false in my code.
    I changed in true, and I obtained the same behaviour. I just tried another network and gain the same problem.
    Perhaps it is not my APs problem.
     
    BTW, at startup when the board is configured as AP if I connect with my laptop the announce works, same if the board starts in Infrastructure mode without switching from AP mode.
    #8
    rainad
    Moderator
    • Total Posts : 1142
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP Announce Issue 2019/02/07 09:10:53 (permalink)
    0
    Probably just the mode switch creates the problem.
    I'll try to run some tests, see what I get.
     
    #9
    Luca Pascarella
    Starting Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2007/05/28 00:53:17
    • Location: The Netherlands
    • Status: offline
    Re: TCP/IP Announce Issue 2019/02/07 09:22:56 (permalink)
    0
    In case it may be useful, that is my configuration.
     
    /*******************************************************************************
      MPLAB Harmony System Configuration Header

      File Name:
        system_config.h

      Summary:
        Build-time configuration header for the system defined by this MPLAB Harmony
        project.

      Description:
        An MPLAB Project may have multiple configurations. This file defines the
        build-time options for a single configuration.

      Remarks:
        This configuration header must not define any prototypes or data
        definitions (or include any files that do). It only provides macro
        definitions for build-time configuration options that are not instantiated
        until used by another MPLAB Harmony module or application.

        Created with MPLAB Harmony Version 2.06
    *******************************************************************************/

    // DOM-IGNORE-BEGIN
    /*******************************************************************************
    Copyright (c) 2013-2015 released Microchip Technology Inc. All rights reserved.

    Microchip licenses to you the right to use, modify, copy and distribute
    Software only when embedded on a Microchip microcontroller or digital signal
    controller that is integrated into your product or third party product
    (pursuant to the sublicense terms in the accompanying license agreement).

    You should refer to the license agreement accompanying this Software for
    additional information regarding your rights and obligations.

    SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
    EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
    MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
    IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
    CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
    OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
    INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
    CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
    SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
    (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    *******************************************************************************/
    // DOM-IGNORE-END

    #ifndef _SYSTEM_CONFIG_H
    #define _SYSTEM_CONFIG_H

    // *****************************************************************************
    // *****************************************************************************
    // Section: Included Files
    // *****************************************************************************
    // *****************************************************************************
    /* This section Includes other configuration headers necessary to completely
        define this configuration.
    */

    /*** SQI Driver Configuration ***/

    #define DRV_SQI_INSTANCES_NUMBER 1
    #define DRV_SQI_CLIENTS_NUMBER 1
    #define DRV_SQI_BUFFER_OBJECT_NUMBER 10
    #define DRV_SQI_DMA_BUFFER_DESC_NUMBER 4

    #define DRV_SQI_INTERRUPT_MODE true
    #define DRV_SQI_INTERRUPT_SOURCE INT_SOURCE_SQI1

    /*** SST26 Driver Configuration ***/
    #define DRV_SST26_INSTANCES_NUMBER 1
    #define DRV_SST26_CLIENTS_NUMBER 1
    #define DRV_SST26_BUFFER_OBJECT_NUMBER 10
    #define DRV_SST26_SYS_FS_REGISTER



    // DOM-IGNORE-BEGIN
    #ifdef __cplusplus // Provide C++ Compatibility

    extern "C" {

    #endif
    // DOM-IGNORE-END

    // *****************************************************************************
    // *****************************************************************************
    // Section: System Service Configuration
    // *****************************************************************************
    // *****************************************************************************

    // *****************************************************************************
    /* Clock System Service Configuration Options
    */
    #define SYS_CLK_FREQ 200000000ul
    #define SYS_CLK_BUS_PERIPHERAL_1 100000000ul
    #define SYS_CLK_BUS_PERIPHERAL_2 100000000ul
    #define SYS_CLK_BUS_PERIPHERAL_3 100000000ul
    #define SYS_CLK_BUS_PERIPHERAL_4 100000000ul
    #define SYS_CLK_BUS_PERIPHERAL_5 100000000ul
    #define SYS_CLK_BUS_PERIPHERAL_7 200000000ul
    #define SYS_CLK_BUS_PERIPHERAL_8 200000000ul
    #define SYS_CLK_BUS_REFERENCE_2 200000000ul
    #define SYS_CLK_CONFIG_PRIMARY_XTAL 24000000ul
    #define SYS_CLK_CONFIG_SECONDARY_XTAL 32768ul
       
    /*** Ports System Service Configuration ***/
    #define SYS_PORT_A_ANSEL 0x3900
    #define SYS_PORT_A_TRIS 0xF9DF
    #define SYS_PORT_A_LAT 0x0000
    #define SYS_PORT_A_ODC 0x0000
    #define SYS_PORT_A_CNPU 0x0001
    #define SYS_PORT_A_CNPD 0x0000
    #define SYS_PORT_A_CNEN 0x0000

    #define SYS_PORT_B_ANSEL 0x0101
    #define SYS_PORT_B_TRIS 0xFF7F
    #define SYS_PORT_B_LAT 0x0000
    #define SYS_PORT_B_ODC 0x0000
    #define SYS_PORT_B_CNPU 0x0000
    #define SYS_PORT_B_CNPD 0x0000
    #define SYS_PORT_B_CNEN 0x0000

    #define SYS_PORT_C_ANSEL 0xFFE1
    #define SYS_PORT_C_TRIS 0xFFED
    #define SYS_PORT_C_LAT 0x0000
    #define SYS_PORT_C_ODC 0x0000
    #define SYS_PORT_C_CNPU 0x0000
    #define SYS_PORT_C_CNPD 0x0000
    #define SYS_PORT_C_CNEN 0x0000

    #define SYS_PORT_D_ANSEL 0x01C0
    #define SYS_PORT_D_TRIS 0xFBFF
    #define SYS_PORT_D_LAT 0x0000
    #define SYS_PORT_D_ODC 0x0000
    #define SYS_PORT_D_CNPU 0x0000
    #define SYS_PORT_D_CNPD 0x0000
    #define SYS_PORT_D_CNEN 0x0000

    #define SYS_PORT_E_ANSEL 0xFC10
    #define SYS_PORT_E_TRIS 0xFF1F
    #define SYS_PORT_E_LAT 0x0000
    #define SYS_PORT_E_ODC 0x0000
    #define SYS_PORT_E_CNPU 0x0300
    #define SYS_PORT_E_CNPD 0x0000
    #define SYS_PORT_E_CNEN 0x0000

    #define SYS_PORT_F_ANSEL 0xCEC0
    #define SYS_PORT_F_TRIS 0xFEFB
    #define SYS_PORT_F_LAT 0x0000
    #define SYS_PORT_F_ODC 0x0000
    #define SYS_PORT_F_CNPU 0x0000
    #define SYS_PORT_F_CNPD 0x0000
    #define SYS_PORT_F_CNEN 0x0000

    #define SYS_PORT_G_ANSEL 0x0C3C
    #define SYS_PORT_G_TRIS 0x3EFF
    #define SYS_PORT_G_LAT 0x0000
    #define SYS_PORT_G_ODC 0x0000
    #define SYS_PORT_G_CNPU 0x0000
    #define SYS_PORT_G_CNPD 0x0000
    #define SYS_PORT_G_CNEN 0x0000


    /*** Command Processor System Service Configuration ***/
    #define SYS_CMD_ENABLE
    #define SYS_CMD_DEVICE_MAX_INSTANCES SYS_CONSOLE_DEVICE_MAX_INSTANCES
    #define SYS_CMD_PRINT_BUFFER_SIZE 8192
    #define SYS_CMD_BUFFER_DMA_READY __attribute__((coherent)) __attribute__((aligned(16)))
    #define SYS_CMD_REMAP_SYS_CONSOLE_MESSAGE
    #define SYS_CMD_REMAP_SYS_DEBUG_MESSAGE

    /*** Console System Service Configuration ***/

    #define SYS_CONSOLE_OVERRIDE_STDIO
    #define SYS_CONSOLE_DEVICE_MAX_INSTANCES 2
    #define SYS_CONSOLE_INSTANCES_NUMBER 1
    #define SYS_CONSOLE_UART_IDX DRV_USART_INDEX_0
    #define SYS_CONSOLE_UART_BAUD_RATE_IDX DRV_USART_BAUD_RATE_IDX0
    #define SYS_CONSOLE_UART_RD_QUEUE_DEPTH 1
    #define SYS_CONSOLE_UART_WR_QUEUE_DEPTH 64
    #define SYS_CONSOLE_BUFFER_DMA_READY



    /*** Debug System Service Configuration ***/
    #define SYS_DEBUG_ENABLE
    #define DEBUG_PRINT_BUFFER_SIZE 8192
    #define SYS_DEBUG_BUFFER_DMA_READY
    #define SYS_DEBUG_USE_CONSOLE

    /*** File System Service Configuration ***/

    #define SYS_FS_MEDIA_NUMBER 2

    #define SYS_FS_VOLUME_NUMBER (1 + 1)

    #define SYS_FS_AUTOMOUNT_ENABLE true
    #define SYS_FS_CLIENT_NUMBER 2
    #define SYS_FS_MAX_FILES 25
    #define SYS_FS_MAX_FILE_SYSTEM_TYPE 2
    #define SYS_FS_MEDIA_MAX_BLOCK_SIZE 512
    #define SYS_FS_MEDIA_MANAGER_BUFFER_SIZE 2048
    #define SYS_FS_FILE_NAME_LEN 255
    #define SYS_FS_CWD_STRING_LEN 1024


    #define SYS_FS_MEDIA_TYPE_IDX0 SYS_FS_MEDIA_TYPE_SPIFLASH
    #define SYS_FS_TYPE_IDX0 MPFS2







    #define SYS_FS_MEDIA_TYPE_IDX1 SYS_FS_MEDIA_TYPE_MSD
    #define SYS_FS_TYPE_IDX1 FAT








    #define SYS_FS_MEDIA_IDX0_MOUNT_NAME_VOLUME_IDX0 "/mnt/sst"
    #define SYS_FS_MEDIA_IDX0_DEVICE_NAME_VOLUME_IDX0 "/dev/mtda1"

    #define SYS_FS_MEDIA_IDX1_MOUNT_NAME_VOLUME_IDX0 "/mnt/usb"
    #define SYS_FS_MEDIA_IDX1_DEVICE_NAME_VOLUME_IDX0 "/dev/sda1"

    /*** Interrupt System Service Configuration ***/
    #define SYS_INT true
    // *****************************************************************************
    /* Random System Service Configuration Options
    */

    #define SYS_RANDOM_CRYPTO_SEED_SIZE 32

    /*** Timer System Service Configuration ***/
    #define SYS_TMR_POWER_STATE SYS_MODULE_POWER_RUN_FULL
    #define SYS_TMR_DRIVER_INDEX DRV_TMR_INDEX_0
    #define SYS_TMR_MAX_CLIENT_OBJECTS 5
    #define SYS_TMR_FREQUENCY 1000
    #define SYS_TMR_FREQUENCY_TOLERANCE 10
    #define SYS_TMR_UNIT_RESOLUTION 10000
    #define SYS_TMR_CLIENT_TOLERANCE 10
    #define SYS_TMR_INTERRUPT_NOTIFICATION true

    // *****************************************************************************
    // *****************************************************************************
    // Section: Driver Configuration
    // *****************************************************************************
    // *****************************************************************************

    /*** MIIM Driver Configuration ***/
    #define DRV_MIIM_ETH_MODULE_ID ETH_ID_0
    #define DRV_MIIM_INSTANCES_NUMBER 1
    #define DRV_MIIM_INSTANCE_OPERATIONS 4
    #define DRV_MIIM_INSTANCE_CLIENTS 2
    #define DRV_MIIM_CLIENT_OP_PROTECTION false
    #define DRV_MIIM_COMMANDS false
    #define DRV_MIIM_DRIVER_OBJECT DRV_MIIM_OBJECT_BASE_Default
    #define DRV_MIIM_DRIVER_INDEX DRV_MIIM_INDEX_0
    /*** Timer Driver Configuration ***/
    #define DRV_TMR_INTERRUPT_MODE true
    #define DRV_TMR_INSTANCES_NUMBER 1
    #define DRV_TMR_CLIENTS_NUMBER 1

    /*** Timer Driver 0 Configuration ***/
    #define DRV_TMR_PERIPHERAL_ID_IDX0 TMR_ID_1
    #define DRV_TMR_INTERRUPT_SOURCE_IDX0 INT_SOURCE_TIMER_1
    #define DRV_TMR_INTERRUPT_VECTOR_IDX0 INT_VECTOR_T1
    #define DRV_TMR_ISR_VECTOR_IDX0 _TIMER_1_VECTOR
    #define DRV_TMR_INTERRUPT_PRIORITY_IDX0 INT_PRIORITY_LEVEL1
    #define DRV_TMR_INTERRUPT_SUB_PRIORITY_IDX0 INT_SUBPRIORITY_LEVEL0
    #define DRV_TMR_CLOCK_SOURCE_IDX0 DRV_TMR_CLKSOURCE_INTERNAL
    #define DRV_TMR_PRESCALE_IDX0 TMR_PRESCALE_VALUE_256
    #define DRV_TMR_OPERATION_MODE_IDX0 DRV_TMR_OPERATION_MODE_16_BIT
    #define DRV_TMR_ASYNC_WRITE_ENABLE_IDX0 false
    #define DRV_TMR_POWER_STATE_IDX0 SYS_MODULE_POWER_RUN_FULL


     // *****************************************************************************
    /* USART Driver Configuration Options
    */
    #define DRV_USART_INTERRUPT_MODE true

    #define DRV_USART_BYTE_MODEL_SUPPORT false

    #define DRV_USART_READ_WRITE_MODEL_SUPPORT true

    #define DRV_USART_BUFFER_QUEUE_SUPPORT true

    #define DRV_USART_CLIENTS_NUMBER 1
    #define DRV_USART_INSTANCES_NUMBER 1

    #define DRV_USART_PERIPHERAL_ID_IDX0 USART_ID_2
    #define DRV_USART_OPER_MODE_IDX0 DRV_USART_OPERATION_MODE_NORMAL
    #define DRV_USART_OPER_MODE_DATA_IDX0
    #define DRV_USART_INIT_FLAG_WAKE_ON_START_IDX0 false
    #define DRV_USART_INIT_FLAG_AUTO_BAUD_IDX0 false
    #define DRV_USART_INIT_FLAG_STOP_IN_IDLE_IDX0 false
    #define DRV_USART_INIT_FLAGS_IDX0 0
    #define DRV_USART_BRG_CLOCK_IDX0 100000000
    #define DRV_USART_BAUD_RATE_IDX0 115200
    #define DRV_USART_LINE_CNTRL_IDX0 DRV_USART_LINE_CONTROL_8NONE1
    #define DRV_USART_HANDSHAKE_MODE_IDX0 DRV_USART_HANDSHAKE_NONE
    #define DRV_USART_LINES_ENABLE_IDX0 USART_ENABLE_TX_RX_USED
    #define DRV_USART_XMIT_INT_SRC_IDX0 INT_SOURCE_USART_2_TRANSMIT
    #define DRV_USART_RCV_INT_SRC_IDX0 INT_SOURCE_USART_2_RECEIVE
    #define DRV_USART_ERR_INT_SRC_IDX0 INT_SOURCE_USART_2_ERROR
    #define DRV_USART_XMIT_INT_VECTOR_IDX0 INT_VECTOR_UART2_TX
    #define DRV_USART_XMIT_INT_PRIORITY_IDX0 INT_PRIORITY_LEVEL1
    #define DRV_USART_XMIT_INT_SUB_PRIORITY_IDX0 INT_SUBPRIORITY_LEVEL0
    #define DRV_USART_RCV_INT_VECTOR_IDX0 INT_VECTOR_UART2_RX
    #define DRV_USART_RCV_INT_PRIORITY_IDX0 INT_PRIORITY_LEVEL1
    #define DRV_USART_RCV_INT_SUB_PRIORITY_IDX0 INT_SUBPRIORITY_LEVEL0
    #define DRV_USART_ERR_INT_VECTOR_IDX0 INT_VECTOR_UART2_FAULT
    #define DRV_USART_ERR_INT_PRIORITY_IDX0 INT_PRIORITY_LEVEL1
    #define DRV_USART_ERR_INT_SUB_PRIORITY_IDX0 INT_SUBPRIORITY_LEVEL0

    #define DRV_USART_XMIT_QUEUE_SIZE_IDX0 10
    #define DRV_USART_RCV_QUEUE_SIZE_IDX0 10


    #define DRV_USART_POWER_STATE_IDX0 SYS_MODULE_POWER_RUN_FULL

    #define DRV_USART_QUEUE_DEPTH_COMBINED 20

    // *****************************************************************************
    // *****************************************************************************
    // Section: Middleware & Other Library Configuration
    // *****************************************************************************
    // *****************************************************************************
    /*** Crypto Library Configuration ***/

    #define WC_NO_HARDEN
    #define MICROCHIP_MPLAB_HARMONY
    #define HAVE_MCAPI
    #define MICROCHIP_PIC32

    /* MPLAB Harmony Net Presentation Layer Definitions*/
    #define NET_PRES_NUM_INSTANCE 1
    #define NET_PRES_NUM_SOCKETS 10



    // *****************************************************************************
    // *****************************************************************************
    // Section: TCPIP Stack Configuration
    // *****************************************************************************
    // *****************************************************************************
    #define TCPIP_STACK_USE_IPV4
    #define TCPIP_STACK_USE_TCP
    #define TCPIP_STACK_USE_UDP

    #define TCPIP_STACK_TICK_RATE 5
    #define TCPIP_STACK_SECURE_PORT_ENTRIES 10

    #define TCPIP_STACK_ALIAS_INTERFACE_SUPPORT false

    #define TCPIP_PACKET_LOG_ENABLE 0

    /* TCP/IP stack event notification */
    #define TCPIP_STACK_USE_EVENT_NOTIFICATION
    #define TCPIP_STACK_USER_NOTIFICATION false
    #define TCPIP_STACK_DOWN_OPERATION true
    #define TCPIP_STACK_IF_UP_DOWN_OPERATION true
    #define TCPIP_STACK_MAC_DOWN_OPERATION true
    #define TCPIP_STACK_INTERFACE_CHANGE_SIGNALING false
    #define TCPIP_STACK_CONFIGURATION_SAVE_RESTORE true
    /*** TCPIP Heap Configuration ***/

    #define TCPIP_STACK_USE_INTERNAL_HEAP
    #define TCPIP_STACK_DRAM_SIZE 50000
    #define TCPIP_STACK_DRAM_RUN_LIMIT 2048

    #define TCPIP_STACK_MALLOC_FUNC x_malloc

    #define TCPIP_STACK_CALLOC_FUNC x_calloc

    #define TCPIP_STACK_FREE_FUNC x_free



    #define TCPIP_STACK_HEAP_USE_FLAGS TCPIP_STACK_HEAP_FLAG_ALLOC_UNCACHED

    #define TCPIP_STACK_HEAP_USAGE_CONFIG TCPIP_STACK_HEAP_USE_DEFAULT

    #define TCPIP_STACK_SUPPORTED_HEAPS 1

    /*** ARP Configuration ***/
    #define TCPIP_ARP_CACHE_ENTRIES 5
    #define TCPIP_ARP_CACHE_DELETE_OLD true
    #define TCPIP_ARP_CACHE_SOLVED_ENTRY_TMO 1200
    #define TCPIP_ARP_CACHE_PENDING_ENTRY_TMO 60
    #define TCPIP_ARP_CACHE_PENDING_RETRY_TMO 2
    #define TCPIP_ARP_CACHE_PERMANENT_QUOTA 50
    #define TCPIP_ARP_CACHE_PURGE_THRESHOLD 75
    #define TCPIP_ARP_CACHE_PURGE_QUANTA 1
    #define TCPIP_ARP_CACHE_ENTRY_RETRIES 3
    #define TCPIP_ARP_GRATUITOUS_PROBE_COUNT 1
    #define TCPIP_ARP_TASK_PROCESS_RATE 2
    #define TCPIP_ARP_PRIMARY_CACHE_ONLY true

    /*** DHCP Configuration ***/
    #define TCPIP_STACK_USE_DHCP_CLIENT
    #define TCPIP_DHCP_TIMEOUT 2
    #define TCPIP_DHCP_TASK_TICK_RATE 200
    #define TCPIP_DHCP_HOST_NAME_SIZE 20
    #define TCPIP_DHCP_CLIENT_CONNECT_PORT 68
    #define TCPIP_DHCP_SERVER_LISTEN_PORT 67
    #define TCPIP_DHCP_CLIENT_ENABLED true


    /*** DNS Client Configuration ***/
    #define TCPIP_STACK_USE_DNS
    #define TCPIP_DNS_CLIENT_SERVER_TMO 60
    #define TCPIP_DNS_CLIENT_TASK_PROCESS_RATE 200
    #define TCPIP_DNS_CLIENT_CACHE_ENTRIES 5
    #define TCPIP_DNS_CLIENT_CACHE_ENTRY_TMO 0
    #define TCPIP_DNS_CLIENT_CACHE_PER_IPV4_ADDRESS 5
    #define TCPIP_DNS_CLIENT_CACHE_PER_IPV6_ADDRESS 1
    #define TCPIP_DNS_CLIENT_ADDRESS_TYPE IP_ADDRESS_TYPE_IPV4
    #define TCPIP_DNS_CLIENT_CACHE_DEFAULT_TTL_VAL 1200
    #define TCPIP_DNS_CLIENT_CACHE_UNSOLVED_ENTRY_TMO 10
    #define TCPIP_DNS_CLIENT_LOOKUP_RETRY_TMO 5
    #define TCPIP_DNS_CLIENT_MAX_HOSTNAME_LEN 128
    #define TCPIP_DNS_CLIENT_MAX_SELECT_INTERFACES 4
    #define TCPIP_DNS_CLIENT_DELETE_OLD_ENTRIES true
    #define TCPIP_DNS_CLIENT_USER_NOTIFICATION false



    /*** HTTP NET Configuration ***/
    #define TCPIP_STACK_USE_HTTP_NET_SERVER
    #define TCPIP_HTTP_NET_MAX_HEADER_LEN 15
    #define TCPIP_HTTP_NET_CACHE_LEN "600"
    #define TCPIP_HTTP_NET_TIMEOUT 45
    #define TCPIP_HTTP_NET_MAX_CONNECTIONS 4
    #define TCPIP_HTTP_NET_DEFAULT_FILE "index.htm"
    #define TCPIP_HTTP_NET_FILENAME_MAX_LEN 25
    #define TCPIP_HTTP_NET_FILE_UPLOAD_ENABLE
    #define TCPIP_HTTP_NET_FILE_UPLOAD_NAME "mpfsupload"
    #define TCPIP_HTTP_NET_USE_POST
    #define TCPIP_HTTP_NET_USE_COOKIES
    #define TCPIP_HTTP_NET_USE_BASE64_DECODE
    #define TCPIP_HTTP_NET_USE_AUTHENTICATION
    #define TCPIP_HTTP_NET_MAX_DATA_LEN 100
    #define TCPIP_HTTP_NET_SKT_TX_BUFF_SIZE 2048
    #define TCPIP_HTTP_NET_SKT_RX_BUFF_SIZE 2048
    #define TCPIP_HTTP_NET_LISTEN_PORT 80
    #define TCPIP_HTTP_NET_CONFIG_FLAGS \
                                                            TCPIP_HTTP_NET_MODULE_FLAG_SECURE_DEFAULT |\
                                                            TCPIP_HTTP_NET_MODULE_FLAG_DEFAULT
    #define TCPIP_HTTP_NET_TASK_RATE 33
    #define TCPIP_HTTP_NET_RESPONSE_BUFFER_SIZE 300
    #define TCPIP_HTTP_NET_COOKIE_BUFFER_SIZE 200
    #define TCPIP_HTTP_NET_FIND_PEEK_BUFF_SIZE 0
    #define TCPIP_HTTP_NET_FILE_PROCESS_BUFFER_SIZE 512
    #define TCPIP_HTTP_NET_FILE_PROCESS_BUFFERS_NUMBER 4
    #define TCPIP_HTTP_NET_FILE_PROCESS_BUFFER_RETRIES 10
    #define TCPIP_HTTP_NET_CHUNKS_NUMBER 10
    #define TCPIP_HTTP_NET_CHUNK_RETRIES 10
    #define TCPIP_HTTP_NET_MAX_RECURSE_LEVEL 3
    #define TCPIP_HTTP_NET_DYNVAR_PROCESS 1
    #define TCPIP_HTTP_NET_DYNVAR_DESCRIPTORS_NUMBER 10
    #define TCPIP_HTTP_NET_DYNVAR_MAX_LEN 50
    #define TCPIP_HTTP_NET_DYNVAR_ARG_MAX_NUMBER 4
    #define TCPIP_HTTP_NET_DYNVAR_PROCESS_RETRIES 10
    #define TCPIP_HTTP_NET_SSI_PROCESS 0
    #define TCPIP_HTTP_NET_CONNECTION_TIMEOUT 100
    #define TCPIP_HTTP_NET_MALLOC_FUNC 0
    #define TCPIP_HTTP_NET_FREE_FUNC 0

    /*** ICMPv4 Server Configuration ***/
    #define TCPIP_STACK_USE_ICMP_SERVER
    #define TCPIP_ICMP_ECHO_ALLOW_BROADCASTS false

    /*** ICMPv4 Client Configuration ***/
    #define TCPIP_STACK_USE_ICMP_CLIENT
    #define TCPIP_ICMP_CLIENT_USER_NOTIFICATION true
    #define TCPIP_ICMP_ECHO_REQUEST_TIMEOUT 500
    #define TCPIP_ICMP_TASK_TICK_RATE 33


    /*** NBNS Configuration ***/
    #define TCPIP_STACK_USE_NBNS
    #define TCPIP_NBNS_TASK_TICK_RATE 110



    /*** SNTP Configuration ***/
    #define TCPIP_STACK_USE_SNTP_CLIENT
    #define TCPIP_NTP_DEFAULT_IF "PIC32INT"
    #define TCPIP_NTP_VERSION 4
    #define TCPIP_NTP_DEFAULT_CONNECTION_TYPE IP_ADDRESS_TYPE_IPV4
    #define TCPIP_NTP_EPOCH 2208988800ul
    #define TCPIP_NTP_REPLY_TIMEOUT 6
    #define TCPIP_NTP_MAX_STRATUM 15
    #define TCPIP_NTP_TIME_STAMP_TMO 660
    #define TCPIP_NTP_SERVER "pool.ntp.org"
    #define TCPIP_NTP_SERVER_MAX_LENGTH 30
    #define TCPIP_NTP_QUERY_INTERVAL 600
    #define TCPIP_NTP_FAST_QUERY_INTERVAL 14
    #define TCPIP_NTP_TASK_TICK_RATE 1100
    #define TCPIP_NTP_RX_QUEUE_LIMIT 2




    /*** TCP Configuration ***/
    #define TCPIP_TCP_MAX_SEG_SIZE_TX 1460
    #define TCPIP_TCP_SOCKET_DEFAULT_TX_SIZE 512
    #define TCPIP_TCP_SOCKET_DEFAULT_RX_SIZE 512
    #define TCPIP_TCP_DYNAMIC_OPTIONS true
    #define TCPIP_TCP_START_TIMEOUT_VAL 1000
    #define TCPIP_TCP_DELAYED_ACK_TIMEOUT 100
    #define TCPIP_TCP_FIN_WAIT_2_TIMEOUT 5000
    #define TCPIP_TCP_KEEP_ALIVE_TIMEOUT 10000
    #define TCPIP_TCP_CLOSE_WAIT_TIMEOUT 5000
    #define TCPIP_TCP_MAX_RETRIES 5
    #define TCPIP_TCP_MAX_UNACKED_KEEP_ALIVES 6
    #define TCPIP_TCP_MAX_SYN_RETRIES 3
    #define TCPIP_TCP_AUTO_TRANSMIT_TIMEOUT_VAL 40
    #define TCPIP_TCP_WINDOW_UPDATE_TIMEOUT_VAL 200
    #define TCPIP_TCP_MAX_SOCKETS 10
    #define TCPIP_TCP_TASK_TICK_RATE 5
    #define TCPIP_TCP_MSL_TIMEOUT 0
    #define TCPIP_TCP_QUIET_TIME 0
    #define TCPIP_TCP_COMMANDS false

    /*** announce Configuration ***/
    #define TCPIP_STACK_USE_ANNOUNCE
    #define TCPIP_ANNOUNCE_MAX_PAYLOAD 512
    #define TCPIP_ANNOUNCE_TASK_RATE 333
    #define TCPIP_ANNOUNCE_NETWORK_DIRECTED_BCAST false

    /*** TCPIP MAC Configuration ***/
    #define TCPIP_EMAC_TX_DESCRIPTORS 8
    #define TCPIP_EMAC_RX_DESCRIPTORS 6
    #define TCPIP_EMAC_RX_DEDICATED_BUFFERS 4
    #define TCPIP_EMAC_RX_INIT_BUFFERS 0
    #define TCPIP_EMAC_RX_LOW_THRESHOLD 1
    #define TCPIP_EMAC_RX_LOW_FILL 2
    #define TCPIP_EMAC_MAX_FRAME 1536
    #define TCPIP_EMAC_LINK_MTU 1500
    #define TCPIP_EMAC_RX_BUFF_SIZE 1536
    #define TCPIP_EMAC_RX_FRAGMENTS 1

    #define TCPIP_EMAC_RX_FILTERS \
                                                        TCPIP_MAC_RX_FILTER_TYPE_BCAST_ACCEPT |\
                                                        TCPIP_MAC_RX_FILTER_TYPE_MCAST_ACCEPT |\
                                                        TCPIP_MAC_RX_FILTER_TYPE_UCAST_ACCEPT |\
                                                        TCPIP_MAC_RX_FILTER_TYPE_RUNT_REJECT |\
                                                        TCPIP_MAC_RX_FILTER_TYPE_CRC_ERROR_REJECT |\
                                                        0
    #define TCPIP_EMAC_ETH_OPEN_FLAGS \
                                                        TCPIP_ETH_OPEN_AUTO |\
                                                        TCPIP_ETH_OPEN_FDUPLEX |\
                                                        TCPIP_ETH_OPEN_HDUPLEX |\
                                                        TCPIP_ETH_OPEN_100 |\
                                                        TCPIP_ETH_OPEN_10 |\
                                                        TCPIP_ETH_OPEN_MDIX_AUTO |\
                                                        0

    #define TCPIP_EMAC_MODULE_ID ETH_ID_0
    #define TCPIP_EMAC_INTERRUPT_MODE true
    #define DRV_ETHMAC_INSTANCES_NUMBER 1
    #define DRV_ETHMAC_CLIENTS_NUMBER 1
    #define DRV_ETHMAC_INDEX 1
    #define DRV_ETHMAC_PERIPHERAL_ID 1
    #define DRV_ETHMAC_INTERRUPT_VECTOR INT_VECTOR_ETHERNET
    #define DRV_ETHMAC_INTERRUPT_SOURCE INT_SOURCE_ETH_1
    #define DRV_ETHMAC_POWER_STATE SYS_MODULE_POWER_RUN_FULL

    #define DRV_ETHMAC_INTERRUPT_MODE true


    #define TCPIP_EMAC_PHY_CONFIG_FLAGS \
                                                        DRV_ETHPHY_CFG_AUTO | \
                                                        0

    #define TCPIP_EMAC_PHY_LINK_INIT_DELAY 500
    #define TCPIP_EMAC_PHY_ADDRESS 0
    #define DRV_ETHPHY_INSTANCES_NUMBER 1
    #define DRV_ETHPHY_CLIENTS_NUMBER 1
    #define DRV_ETHPHY_INDEX 1
    #define DRV_ETHPHY_PERIPHERAL_ID 1
    #define DRV_ETHPHY_NEG_INIT_TMO 1
    #define DRV_ETHPHY_NEG_DONE_TMO 2000
    #define DRV_ETHPHY_RESET_CLR_TMO 500
    #define DRV_ETHPHY_USE_DRV_MIIM true
    #define TCPIP_EMAC_AUTO_FLOW_CONTROL_ENABLE true
    #define TCPIP_EMAC_FLOW_CONTROL_PAUSE_BYTES 3072
    #define TCPIP_EMAC_FLOW_CONTROL_FULL_WMARK 2
    #define TCPIP_EMAC_FLOW_CONTROL_EMPTY_WMARK 0



    /*** UDP Configuration ***/
    #define TCPIP_UDP_MAX_SOCKETS 10
    #define TCPIP_UDP_SOCKET_DEFAULT_TX_SIZE 512
    #define TCPIP_UDP_SOCKET_DEFAULT_TX_QUEUE_LIMIT 3
    #define TCPIP_UDP_SOCKET_DEFAULT_RX_QUEUE_LIMIT 3
    #define TCPIP_UDP_USE_POOL_BUFFERS false
    #define TCPIP_UDP_USE_TX_CHECKSUM true
    #define TCPIP_UDP_USE_RX_CHECKSUM true
    #define TCPIP_UDP_COMMANDS true

    /*** tcpip_cmd Configuration ***/
    #define TCPIP_STACK_COMMAND_ENABLE
    #define TCPIP_STACK_COMMANDS_STORAGE_ENABLE
    #define TCPIP_STACK_COMMANDS_ICMP_ECHO_REQUESTS 4
    #define TCPIP_STACK_COMMANDS_ICMP_ECHO_REQUEST_DELAY 1000
    #define TCPIP_STACK_COMMANDS_ICMP_ECHO_TIMEOUT 5000
    #define TCPIP_STACK_COMMANDS_WIFI_ENABLE false
    #define TCPIP_STACK_COMMANDS_ICMP_ECHO_REQUEST_BUFF_SIZE 2000
    #define TCPIP_STACK_COMMANDS_ICMP_ECHO_REQUEST_DATA_SIZE 100



    /*** IPv4 Configuration ***/

    /*** Network Configuration Index 0 ***/
    #define TCPIP_NETWORK_DEFAULT_INTERFACE_NAME_IDX0 "PIC32INT"
    #define TCPIP_IF_PIC32INT
    #define TCPIP_NETWORK_DEFAULT_HOST_NAME_IDX0 "MICRO_ETH"
    #define TCPIP_NETWORK_DEFAULT_MAC_ADDR_IDX0 0
    #define TCPIP_NETWORK_DEFAULT_IP_ADDRESS_IDX0 "192.168.1.15"
    #define TCPIP_NETWORK_DEFAULT_IP_MASK_IDX0 "255.255.255.0"
    #define TCPIP_NETWORK_DEFAULT_GATEWAY_IDX0 "192.168.1.1"
    #define TCPIP_NETWORK_DEFAULT_DNS_IDX0 "192.168.1.1"
    #define TCPIP_NETWORK_DEFAULT_SECOND_DNS_IDX0 "8.8.8.8"
    #define TCPIP_NETWORK_DEFAULT_POWER_MODE_IDX0 "full"
    #define TCPIP_NETWORK_DEFAULT_INTERFACE_FLAGS_IDX0 \
                 TCPIP_NETWORK_CONFIG_DHCP_CLIENT_ON |\
                 TCPIP_NETWORK_CONFIG_DNS_CLIENT_ON |\
                 TCPIP_NETWORK_CONFIG_IP_STATIC
    #define TCPIP_NETWORK_DEFAULT_MAC_DRIVER_IDX0 DRV_ETHMAC_PIC32MACObject
    #define TCPIP_NETWORK_DEFAULT_IPV6_ADDRESS_IDX0 0
    #define TCPIP_NETWORK_DEFAULT_IPV6_PREFIX_LENGTH_IDX0 0
    #define TCPIP_NETWORK_DEFAULT_IPV6_GATEWAY_IDX0 0
    /*** TCPIP SYS FS Wrapper ***/
    #define SYS_FS_MAX_PATH 80
    #define LOCAL_WEBSITE_PATH_FS "/mnt/sst"
    #define LOCAL_WEBSITE_PATH "/mnt/sst/"
    #define SYS_FS_DRIVE "FLASH"
    #define SYS_FS_NVM_VOL "/dev/mtda1"
    #define SYS_FS_FATFS_STRING "FATFS"
    #define SYS_FS_MPFS_STRING "MPFS2"

    /*** USB Driver Configuration ***/


    /* Disable Device Support */
    #define DRV_USBHS_DEVICE_SUPPORT false

    /* Enables Host Support */
    #define DRV_USBHS_HOST_SUPPORT true

    /* Maximum USB driver instances */
    #define DRV_USBHS_INSTANCES_NUMBER 1

    /* Interrupt mode enabled */
    #define DRV_USBHS_INTERRUPT_MODE true


    /* Number of Endpoints used */
    #define DRV_USBHS_ENDPOINTS_NUMBER 1







    #define DRV_USBHS_HOST_NAK_LIMIT 2000
    /* Provides Host pipes number */
    #define DRV_USBHS_HOST_PIPES_NUMBER 10
    #define DRV_USBHS_HOST_ATTACH_DEBOUNCE_DURATION 500
    #define DRV_USBHS_HOST_RESET_DURATION 100
    // *****************************************************************************
    // *****************************************************************************
    // Section: USB Device Layer Configuration
    // *****************************************************************************
    // *****************************************************************************
    /* Provides Host pipes number */
    #define USB_HOST_PIPES_NUMBER 10

    // *****************************************************************************
    // *****************************************************************************
    // Section: USB Host Layer Configuration
    // *****************************************************************************
    // **************************************************************************
     
    /* Total number of devices to be supported */
    #define USB_HOST_DEVICES_NUMBER 1

    /* Target peripheral list entries */
    #define USB_HOST_TPL_ENTRIES 1

    /* Maximum number of configurations supported per device */
    #define USB_HOST_DEVICE_INTERFACES_NUMBER 5

    #define USB_HOST_CONTROLLERS_NUMBER 1

    #define USB_HOST_TRANSFERS_NUMBER 10

    /* Number of Host Layer Clients */
    #define USB_HOST_CLIENTS_NUMBER 1

    /* Number of MSD Function driver instances in the application */
    #define USB_HOST_MSD_INSTANCES_NUMBER 1

    /* Number of Logical Units */
    #define USB_HOST_SCSI_INSTANCES_NUMBER 1
    #define USB_HOST_MSD_LUN_NUMBERS 1








    // *****************************************************************************
    // *****************************************************************************
    // Section: Application Configuration
    // *****************************************************************************
    // *****************************************************************************
    /*** Application Defined Pins ***/

    /*** Functions for LED_BLUE_1_ pin ***/
    #define LED_BLUE_1_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_G, PORTS_BIT_POS_15)
    #define LED_BLUE_1_On() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_G, PORTS_BIT_POS_15)
    #define LED_BLUE_1_Off() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_G, PORTS_BIT_POS_15)
    #define LED_BLUE_1_StateGet() (!(PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_G, PORTS_BIT_POS_15)))

    /*** Functions for LED_GREEN_1_ pin ***/
    #define LED_GREEN_1_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_5)
    #define LED_GREEN_1_On() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_5)
    #define LED_GREEN_1_Off() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_5)
    #define LED_GREEN_1_StateGet() (!(PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_5)))

    /*** Functions for LED_RED_1_ pin ***/
    #define LED_RED_1_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_5)
    #define LED_RED_1_On() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_5)
    #define LED_RED_1_Off() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_5)
    #define LED_RED_1_StateGet() (!(PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_5)))

    /*** Functions for LED_BLUE_2_ pin ***/
    #define LED_BLUE_2_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_6)
    #define LED_BLUE_2_On() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_6)
    #define LED_BLUE_2_Off() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_6)
    #define LED_BLUE_2_StateGet() (!(PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_6)))

    /*** Functions for LED_GREEN_2_ pin ***/
    #define LED_GREEN_2_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_7)
    #define LED_GREEN_2_On() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_7)
    #define LED_GREEN_2_Off() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_7)
    #define LED_GREEN_2_StateGet() (!(PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_7)))

    /*** Functions for LED_RED_2_ pin ***/
    #define LED_RED_2_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_C, PORTS_BIT_POS_1)
    #define LED_RED_2_On() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_C, PORTS_BIT_POS_1)
    #define LED_RED_2_Off() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_C, PORTS_BIT_POS_1)
    #define LED_RED_2_StateGet() (!(PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_C, PORTS_BIT_POS_1)))

    #define LEDs_1_Off() do{LED_RED_1_Off(); LED_GREEN_1_Off(); LED_BLUE_1_Off();}while(0);
    #define LEDs_2_Off() do{LED_RED_2_Off(); LED_GREEN_2_Off(); LED_BLUE_2_Off();}while(0);

    /*** Functions for LED_SYS_ pin ***/
    #define LED_SYS_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_D, PORTS_BIT_POS_10)
    #define LED_SYS_On() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_D, PORTS_BIT_POS_10)
    #define LED_SYS_Off() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_D, PORTS_BIT_POS_10)
    #define LED_SYS_StateGet() PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_D, PORTS_BIT_POS_10)

    /*** Functions for SW_3_ pin ***/
    #define SW_3_StateGet() PLIB_PORTS_PinGet(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_0)

    /*** Functions for SW_2_ pin ***/
    #define SW_2_StateGet() PLIB_PORTS_PinGet(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_8)

    /*** Functions for SW_1_ pin ***/
    #define SW_1_StateGet() PLIB_PORTS_PinGet(PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_9)

    /*** Functions for I2C_WP_ pin ***/
    #define I2C_WP_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_C, PORTS_BIT_POS_4)
    #define I2C_WP_On() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_C, PORTS_BIT_POS_4)
    #define I2C_WP_Off() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_C, PORTS_BIT_POS_4)
    #define I2C_WP_StateGet() PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_C, PORTS_BIT_POS_4)
    #define I2C_WP_StateSet(Value) PLIB_PORTS_PinWrite(PORTS_ID_0, PORT_CHANNEL_C, PORTS_BIT_POS_4, Value)

    /*** Functions for VS_RST_ pin ***/
    #define VS_RST_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_B, PORTS_BIT_POS_7)
    #define VS_RST_On() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_B, PORTS_BIT_POS_7)
    #define VS_RST_Off() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_B, PORTS_BIT_POS_7)
    #define VS_RST_StateGet() PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_B, PORTS_BIT_POS_7)
    #define VS_RST_StateSet(Value) PLIB_PORTS_PinWrite(PORTS_ID_0, PORT_CHANNEL_B, PORTS_BIT_POS_7, Value)

    /*** Functions for VS_CS_ pin ***/
    #define VS_CS_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_9)
    #define VS_CS_On() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_9)
    #define VS_CS_Off() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_9)
    #define VS_CS_StateGet() PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_9)
    #define VS_CS_StateSet(Value) PLIB_PORTS_PinWrite(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_9, Value)

    /*** Functions for VS_DCS_ pin ***/
    #define VS_DCS_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_10)
    #define VS_DCS_On() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_10)
    #define VS_DCS_Off() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_10)
    #define VS_DCS_StateGet() PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_10)
    #define VS_DCS_StateSet(Value) PLIB_PORTS_PinWrite(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_10, Value)

    /*** Functions for USB_EN_ pin ***/
    #define USB_EN_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_2)
    #define USB_EN_On() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_2)
    #define USB_EN_Off() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_2)
    #define USB_EN_StateGet() PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_2)
    #define USB_EN_StateSet(Value) PLIB_PORTS_PinWrite(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_2, Value)

    /*** Functions for ETH_RST_ pin ***/
    #define ETH_RST_Toggle() PLIB_PORTS_PinToggle(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_8)
    #define ETH_RST_On() PLIB_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_8)
    #define ETH_RST_Off() PLIB_PORTS_PinClear(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_8)
    #define ETH_RST_StateGet() PLIB_PORTS_PinGetLatched(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_8)
    #define ETH_RST_StateSet(Value) PLIB_PORTS_PinWrite(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_8, Value)

    /*** Functions for VS_DREQ_ pin ***/
    #define VS_DREQ_StateGet() PLIB_PORTS_PinGet(PORTS_ID_0, PORT_CHANNEL_B, PORTS_BIT_POS_6)

    /*** Functions for USB_OC_ pin ***/
    #define USB_OC_StateGet() PLIB_PORTS_PinGet(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_2)


    /*** Application Instance 0 Configuration ***/

    //DOM-IGNORE-BEGIN
    #ifdef __cplusplus
    }
    #endif
    //DOM-IGNORE-END

    #endif // _SYSTEM_CONFIG_H
    /*******************************************************************************
     End of File
    */

     
    And this is how I handle the interfaces at startup. Currently I have two versions of the same board, the first is with a LAN8740 only and the second is with the WINC1500 only.
     
    void APP_NET_Initialize(void) {
        data.state = APP_NET_WAIT_DISK_MOUNT;
        data.error = APP_NET_NO_ERROR;
        data.bits.isWiFiPowerSaveConfigured = false;
        data.bits.interface = false;
        data.bits.internet = false;

        data.ethNetworkHandle = data.wifiNetworkHandle = NULL;
        data.wasNetUp[0] = data.wasNetUp[1] = true;

    #if defined PROJECT_CONFIGURATION_WI_FI
        data.ipWait = data.reconn_retries = 0;
        data.iwpriv_set_param.conn.initConnAllowed = false; // Prevent default startup connections
        iwpriv_set(INITCONN_OPTION_SET, &data.iwpriv_set_param);
        data.iwpriv_set_param.scan.prescanAllowed = true; // Start prescan
        iwpriv_set(PRESCAN_OPTION_SET, &data.iwpriv_set_param);
    #endif
        // Define periodic timeout for Internet check
        data.timeout = 20000 * (SYS_TMR_TickCounterFrequencyGet() / 1000);
        // Assign user's specific functions to HTTP server
        HTTP_APP_Initialize();
    }

    void APP_NET_Tasks(void) {
        SETTINGS_NET_DATA * netData;
        SYS_STATUS tcpipStat;
        int netIndex;
        APP_WIFI_SCAN_RETURN status;

        switch (data.state) {
            case APP_NET_WAIT_DISK_MOUNT:
                if (APP_FS_IsFlashMounted())
                    data.state = APP_NET_WAIT_NET_INIT;
                break;

            case APP_NET_WAIT_NET_INIT:
                if ((tcpipStat = TCPIP_STACK_Status(sysObj.tcpip)) < 0) {
                    SYS_DEBUG_PRINT(SYS_ERROR_INFO, "TCP/IP stack initialization failed. Code: %d\r\n", tcpipStat);
                    data.error = APP_NET_ERROR_NET_INIT;
                    data.state = APP_NET_ERROR;
                } else if (tcpipStat == SYS_STATUS_READY) {
                    // TCP/IP Stack ready, go ahead
                    APP_WIFI_Init();
                    data.startTickCommand = SYS_TMR_TickCountGet();
                    data.state = APP_NET_LOAD_CONFIG;
                }
                break;

            case APP_NET_LOAD_CONFIG:
                netData = Settings_GetNet();
                data.state = APP_NET_CONFIG;
    #if defined(APP_NET_ETH_VERSION)
                if (!APP_NET_LoadEthernetNetworkConfig(netData, &data.ethNetworkConfig)) {
                    data.error = APP_NET_ERROR_LOAD_NET;
                    data.state = APP_NET_ERROR;
                }
    #endif
    #if defined(APP_NET_WIFI_VERSION)
                if (!APP_NET_LoadWiFiNetworkConfig(netData, &data.wifiNetworkConfig)) {
                    data.error = APP_NET_ERROR_LOAD_NET;
                    data.state = APP_NET_ERROR;
                }
    #endif
                // break; no break needed

            case APP_NET_CONFIG:
    #if defined(APP_NET_ETH_VERSION)
                data.ethNetworkHandle = TCPIP_STACK_NetHandleGet(data.ethNetworkConfig.interface);
                netIndex = TCPIP_STACK_NetIndexGet(data.ethNetworkHandle);
                data.defaultIPv4[netIndex].Val = TCPIP_STACK_NetAddress(data.ethNetworkHandle);
                data.ethNetworkConfig.pMacObject = TCPIP_STACK_MACObjectGet(data.ethNetworkHandle);
                TCPIP_STACK_NetDown(data.ethNetworkHandle);
                TCPIP_STACK_NetUp(data.ethNetworkHandle, &data.ethNetworkConfig);
                data.state = APP_NET_MODULES_ENABLE;
    #endif
    #if defined(APP_NET_WIFI_VERSION)
                /* Following "if condition" is useless when demo firstly boots up,
                 * since stack's status has already been checked in APP_NET_WAIT_NET_INIT.
                 * But it is necessary in Wi-Fi interface reset due to connection errors. */
                iwpriv_get(DRVSTATUS_GET, &data.iwpriv_get_param);
                if (data.iwpriv_get_param.driverStatus.isOpen) {
                    data.iwpriv_get_param.devInfo.info = &data.wifi_deviceInfo;
                    iwpriv_get(DEVICEINFO_GET, &data.iwpriv_get_param);
                    // Same as for Ethernet
                    data.wifiNetworkHandle = TCPIP_STACK_NetHandleGet(data.wifiNetworkConfig.interface);
                    netIndex = TCPIP_STACK_NetIndexGet(data.wifiNetworkHandle);
                    data.defaultIPv4[netIndex].Val = TCPIP_STACK_NetAddress(data.wifiNetworkHandle);
                    data.wifiNetworkConfig.pMacObject = TCPIP_STACK_MACObjectGet(data.wifiNetworkHandle);
                    // reset flag used in redirection command
                    data.bits.g_wifi_redirection_signal = false;
                    data.state = APP_NET_PRESCAN;
                } else {
                    data.state = APP_NET_CONFIG;
                }
    #endif
                // For boards with multiple interfaces define unique interface index
                data.interfaceNumber = TCPIP_STACK_NumberOfNetworksGet();
                for (netIndex = 0; netIndex < data.interfaceNumber; netIndex++) {
                    TCPIP_NET_HANDLE netHandle = TCPIP_STACK_IndexToNet(netIndex);
                    if (IS_ETH_INTERFACE(TCPIP_STACK_NetNameGet(netHandle)))
                        data.ethIndex = netIndex;
                    if (IS_WIFI_INTERFACE(TCPIP_STACK_NetNameGet(netHandle)))
                        data.wifiIndex = netIndex;
                }
                break;

            case APP_NET_PRESCAN:
                // If WiFi is present and configurated as AP run a prescan
                if ((status = APP_WIFI_Prescan(data.wifiNetworkHandle, &data.wifiNetworkConfig)) == APP_WIFI_READY) {
                    data.state = APP_NET_MODULES_ENABLE;
                } else if (status == APP_WIFI_ERROR) {
                    data.error = APP_NET_ERROR_PRESCAN;
                    data.state = APP_NET_ERROR;
                }
                break;

            case APP_NET_MODULES_ENABLE:
                // Enable Wi-Fi interfaces
                for (netIndex = 0; netIndex < data.interfaceNumber; ++netIndex)
                    APP_WIFI_IFModules_Enable(TCPIP_STACK_IndexToNet(netIndex));
                timestamp_dhcp_kickin(data.ipWait);
                data.bits.interface = true;
                data.startTick = SYS_TMR_TickCountGet();
                data.state = APP_NET_TRANSACT;
                // break; break is not needed

            case APP_NET_TRANSACT:
    #if defined(APP_NET_WIFI_VERSION)
                if (data.wifi_deviceInfo.deviceType == WINC1500_MODULE) {
                    IWPRIV_GET_PARAM param;
                    iwpriv_get(FWUPGRADEREQUEST_GET, &param);
                    if (param.fwUpgrade.requested) {
                        data.state = APP_NET_FW_OTA_UPDATE;
                        break;
                    }
                }

                // wait for redirection command from custom_http_app.c
                if (data.bits.g_wifi_redirection_signal) {
                    APP_WIFI_IFModules_Disable(data.wifiNetworkHandle);
                    TCPIP_STACK_NetDown(data.wifiNetworkHandle);
                    SYS_CONSOLE_MESSAGE("Connecting to target AP...\r\n");
                    TCPIP_STACK_NetUp(data.wifiNetworkHandle, &data.wifiNetworkConfig);
                    data.bits.isWiFiPowerSaveConfigured = false;
                    data.state = APP_NET_CONFIG;
                    return;
                }

                iwpriv_get(CONNSTATUS_GET, &data.iwpriv_get_param);
                if (data.iwpriv_get_param.conn.status == IWPRIV_CONNECTION_SUCCESSFUL) {
                    // reset reconnection retries
                    data.reconn_retries = 0;
                } else if (data.iwpriv_get_param.conn.status == IWPRIV_CONNECTION_FAILED) {
                    if (data.reconn_retries++ < APP_WIFI_RECONNECTION_RETRY_LIMIT) {
                        SYS_CONSOLE_PRINT("Couldn't connect to target AP, resetting Wi-Fi module and trying to reconnect, retries left: %u\r\n\n", APP_WIFI_RECONNECTION_RETRY_LIMIT - data.reconn_retries);
                        APP_WIFI_IFModules_Disable(data.wifiNetworkHandle);
                        TCPIP_STACK_NetDown(data.wifiNetworkHandle);
                        TCPIP_STACK_NetUp(data.wifiNetworkHandle, &data.wifiNetworkConfig);
                        data.bits.isWiFiPowerSaveConfigured = false;
                        data.state = APP_NET_CONFIG;
                        break;
                    }
                } else if (data.iwpriv_get_param.conn.status == IWPRIV_CONNECTION_REESTABLISHED) {
                    // restart DHCP client and configure Wi-Fi power save
                    TCPIP_DHCP_Disable(data.wifiNetworkHandle);
                    TCPIP_DHCP_Enable(data.wifiNetworkHandle);
                    data.bits.isWiFiPowerSaveConfigured = false;
                    timestamp_dhcp_kickin(data.ipWait);
                }

                if (SYS_TMR_TickCountGet() - data.startTick >= SYS_TMR_TickCounterFrequencyGet() / 2ul) {
                    if (data.ipWait && ++data.ipWait > APP_WIFI_DHCP_WAIT_THRESHOLD) {
                        data.ipWait = 0;
                        if (data.iwpriv_get_param.conn.status != IWPRIV_CONNECTION_SUCCESSFUL)
                            SYS_CONSOLE_MESSAGE("Failed to obtain an IP address from DHCP server\r\nIf security is used, double-check if the key is valid\r\n");
                    }
                    data.startTick = SYS_TMR_TickCountGet();
                }

                // If we get a new IP address that is different than the default one, we will run PowerSave configuration.
                netIndex = TCPIP_STACK_NetIndexGet(data.wifiNetworkHandle);
                if (!data.bits.isWiFiPowerSaveConfigured && TCPIP_STACK_NetIsUp(data.wifiNetworkHandle) && (TCPIP_STACK_NetAddress(data.wifiNetworkHandle) != data.defaultIPv4[netIndex].Val)) {
                    APP_WIFI_PowerSave_Config(true);
                    data.bits.isWiFiPowerSaveConfigured = true;
                }
                APP_WIFI_DHCPS_Sync(data.wifiNetworkHandle);

                if (APP_Commands_PreScanListDisplay_Get())
                    APP_Commands_PreScanListEntry_Display();
    #endif

                // If the IP address of an interface has changed, display the new value on console.
                for (netIndex = 0; netIndex < data.interfaceNumber; ++netIndex) {
                    IPV4_ADDR ipAddr;
                    TCPIP_NET_HANDLE netH = TCPIP_STACK_IndexToNet(netIndex);
                    ipAddr.Val = TCPIP_STACK_NetAddress(netH);
                    if (data.lastIPv4[netIndex].Val != ipAddr.Val) {
                        data.lastIPv4[netIndex].Val = ipAddr.Val;
                        if (ipAddr.Val != 0) {
                            //SYS_CONSOLE_PRINT("%s IPv4 Address: %d.%d.%d.%d\r\n", TCPIP_STACK_NetNameGet(netH), ipAddr.v[0], ipAddr.v[1], ipAddr.v[2], ipAddr.v[3]);
                            APP_NET_PrintNetwork(netH);
                            data.ipWait = 0;
                        }
                    }
                }

                if ((SYS_TMR_TickCountGet() - data.startTickCommand > data.timeout)) {
                    data.startTickCommand = SYS_TMR_TickCountGet();
                    LED_BLUE_1_Toggle();
                    data.bits.scan++;
                    //PING_SendDefaultPing();
    #if defined(APP_NET_WIFI_VERSION)
                    if (data.bits.connectTo == false) {
                        //APP_WIFI_ConnectoTo("Luca", "LucaLucaDelft", WDRV_SECURITY_WPA_AUTO_WITH_PASS_PHRASE, WDRV_NETWORK_TYPE_INFRASTRUCTURE);
                        data.bits.connectTo = true;
                    }
                    if (data.bits.scan == 4)
                        APP_WIFI_ScanNetworks();
                    APP_WIFI_ScanGetResults();
    #endif
                }
                break;


            case APP_NET_ERROR:
                //appNETData.state = APP_NET_WAIT_INIT;
                // TODO. Working here
                break;

            case APP_NET_FW_OTA_UPDATE:
    #if defined PROJECT_CONFIGURATION_WI_FI
                APP_WIFI_IFModules_Disable(data.wifiNetworkHandle);
                TCPIP_STACK_NetDown(data.wifiNetworkHandle);
                TCPIP_STACK_NetUp(data.wifiNetworkHandle, &data.wifiNetworkConfig);
                data.state = APP_NET_WAIT_FOR_FW_UPDATE;
    #endif
                break;

            case APP_NET_WAIT_FOR_FW_UPDATE:
            default:
                break;
        }
    }

    post edited by Luca Pascarella - 2019/02/07 09:25:16
    #10
    rainad
    Moderator
    • Total Posts : 1142
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP Announce Issue 2019/02/07 09:34:25 (permalink)
    0
    Can you reproduce this issue with ETH as well? That'd be useful.
     
    #11
    Luca Pascarella
    Starting Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2007/05/28 00:53:17
    • Location: The Netherlands
    • Status: offline
    Re: TCP/IP Announce Issue 2019/02/07 10:00:30 (permalink)
    0
    No problems with the Ethernet version even if I unplug and plug the Ethernet cable. Same for the WiFi version if I don't change the AP mode the announce works perfectly.
    #12
    rainad
    Moderator
    • Total Posts : 1142
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP Announce Issue 2019/02/07 13:46:48 (permalink)
    0
    It should happen on the Ethernet as well when the cable is disconnected.
    The UDP socket does not make any difference, ETH or Wi-Fi.
    I'll try to see if it can be reproduced.
     
    #13
    Luca Pascarella
    Starting Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2007/05/28 00:53:17
    • Location: The Netherlands
    • Status: offline
    Re: TCP/IP Announce Issue 2019/02/07 15:35:23 (permalink)
    0
    I see the point.
    From a user perspective, my code differs for how I initialize the TCPIP Stack with my settings.
    In the Ethernet case, i just call NetUp with my settings such as static IP, Mask, DNS, or DHCP.
     TCPIP_STACK_NetDown(data.ethNetworkHandle);
    TCPIP_STACK_NetUp(data.ethNetworkHandle, &data.ethNetworkConfig);


    For the WiFi, according to easy_config project, the procedure is longer. I manually should call client and server of DHCP, DNS, BiosName, etc. to properly switch between SoftAP and Infrastructure.
     
    For esample:
    void APP_WIFI_IFModules_Enable(TCPIP_NET_HANDLE netH) {
    #if defined(APP_NET_WIFI_VERSION)
        int netIndex = TCPIP_STACK_NetIndexGet(netH);
        const char *netName = TCPIP_STACK_NetNameGet(netH);

        /*
         * If it's not Wi-Fi interface, then leave it to the TCP/IP stack
         * to configure its DHCP server/client status.
         */
        if (IS_WF_INTF(netName)) {
            iwpriv_get(OPERATIONMODE_GET, &data.s_app_get_param);
            if (data.s_app_get_param.opMode.isServer) {
                TCPIP_DHCP_Disable(netH); // must stop DHCP client first
                TCPIP_DHCPS_Enable(netH); // start DHCP server
                TCPIP_DNS_Disable(netH, true);
                TCPIP_DNSS_Enable(netH);
            } else {
                TCPIP_DHCPS_Disable(netH); // must stop DHCP server first
                TCPIP_DHCP_Enable(netH); // start DHCP client
                TCPIP_DNSS_Disable(netH);
                TCPIP_DNS_Enable(netH, TCPIP_DNS_ENABLE_DEFAULT);
            }
            APP_WIFI_IPv6MulticastFilter_Set(netH);
        }
        if (IS_NBNS_RUN()) {
            const char *netBiosName = TCPIP_STACK_NetBIOSName(netH);
            SYS_CONSOLE_PRINT(" Interface %s on host %s - NBNS enabled\r\n", netName, netBiosName);
        }
        if (IS_MDNS_RUN()) {
            char mDNSServiceName[] = "MyWebServiceNameX "; // base name of the service Must not exceed 16 bytes long
            // the last digit will be incremented by interface
            mDNSServiceName[sizeof (mDNSServiceName) - 2] = '1' + netIndex;
            TCPIP_MDNS_ServiceRegister(netH, mDNSServiceName, "_http._tcp.local", 80, ((const uint8_t *) "path=/index.htm"),
                    1, NULL, NULL);
        }
    #endif
    }
     
    void APP_WIFI_IFModules_Disable(TCPIP_NET_HANDLE netH) {
    const char *netName = TCPIP_STACK_NetNameGet(netH);
    if (IS_WF_INTF(netName) && TCPIP_STACK_NetIsUp(netH))
    APP_WIFI_PowerSave_Config(false);
    TCPIP_DHCPS_Disable(netH);
    TCPIP_DHCP_Disable(netH);
    TCPIP_DNSS_Disable(netH);
    TCPIP_DNS_Disable(netH, true);
    TCPIP_MDNS_ServiceDeregister(netH);
    }


    May this difference hide the problem?
    #14
    Jump to:
    © 2019 APG vNext Commercial Version 4.5