nova verzija tcp+udp->serial com

main.cpp

Committer:
bosko001
Date:
2020-05-01
Revision:
12:cbfc10c15437
Parent:
11:2cc7e6f06cff
Child:
13:03617f6ed112

File content as of revision 12:cbfc10c15437:

#include "mbed.h"
#include "clubbing.h"
#include "EthernetSetup.h"
#include "UdpToScom.h"
#include "TcpServerToFlash.h"
#include "dxml.h"
#include "doHTML.h"
#include "dataFlash.h"
#include "string.h"





volatile PFV pfv = NULL; 


DigitalOut GLed(LED2,1);

void pfv_fun( void ) 
{
     while(true) 
     { 
        if(pfv) {pfv(); pfv = NULL;}
        cleanTcpServerToFlashThread( );

     } 
} 
Thread pfv_thread(pfv_fun);


void input_fun( void ) 
{
     while(true) 
     { 
      unsigned char uc;
        uc = (unsigned char)getchar( );
        printf( "\n\runesen karakter %c\n\r", uc);
        if( uc == 'h' ) 
        {
            extern C_HTMLparse *gpc_html;
                    auto c = gpc_html->getHTML_free( );
                    printf("\n\r%s\n\r", c);
                    free(c);

        }
     } 
} 
Thread input_thread(input_fun);


    C_HTMLparse *gpc_html;
    
    
    
    

int main(void)
{
  
    printf("\n\r----------  POCETAK  ------------- \n\r");
    
    init_FlashData( );
    showFlashData(  );

   gpc_html = new C_HTMLparse;

//                    auto c = gpc_html->getHTML_free( );  // konvertovanje HTMLa u niz
//                    printf("\n\r HTML:\n\n %s\n\rduzina = %d", c, strlen(c));  // slanje HTML-a
//                    free(c); // oslobadjanje memorije HTML niza

//    putHTMLintoFLASH( gpc_html );
    putFLASHintoHTML( gpc_html );


//    init_EthToScom(  );

   extern EthernetInterface *gp_eth;

   gp_eth = ethernet_setup(  );

    if(gp_eth == NULL) printf("ethernet greska\n\r"); 
    else 
    {
      printf("eth OK\n\r");
      scomRxThreadRiseUp(  );
      udpRxThreadRiseUp(  );

#if NO_UDP <= 1
    inic_TcpServerToFlash(  );
#endif
    }
    
extern void test_HTML(void);
//    test_HTML( );

    
int i=0;
    while(true)
    {
       if(i++ >10 ) { i=0;  GLed = !GLed;}
        wait(0.01);  
    } 

     deinit_FlashData(  );


}








//
//enum nsapi_error {
//    NSAPI_ERROR_OK                  =  0,        /*!< no error */
//    NSAPI_ERROR_WOULD_BLOCK         = -3001,     /*!< no data is not available but call is non-blocking */
//    NSAPI_ERROR_UNSUPPORTED         = -3002,     /*!< unsupported functionality */
//    NSAPI_ERROR_PARAMETER           = -3003,     /*!< invalid configuration */
//    NSAPI_ERROR_NO_CONNECTION       = -3004,     /*!< not connected to a network */
//    NSAPI_ERROR_NO_SOCKET           = -3005,     /*!< socket not available for use */
//    NSAPI_ERROR_NO_ADDRESS          = -3006,     /*!< IP address is not known */
//    NSAPI_ERROR_NO_MEMORY           = -3007,     /*!< memory resource not available */
//    NSAPI_ERROR_NO_SSID             = -3008,     /*!< ssid not found */
//    NSAPI_ERROR_DNS_FAILURE         = -3009,     /*!< DNS failed to complete successfully */
//    NSAPI_ERROR_DHCP_FAILURE        = -3010,     /*!< DHCP failed to complete successfully */
//    NSAPI_ERROR_AUTH_FAILURE        = -3011,     /*!< connection to access point failed */
//    NSAPI_ERROR_DEVICE_ERROR        = -3012,     /*!< failure interfacing with the network processor */
//    NSAPI_ERROR_IN_PROGRESS         = -3013,     /*!< operation (eg connect) in progress */
//    NSAPI_ERROR_ALREADY             = -3014,     /*!< operation (eg connect) already in progress */
//    NSAPI_ERROR_IS_CONNECTED        = -3015,     /*!< socket is already connected */
//    NSAPI_ERROR_CONNECTION_LOST     = -3016,     /*!< connection lost */
//    NSAPI_ERROR_CONNECTION_TIMEOUT  = -3017,     /*!< connection timed out */
//};