-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest2.c
39 lines (36 loc) · 1003 Bytes
/
test2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <string.h>
#include <stdio.h>
#include "setup.h"
#include "wizchip_conf.h"
#include "socket.h"
#include "loopback.h"
void HAL_Delay(uint16_t count);
/** STM8S Discovery CPU RAM size is only 2K, we need to
* redefine LOOPBACK_DATA_BUF_SIZE in project settings
* Project Settings->C Compiler->Predefined Symbox, add
* LOOPBACK_DATA_BUF_SIZE=512
*/
//void SerialPutString(char *s);
//#define PRINT_STR SerialPutString
void loop_tcp_server_test(int16_t port)
{
uint8_t buffer[LOOPBACK_DATA_BUF_SIZE];
printf( "TCP server test\r\n" );
while(1)
loopback_tcps(0, buffer, port);
}
void loop_tcp_client_test(uint8_t *destip, int16_t destport)
{
uint8_t buffer[LOOPBACK_DATA_BUF_SIZE];
printf( "TCP Client Test\r\n" );
while(1) {
loopback_tcpc(0, buffer, destip, destport);
}
}
void ping_client_test(uint8_t *destip)
{
extern uint8_t ping_auto(uint8_t s, uint8_t *addr);
printf( "Ping Client Test\r\n" );
while(1)
ping_auto( 0, destip );
}