]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/CyaSSL/IDE/MDK5-ARM/Projects/EchoServer/main.c
Demo application related:
[freertos] / FreeRTOS-Plus / Source / CyaSSL / IDE / MDK5-ARM / Projects / EchoServer / main.c
1 /* main.c
2  *
3  * Copyright (C) 2006-2014 wolfSSL Inc.
4  *
5  * This file is part of CyaSSL.
6  *
7  * CyaSSL is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * CyaSSL is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21  
22 #ifdef HAVE_CONFIG_H
23     #include <config.h>
24 #endif
25
26 #include <cyassl/ctaocrypt/visibility.h>
27 #include <cyassl/ctaocrypt/logging.h>
28
29 #include "cmsis_os.h"
30 #include "rl_fs.h" 
31 #include "rl_net.h" 
32 #include <stdio.h>
33 #include "cyassl_MDK_ARM.h"
34 #include <cyassl/ssl.h>
35
36 /*-----------------------------------------------------------------------------
37  *        Initialize a Flash Memory Card
38  *----------------------------------------------------------------------------*/
39 static void init_filesystem (void) {
40     int32_t retv;
41
42     retv = finit ("M0:");
43     if (retv == 0) {
44         retv = fmount ("M0:");
45         if (retv == 0) {
46             printf ("Drive M0 ready!\n");
47         }
48         else {
49           printf ("Drive M0 mount failed!\n");
50         }
51     } else {
52         printf ("Drive M0 initialization failed!\n");
53     }
54 }
55
56 /*-----------------------------------------------------------------------------
57  *        TCP/IP tasks
58  *----------------------------------------------------------------------------*/
59 void tcp_poll (void const *arg)
60 {
61     CYASSL_MSG("TCP polling started.\n") ;
62     while (1) {
63         net_main ();
64         osDelay(1) ;
65     }
66 }
67
68 typedef struct func_args {
69     int    argc;
70     char** argv;
71 } func_args;
72
73 extern void echoserver_test(func_args * args) ;
74 extern void init_time(void) ;
75
76     osThreadDef (tcp_poll, osPriorityHigh, 1, 0) ;
77 /*-----------------------------------------------------------------------------
78  *       mian entry 
79  *----------------------------------------------------------------------------*/
80 int myoptind = 0;
81 char* myoptarg = NULL;
82
83 int main() 
84 {
85     void *args = NULL ;
86     init_filesystem ();
87     net_initialize() ;
88     osThreadCreate (osThread (tcp_poll), NULL); 
89     osDelay(10000) ;  /* wait for DHCP */
90     #if defined(DEBUG_CYASSL)
91         printf("Turning ON Debug message\n") ;
92         CyaSSL_Debugging_ON() ;
93     #endif
94
95         printf("echoserver: Started\n") ;
96     echoserver_test(args) ;
97     printf("echoserver: Terminated\n") ;
98 }