AzureMXChip/MXCHIPAZ3166/core/lib/netxduo/samples/demo_netxduo_smtp_client.c
void    tx_application_define(void *first_unused_memory)
{

UINT    status;
CHAR    *free_memory_pointer;


    /* Setup the pointer to unallocated memory.  */
    free_memory_pointer =  (CHAR *) first_unused_memory;

    /* Create IP default packet pool. This packets do not need a very large payload. */
    status =  nx_packet_pool_create(&ip_packet_pool, "Default IP Packet Pool", 
                                    512, free_memory_pointer, 2048);

    /* Update pointer to unallocated (free) memory. */
    free_memory_pointer = free_memory_pointer + 2048;    

    /* Create SMTP Client packet pool. This is only for transmitting packets to the server.
       It need not be a separate packet pool than the IP default packet pool but for more efficient
       resource use, we use two different packet pools because the CLient SMTP messages
       generally require more payload than IP control packets. 

       Packet payload depends on the SMTP Client application requirements.  Size of packet payload 
       must include IP and TCP headers. For IPv6 connections, IP and TCP header data is 60 bytes. For IPv4  
       IP and TCP header data is 40 bytes (not including TCP options). 
    */

    status |=  nx_packet_pool_create(&client_packet_pool, "SMTP Client Packet Pool", 
                                     800, free_memory_pointer, (10*800));

    if (status != NX_SUCCESS)
    {
        return;
    }

    /* Update pointer to unallocated (free) memory. */
    free_memory_pointer = free_memory_pointer + (10*800);    

    /* Initialize the NetX system. */
    nx_system_initialize();

    /* Create the client thread */
    status = tx_thread_create(&demo_client_thread, "client_thread",
                              demo_client_thread_entry, 0, free_memory_pointer,
                              2048, 16, 16,
                              TX_NO_TIME_SLICE, TX_DONT_START);

    if (status != NX_SUCCESS)
    {

        printf("Error creating Client thread. Status 0x%x\r\n", status);
        return;       
    }

    /* Update pointer to unallocated (free) memory. */
    free_memory_pointer =  free_memory_pointer + 4096;


    /* Create Client IP instance. Remember to replace the generic driver
       with a real ethernet driver to actually run this demo! */
    status = nx_ip_create(&client_ip, "SMTP Client IP Instance", CLIENT_IP_ADDRESS, 0xFFFFFF00UL, 
                          &ip_packet_pool, _nx_ram_network_driver, free_memory_pointer, 
                          2048, 1);
   
    free_memory_pointer =  free_memory_pointer + 2048;

    /* Enable ARP and supply ARP cache memory. */
    status =  nx_arp_enable(&client_ip, (void **) free_memory_pointer, 1040);

    /* Update pointer to unallocated (free) memory. */
    free_memory_pointer = free_memory_pointer + 1040;
    
    /* Enable TCP for client. */
    status =  nx_tcp_enable(&client_ip);

    if (status != NX_SUCCESS)
    {
        return;
    }

    /* Enable ICMP for client. */
    status =  nx_icmp_enable(&client_ip);

    if (status != NX_SUCCESS)
    {
        return;
    }

    /* Start the client thread. */
    tx_thread_resume(&demo_client_thread);

    return;
}
/* Define what the initial system looks like.  */
Define what the initial system looks like.
Define what the initial system looks like .
void    tx_application_define(void *first_unused_memory)
{
UINT    status;
CHAR    *free_memory_pointer;
    free_memory_pointer =  (CHAR *) first_unused_memory;
    status =  nx_packet_pool_create(&ip_packet_pool, "Default IP Packet Pool", 
                                    512, free_memory_pointer, 2048);
    free_memory_pointer = free_memory_pointer + 2048;    
    status |=  nx_packet_pool_create(&client_packet_pool, "SMTP Client Packet Pool", 
                                     800, free_memory_pointer, (10*800));
    if (status != NX_SUCCESS)
    {
        return;
    }
    free_memory_pointer = free_memory_pointer + (10*800);    
    nx_system_initialize();
    status = tx_thread_create(&demo_client_thread, "client_thread",
                              demo_client_thread_entry, 0, free_memory_pointer,
                              2048, 16, 16,
                              TX_NO_TIME_SLICE, TX_DONT_START);
    if (status != NX_SUCCESS)
    {
        printf("Error creating Client thread. Status 0x%x\r\n", status);
        return;       
    }
    free_memory_pointer =  free_memory_pointer + 4096;
    status = nx_ip_create(&client_ip, "SMTP Client IP Instance", CLIENT_IP_ADDRESS, 0xFFFFFF00UL, 
                          &ip_packet_pool, _nx_ram_network_driver, free_memory_pointer, 
                          2048, 1);
    free_memory_pointer =  free_memory_pointer + 2048;
    status =  nx_arp_enable(&client_ip, (void **) free_memory_pointer, 1040);
    free_memory_pointer = free_memory_pointer + 1040;
    status =  nx_tcp_enable(&client_ip);
    if (status != NX_SUCCESS)
    {
        return;
    }
    status =  nx_icmp_enable(&client_ip);
    if (status != NX_SUCCESS)
    {
        return;
    }
    tx_thread_resume(&demo_client_thread);
    return;
}
void tx_application_define ( void * first_unused_memory ) { UINT status ; CHAR * free_memory_pointer ; free_memory_pointer = ( CHAR * ) first_unused_memory ; status = nx_packet_pool_create ( & ip_packet_pool , " " , 512 , free_memory_pointer , 2048 ) ; free_memory_pointer = free_memory_pointer + 2048 ; status |= nx_packet_pool_create ( & client_packet_pool , " " , 800 , free_memory_pointer , ( 10 * 800 ) ) ; if ( status != NX_SUCCESS ) { return ; } free_memory_pointer = free_memory_pointer + ( 10 * 800 ) ; nx_system_initialize ( ) ; status = tx_thread_create ( & demo_client_thread , " " , demo_client_thread_entry , 0 , free_memory_pointer , 2048 , 16 , 16 , TX_NO_TIME_SLICE , TX_DONT_START ) ; if ( status != NX_SUCCESS ) { printf ( " \r \n " , status ) ; return ; } free_memory_pointer = free_memory_pointer + 4096 ; status = nx_ip_create ( & client_ip , " " , CLIENT_IP_ADDRESS , 0xFFFFFF00UL , & ip_packet_pool , _nx_ram_network_driver , free_memory_pointer , 2048 , 1 ) ; free_memory_pointer = free_memory_pointer + 2048 ; status = nx_arp_enable ( & client_ip , ( void * * ) free_memory_pointer , 1040 ) ; free_memory_pointer = free_memory_pointer + 1040 ; status = nx_tcp_enable ( & client_ip ) ; if ( status != NX_SUCCESS ) { return ; } status = nx_icmp_enable ( & client_ip ) ; if ( status != NX_SUCCESS ) { return ; } tx_thread_resume ( & demo_client_thread ) ; return ; }
Define what the initial system looks like.
Define what the initial system looks like .
/* Setup the pointer to unallocated memory.  */ /* Create IP default packet pool. This packets do not need a very large payload. */ /* Update pointer to unallocated (free) memory. */ /* Create SMTP Client packet pool. This is only for transmitting packets to the server.
       It need not be a separate packet pool than the IP default packet pool but for more efficient
       resource use, we use two different packet pools because the CLient SMTP messages
       generally require more payload than IP control packets. 

       Packet payload depends on the SMTP Client application requirements.  Size of packet payload 
       must include IP and TCP headers. For IPv6 connections, IP and TCP header data is 60 bytes. For IPv4  
       IP and TCP header data is 40 bytes (not including TCP options). 
    */ /* Update pointer to unallocated (free) memory. */ /* Initialize the NetX system. */ /* Create the client thread */ /* Update pointer to unallocated (free) memory. */ /* Create Client IP instance. Remember to replace the generic driver
       with a real ethernet driver to actually run this demo! */ /* Enable ARP and supply ARP cache memory. */ /* Update pointer to unallocated (free) memory. */ /* Enable TCP for client. */ /* Enable ICMP for client. */ /* Start the client thread. */