Compare commits
1 Commits
WolfgangsO
...
modifyFTPS
Author | SHA1 | Date | |
---|---|---|---|
7286d4aa36 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,7 +1,3 @@
|
||||
# Wolfgangs own stuff
|
||||
build
|
||||
w5500.a
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
@ -1,113 +0,0 @@
|
||||
#include "multicast.h"
|
||||
#include <stdio.h>
|
||||
#include "socket.h"
|
||||
#include "wizchip_conf.h"
|
||||
|
||||
|
||||
int32_t multicast_loopback(uint8_t sn, uint8_t* buf, uint8_t* multicast_ip, uint16_t multicast_port)
|
||||
{
|
||||
int32_t ret;
|
||||
uint16_t size, sentsize;
|
||||
uint8_t destip[4];
|
||||
uint16_t destport, port=3000;
|
||||
|
||||
switch(getSn_SR(sn))
|
||||
{
|
||||
case SOCK_UDP :
|
||||
if((size = getSn_RX_RSR(sn)) > 0)
|
||||
{
|
||||
if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE;
|
||||
ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport);
|
||||
if(ret <= 0)
|
||||
{
|
||||
#ifdef _MULTICAST_DEBUG_
|
||||
printf("%d: recvfrom error. %ld\r\n",sn,ret);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
size = (uint16_t) ret;
|
||||
sentsize = 0;
|
||||
while(sentsize != size)
|
||||
{
|
||||
ret = sendto(sn, buf+sentsize, size-sentsize, destip, destport);
|
||||
if(ret < 0)
|
||||
{
|
||||
#ifdef _MULTICAST_DEBUG_
|
||||
printf("%d: sendto error. %ld\r\n",sn,ret);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
sentsize += ret; // Don't care SOCKERR_BUSY, because it is zero.
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case SOCK_CLOSED:
|
||||
#ifdef _MULTICAST_DEBUG_
|
||||
printf("%d:Multicast Loopback start\r\n",sn);
|
||||
#endif
|
||||
setSn_DIPR(0, multicast_ip);
|
||||
setSn_DPORT(0, multicast_port);
|
||||
if((ret = socket(sn, Sn_MR_UDP, port, Sn_MR_MULTI)) != sn)
|
||||
return ret;
|
||||
#ifdef _MULTICAST_DEBUG_
|
||||
printf("%d:Opened, UDP Multicast Socket\r\n", sn);
|
||||
printf("%d:Multicast Group IP - %d.%d.%d.%d\r\n", sn, multicast_ip[0], multicast_ip[1], multicast_ip[2], multicast_ip[3]);
|
||||
printf("%d:Multicast Group Port - %d\r\n", sn, multicast_port);
|
||||
#endif
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t multicast_recv(uint8_t sn, uint8_t* buf, uint8_t* multicast_ip, uint16_t multicast_port)
|
||||
{
|
||||
int32_t ret;
|
||||
uint16_t size, port=3000;
|
||||
uint8_t destip[4];
|
||||
uint16_t destport;
|
||||
|
||||
switch(getSn_SR(sn))
|
||||
{
|
||||
case SOCK_UDP :
|
||||
if((size = getSn_RX_RSR(sn)) > 0)
|
||||
{
|
||||
if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE;
|
||||
ret = recvfrom(sn, buf, size, destip, (uint16_t*)&destport);
|
||||
if(ret <= 0)
|
||||
{
|
||||
#ifdef _MULTICAST_DEBUG_
|
||||
printf("%d: recvfrom error. %ld\r\n",sn,ret);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
size = (uint16_t) ret;
|
||||
#ifdef _MULTICAST_DEBUG_
|
||||
printf("\r\nrecv size : %d\r\n", size);
|
||||
for(int i=0; i<size; i++)
|
||||
printf("%c", buf[i]);
|
||||
printf("\r\n");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case SOCK_CLOSED:
|
||||
#ifdef _MULTICAST_DEBUG_
|
||||
printf("%d:Multicast Recv start\r\n",sn);
|
||||
#endif
|
||||
setSn_DIPR(sn, multicast_ip);
|
||||
setSn_DPORT(sn, multicast_port);
|
||||
if((ret = socket(sn, Sn_MR_UDP, port, Sn_MR_MULTI)) != sn)
|
||||
return ret;
|
||||
#ifdef _MULTICAST_DEBUG_
|
||||
printf("%d:Opened, UDP Multicast Socket\r\n", sn);
|
||||
printf("%d:Multicast Group IP - %d.%d.%d.%d\r\n", sn, multicast_ip[0], multicast_ip[1], multicast_ip[2], multicast_ip[3]);
|
||||
printf("%d:Multicast Group Port - %d\r\n", sn, multicast_port);
|
||||
#endif
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#ifndef _MULTICAST_H_
|
||||
#define _MULTICAST_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Multicast test debug message printout enable */
|
||||
#define _MULTICAST_DEBUG_
|
||||
|
||||
#ifndef DATA_BUF_SIZE
|
||||
#define DATA_BUF_SIZE 2048
|
||||
#endif
|
||||
|
||||
/* UDP Multicast Loopback test example */
|
||||
int32_t multicast_loopback(uint8_t sn, uint8_t* buf, uint8_t* multicast_ip, uint16_t multicast_port);
|
||||
|
||||
/* UDP Multicast Recv test example */
|
||||
int32_t multicast_recv(uint8_t sn, uint8_t* buf, uint8_t* multicast_ip, uint16_t multicast_port);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -117,7 +117,6 @@ int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
|
||||
uint32_t taddr;
|
||||
getSIPR((uint8_t*)&taddr);
|
||||
if(taddr == 0) return SOCKERR_SOCKINIT;
|
||||
break;
|
||||
}
|
||||
case Sn_MR_UDP :
|
||||
case Sn_MR_MACRAW :
|
||||
|
@ -80,7 +80,7 @@ void wizchip_cris_exit(void) {}
|
||||
* null function is called.
|
||||
*/
|
||||
//void wizchip_cs_select(void) {};
|
||||
__attribute__((weak)) void wizchip_cs_select(void) {}
|
||||
void wizchip_cs_select(void) {}
|
||||
|
||||
/**
|
||||
* @brief Default function to deselect chip.
|
||||
@ -88,7 +88,7 @@ __attribute__((weak)) void wizchip_cs_select(void) {}
|
||||
* null function is called.
|
||||
*/
|
||||
//void wizchip_cs_deselect(void) {};
|
||||
__attribute__((weak)) void wizchip_cs_deselect(void) {}
|
||||
void wizchip_cs_deselect(void) {}
|
||||
|
||||
/**
|
||||
* @brief Default function to read in direct or indirect interface.
|
||||
@ -114,7 +114,7 @@ void wizchip_bus_writedata(uint32_t AddrSel, iodata_t wb) { *((volatile iodata
|
||||
* null function is called.
|
||||
*/
|
||||
//uint8_t wizchip_spi_readbyte(void) {return 0;};
|
||||
__attribute__((weak)) uint8_t wizchip_spi_readbyte(void) {return 0;}
|
||||
uint8_t wizchip_spi_readbyte(void) {return 0;}
|
||||
|
||||
/**
|
||||
* @brief Default function to write in SPI interface.
|
||||
@ -122,7 +122,7 @@ __attribute__((weak)) uint8_t wizchip_spi_readbyte(void) {return 0;}
|
||||
* null function is called.
|
||||
*/
|
||||
//void wizchip_spi_writebyte(uint8_t wb) {};
|
||||
__attribute__((weak)) void wizchip_spi_writebyte(uint8_t wb) {}
|
||||
void wizchip_spi_writebyte(uint8_t wb) {}
|
||||
|
||||
/**
|
||||
* @brief Default function to burst read in SPI interface.
|
||||
@ -130,7 +130,7 @@ __attribute__((weak)) void wizchip_spi_writebyte(uint8_t wb) {}
|
||||
* null function is called.
|
||||
*/
|
||||
//void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {};
|
||||
__attribute__((weak)) void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}
|
||||
void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {}
|
||||
|
||||
/**
|
||||
* @brief Default function to burst write in SPI interface.
|
||||
@ -138,7 +138,7 @@ __attribute__((weak)) void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len)
|
||||
* null function is called.
|
||||
*/
|
||||
//void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {};
|
||||
__attribute__((weak)) void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}
|
||||
void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {}
|
||||
|
||||
/**
|
||||
* @\ref _WIZCHIP instance
|
||||
@ -521,12 +521,7 @@ void wizchip_clrinterrupt(intr_kind intr)
|
||||
setIR( ((((uint16_t)ir) << 8) | (((uint16_t)sir) & 0x00FF)) );
|
||||
#else
|
||||
setIR(ir);
|
||||
//M20200227 : For clear
|
||||
//setSIR(sir);
|
||||
for(ir=0; ir<8; ir++){
|
||||
if(sir & (0x01 <<ir) ) setSn_IR(ir, 0xff);
|
||||
}
|
||||
|
||||
setSIR(sir);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -71,10 +71,6 @@ extern "C" {
|
||||
#define W5300 5300
|
||||
#define W5500 5500
|
||||
|
||||
|
||||
#define _WIZCHIP_ W5500
|
||||
|
||||
|
||||
#ifndef _WIZCHIP_
|
||||
#define _WIZCHIP_ W5100S // W5100, W5100S, W5200, W5300, W5500
|
||||
#endif
|
||||
|
@ -56,8 +56,7 @@
|
||||
/* If you want to display debug & processing message, Define _DHCP_DEBUG_ in dhcp.h */
|
||||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
//#include <stdio.h>
|
||||
int logMsg(const char *format, ...);
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/* DHCP state machine. */
|
||||
@ -418,7 +417,7 @@ void send_DHCP_DISCOVER(void)
|
||||
ip[3] = 255;
|
||||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("> Send DHCP_DISCOVER\r\n");
|
||||
printf("> Send DHCP_DISCOVER\r\n");
|
||||
#endif
|
||||
|
||||
sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG, RIP_MSG_SIZE, ip, DHCP_SERVER_PORT);
|
||||
@ -516,7 +515,7 @@ void send_DHCP_REQUEST(void)
|
||||
for (i = k; i < OPT_SIZE; i++) pDHCPMSG->OPT[i] = 0;
|
||||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("> Send DHCP_REQUEST\r\n");
|
||||
printf("> Send DHCP_REQUEST\r\n");
|
||||
#endif
|
||||
|
||||
sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG, RIP_MSG_SIZE, ip, DHCP_SERVER_PORT);
|
||||
@ -577,7 +576,7 @@ void send_DHCP_DECLINE(void)
|
||||
ip[3] = 0xFF;
|
||||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("\r\n> Send DHCP_DECLINE\r\n");
|
||||
printf("\r\n> Send DHCP_DECLINE\r\n");
|
||||
#endif
|
||||
|
||||
sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG, RIP_MSG_SIZE, ip, DHCP_SERVER_PORT);
|
||||
@ -599,12 +598,10 @@ int8_t parseDHCPMSG(void)
|
||||
{
|
||||
len = recvfrom(DHCP_SOCKET, (uint8_t *)pDHCPMSG, len, svr_addr, &svr_port);
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("DHCP message : %d.%d.%d.%d(%d) %d received. \r\n",svr_addr[0],svr_addr[1],svr_addr[2], svr_addr[3],svr_port, len);
|
||||
printf("DHCP message : %d.%d.%d.%d(%d) %d received. \r\n",svr_addr[0],svr_addr[1],svr_addr[2], svr_addr[3],svr_port, len);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
else return 0;
|
||||
if (svr_port == DHCP_SERVER_PORT) {
|
||||
// compare mac address
|
||||
if ( (pDHCPMSG->chaddr[0] != DHCP_CHADDR[0]) || (pDHCPMSG->chaddr[1] != DHCP_CHADDR[1]) ||
|
||||
@ -612,7 +609,7 @@ int8_t parseDHCPMSG(void)
|
||||
(pDHCPMSG->chaddr[4] != DHCP_CHADDR[4]) || (pDHCPMSG->chaddr[5] != DHCP_CHADDR[5]) )
|
||||
{
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("No My DHCP Message. This message is ignored.\r\n");
|
||||
printf("No My DHCP Message. This message is ignored.\r\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -622,7 +619,7 @@ int8_t parseDHCPMSG(void)
|
||||
((svr_addr[0]!=DHCP_REAL_SIP[0])|| (svr_addr[1]!=DHCP_REAL_SIP[1])|| (svr_addr[2]!=DHCP_REAL_SIP[2])|| (svr_addr[3]!=DHCP_REAL_SIP[3])) )
|
||||
{
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("Another DHCP sever send a response message. This is ignored.\r\n");
|
||||
printf("Another DHCP sever send a response message. This is ignored.\r\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -731,7 +728,7 @@ uint8_t DHCP_run(void)
|
||||
case STATE_DHCP_DISCOVER :
|
||||
if (type == DHCP_OFFER){
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("> Receive DHCP_OFFER\r\n");
|
||||
printf("> Receive DHCP_OFFER\r\n");
|
||||
#endif
|
||||
DHCP_allocated_ip[0] = pDHCPMSG->yiaddr[0];
|
||||
DHCP_allocated_ip[1] = pDHCPMSG->yiaddr[1];
|
||||
@ -747,7 +744,7 @@ uint8_t DHCP_run(void)
|
||||
if (type == DHCP_ACK) {
|
||||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("> Receive DHCP_ACK\r\n");
|
||||
printf("> Receive DHCP_ACK\r\n");
|
||||
#endif
|
||||
if (check_DHCP_leasedIP()) {
|
||||
// Network info assignment from DHCP
|
||||
@ -764,7 +761,7 @@ uint8_t DHCP_run(void)
|
||||
} else if (type == DHCP_NAK) {
|
||||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("> Receive DHCP_NACK\r\n");
|
||||
printf("> Receive DHCP_NACK\r\n");
|
||||
#endif
|
||||
|
||||
reset_DHCP_timeout();
|
||||
@ -778,7 +775,7 @@ uint8_t DHCP_run(void)
|
||||
if ((dhcp_lease_time != INFINITE_LEASETIME) && ((dhcp_lease_time/2) < dhcp_tick_1s)) {
|
||||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("> Maintains the IP address \r\n");
|
||||
printf("> Maintains the IP address \r\n");
|
||||
#endif
|
||||
|
||||
type = 0;
|
||||
@ -809,19 +806,19 @@ uint8_t DHCP_run(void)
|
||||
ret = DHCP_IP_CHANGED;
|
||||
dhcp_ip_update();
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg(">IP changed.\r\n");
|
||||
printf(">IP changed.\r\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
#ifdef _DHCP_DEBUG_
|
||||
else logMsg(">IP is continued.\r\n");
|
||||
else printf(">IP is continued.\r\n");
|
||||
#endif
|
||||
reset_DHCP_timeout();
|
||||
dhcp_state = STATE_DHCP_LEASED;
|
||||
} else if (type == DHCP_NAK) {
|
||||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("> Receive DHCP_NACK, Failed to maintain ip\r\n");
|
||||
printf("> Receive DHCP_NACK, Failed to maintain ip\r\n");
|
||||
#endif
|
||||
|
||||
reset_DHCP_timeout();
|
||||
@ -851,18 +848,18 @@ uint8_t check_DHCP_timeout(void)
|
||||
|
||||
switch ( dhcp_state ) {
|
||||
case STATE_DHCP_DISCOVER :
|
||||
// logMsg("<<timeout>> state : STATE_DHCP_DISCOVER\r\n");
|
||||
// printf("<<timeout>> state : STATE_DHCP_DISCOVER\r\n");
|
||||
send_DHCP_DISCOVER();
|
||||
break;
|
||||
|
||||
case STATE_DHCP_REQUEST :
|
||||
// logMsg("<<timeout>> state : STATE_DHCP_REQUEST\r\n");
|
||||
// printf("<<timeout>> state : STATE_DHCP_REQUEST\r\n");
|
||||
|
||||
send_DHCP_REQUEST();
|
||||
break;
|
||||
|
||||
case STATE_DHCP_REREQUEST :
|
||||
// logMsg("<<timeout>> state : STATE_DHCP_REREQUEST\r\n");
|
||||
// printf("<<timeout>> state : STATE_DHCP_REREQUEST\r\n");
|
||||
|
||||
send_DHCP_REQUEST();
|
||||
break;
|
||||
@ -915,7 +912,7 @@ int8_t check_DHCP_leasedIP(void)
|
||||
// UDP send Timeout occurred : allocated IP address is unique, DHCP Success
|
||||
|
||||
#ifdef _DHCP_DEBUG_
|
||||
logMsg("\r\n> Check leased IP - OK\r\n");
|
||||
printf("\r\n> Check leased IP - OK\r\n");
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@ -949,12 +946,7 @@ void DHCP_init(uint8_t s, uint8_t * buf)
|
||||
DHCP_SOCKET = s; // SOCK_DHCP
|
||||
pDHCPMSG = (RIP_MSG*)buf;
|
||||
DHCP_XID = 0x12345678;
|
||||
{
|
||||
DHCP_XID += DHCP_CHADDR[3];
|
||||
DHCP_XID += DHCP_CHADDR[4];
|
||||
DHCP_XID += DHCP_CHADDR[5];
|
||||
DHCP_XID += (DHCP_CHADDR[3] ^ DHCP_CHADDR[4] ^ DHCP_CHADDR[5]);
|
||||
}
|
||||
|
||||
// WIZchip Netinfo Clear
|
||||
setSIPR(zeroip);
|
||||
setGAR(zeroip);
|
||||
|
@ -539,7 +539,7 @@ int8_t DNS_run(uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns)
|
||||
#ifdef _DNS_DEBUG_
|
||||
printf("> DNS Server is not responding : %d.%d.%d.%d\r\n", dns_ip[0], dns_ip[1], dns_ip[2], dns_ip[3]);
|
||||
#endif
|
||||
close(DNS_SOCKET);
|
||||
wizchip_close(DNS_SOCKET);
|
||||
return 0; // timeout occurred
|
||||
}
|
||||
else if (ret_check_timeout == 0) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,21 +21,19 @@ extern "C" {
|
||||
//#define F_FILESYSTEM // If your target support a file system, you have to activate this feature and implement.
|
||||
|
||||
#if defined(F_FILESYSTEM)
|
||||
#include "ff.h"
|
||||
//#include "ff.h"
|
||||
#endif
|
||||
|
||||
#define F_APP_FTP
|
||||
#define _FTP_DEBUG_
|
||||
|
||||
|
||||
#define LINELEN 100
|
||||
#define _FTP_FILENAME_LEN_ 100
|
||||
//#define DATA_BUF_SIZE 100
|
||||
#if !defined(F_FILESYSTEM)
|
||||
#define _MAX_SS 512
|
||||
#endif
|
||||
|
||||
#define CTRL_SOCK 2
|
||||
#define DATA_SOCK 3
|
||||
#define SOCK_MAX_NUM 4
|
||||
|
||||
#define IPPORT_FTPD 20 /* FTP Data port */
|
||||
#define IPPORT_FTP 21 /* FTP Control port */
|
||||
@ -79,43 +77,18 @@ enum ftp_cmd {
|
||||
NO_CMD,
|
||||
};
|
||||
|
||||
enum ftp_type {
|
||||
ASCII_TYPE,
|
||||
IMAGE_TYPE,
|
||||
LOGICAL_TYPE
|
||||
};
|
||||
|
||||
enum ftp_state {
|
||||
FTPS_NOT_LOGIN,
|
||||
FTPS_LOGIN
|
||||
};
|
||||
|
||||
enum datasock_state{
|
||||
DATASOCK_IDLE,
|
||||
DATASOCK_READY,
|
||||
DATASOCK_START
|
||||
};
|
||||
|
||||
enum datasock_mode{
|
||||
PASSIVE_MODE,
|
||||
ACTIVE_MODE
|
||||
};
|
||||
|
||||
struct ftpd {
|
||||
uint8_t control; /* Control stream */
|
||||
uint8_t data; /* Data stream */
|
||||
|
||||
enum ftp_type type; /* Transfer type */
|
||||
enum ftp_state state;
|
||||
|
||||
enum ftp_cmd current_cmd;
|
||||
|
||||
enum datasock_state dsock_state;
|
||||
enum datasock_mode dsock_mode;
|
||||
|
||||
char username[LINELEN]; /* Arg to USER command */
|
||||
char workingdir[LINELEN];
|
||||
char filename[LINELEN];
|
||||
uint8_t ctrl_sock; /* Control Socket */
|
||||
uint8_t data_sock; /* Data Socket */
|
||||
char user[20]; /* FTP Server user */
|
||||
char pass[20]; /* FTP Server password */
|
||||
char username[_FTP_FILENAME_LEN_]; /* Arg to USER command */
|
||||
char workingdir[_FTP_FILENAME_LEN_];
|
||||
char filename[_FTP_FILENAME_LEN_];
|
||||
uint8_t is_login; /* Login 1: login, 0: Not login */
|
||||
uint8_t is_ascii; /* Transfer Type 1 : ASCII, 0 : Binary */
|
||||
uint8_t is_active; /* FTP Mode 1 : Active, 0: Passive */
|
||||
|
||||
#if defined(F_FILESYSTEM)
|
||||
FIL fil; // FatFs File objects
|
||||
@ -124,18 +97,8 @@ struct ftpd {
|
||||
|
||||
};
|
||||
|
||||
#ifndef un_I2cval
|
||||
typedef union _un_l2cval {
|
||||
uint32_t lVal;
|
||||
uint8_t cVal[4];
|
||||
}un_l2cval;
|
||||
#endif
|
||||
|
||||
void ftpd_init(uint8_t * src_ip);
|
||||
void ftpd_init(char* user, char*pass);
|
||||
uint8_t ftpd_run(uint8_t * dbuf);
|
||||
char proc_ftpd(char * buf);
|
||||
char ftplogin(char * pass);
|
||||
int pport(char * arg);
|
||||
|
||||
int sendit(char * command);
|
||||
int recvit(char * command);
|
||||
|
@ -71,7 +71,7 @@ uint16_t ntp_retry_cnt=0; //counting the ntp retry number
|
||||
48) UTC+13:00 Tonga
|
||||
49) UTC+14:00 Kiribati (Line Islands)
|
||||
*/
|
||||
uint64_t get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
|
||||
void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
|
||||
{
|
||||
tstamp seconds = 0;
|
||||
uint8_t i=0;
|
||||
@ -79,8 +79,6 @@ uint64_t get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
|
||||
{
|
||||
seconds = (seconds << 8) | buf[idx + i];
|
||||
}
|
||||
uint64_t rawSeconds = seconds;
|
||||
|
||||
switch (time_zone)
|
||||
{
|
||||
case 0:
|
||||
@ -134,7 +132,7 @@ uint64_t get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
|
||||
case 20:
|
||||
seconds -= 1*3600;
|
||||
break;
|
||||
case 21: //<2F>?
|
||||
case 21: //<2F><EFBFBD>?
|
||||
case 22:
|
||||
break;
|
||||
case 23:
|
||||
@ -215,8 +213,6 @@ uint64_t get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx)
|
||||
|
||||
//calculation for date
|
||||
calcdatetime(seconds);
|
||||
|
||||
return rawSeconds;
|
||||
}
|
||||
|
||||
void SNTP_init(uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf)
|
||||
@ -266,7 +262,7 @@ int8_t SNTP_run(datetime *time)
|
||||
if (RSR_len > MAX_SNTP_BUF_SIZE) RSR_len = MAX_SNTP_BUF_SIZE; // if Rx data size is lager than TX_RX_MAX_BUF_SIZE
|
||||
recvfrom(NTP_SOCKET, data_buf, RSR_len, (uint8_t *)&destip, &destport);
|
||||
|
||||
time->seconds = get_seconds_from_ntp_server(data_buf,startindex);
|
||||
get_seconds_from_ntp_server(data_buf,startindex);
|
||||
time->yy = Nowdatetime.yy;
|
||||
time->mo = Nowdatetime.mo;
|
||||
time->dd = Nowdatetime.dd;
|
||||
|
@ -56,7 +56,6 @@ typedef struct _datetime
|
||||
uint8_t hh;
|
||||
uint8_t mm;
|
||||
uint8_t ss;
|
||||
uint64_t seconds;
|
||||
} datetime;
|
||||
|
||||
#define ntp_port 123 //ntp server port number
|
||||
@ -64,7 +63,7 @@ typedef struct _datetime
|
||||
#define UTC_ADJ_HRS 9 // SEOUL : GMT+9
|
||||
#define EPOCH 1900 // NTP start year
|
||||
|
||||
uint64_t get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx);
|
||||
void get_seconds_from_ntp_server(uint8_t *buf, uint16_t idx);
|
||||
void SNTP_init(uint8_t s, uint8_t *ntp_server, uint8_t tz, uint8_t *buf);
|
||||
int8_t SNTP_run(datetime *time);
|
||||
tstamp changedatetime_to_seconds(void);
|
||||
|
@ -169,7 +169,7 @@ void httpServer_run(uint8_t seqnum)
|
||||
|
||||
gettime = get_httpServer_timecount();
|
||||
// Check the TX socket buffer for End of HTTP response sends
|
||||
while(getSn_TX_FSR(s) != (getSn_TxMAX(s)))
|
||||
while(getSn_TX_FSR(s) != (getSn_TXBUF_SIZE(s)*1024))
|
||||
{
|
||||
if((get_httpServer_timecount() - gettime) > 3)
|
||||
{
|
||||
|
68
Makefile
68
Makefile
@ -1,68 +0,0 @@
|
||||
WIZCHIP?=W5500
|
||||
ENABLE_DHCP?=yes
|
||||
ENABLE_DNS?=yes
|
||||
ENABLE_HTTPSERVER?=yes
|
||||
ENABLE_MQTT?=no
|
||||
ENABLE_SNTP?=yes
|
||||
|
||||
CFLAGS?=-mcpu=cortex-m3 -mthumb -Og -fdata-sections -ffunction-sections -g -gdwarf-2
|
||||
|
||||
CC=arm-none-eabi-gcc
|
||||
AR=arm-none-eabi-ar
|
||||
|
||||
CFLAGS+=-iquote Ethernet -Wall -D_WIZCHIP_=$(WIZCHIP)
|
||||
|
||||
OBJDIR=build
|
||||
VPATH=Ethernet:Ethernet/W5500
|
||||
ifeq ($(ENABLE_DHCP),yes)
|
||||
VPATH+=Internet/DHCP
|
||||
endif
|
||||
ifeq ($(ENABLE_DNS),yes)
|
||||
VPATH+=Internet/DNS
|
||||
endif
|
||||
ifeq ($(ENABLE_MQTT),yes)
|
||||
VPATH+=Internet/MQTT:Internet/MQTT/MQTTPacket/src
|
||||
endif
|
||||
ifeq ($(ENABLE_HTTPSERVER),yes)
|
||||
VPATH+=Internet/httpServer
|
||||
endif
|
||||
ifeq ($(ENABLE_SNTP),yes)
|
||||
VPATH+=Internet/SNTP
|
||||
endif
|
||||
|
||||
OBJS=$(addprefix $(OBJDIR)/,wizchip_conf.o socket.o w5500.o)
|
||||
ifeq ($(ENABLE_DHCP),yes)
|
||||
OBJS+=$(addprefix $(OBJDIR)/,dhcp.o)
|
||||
endif
|
||||
ifeq ($(ENABLE_DNS),yes)
|
||||
OBJS+=$(addprefix $(OBJDIR)/,dns.o)
|
||||
endif
|
||||
ifeq ($(ENABLE_HTTPSERVER),yes)
|
||||
OBJS+=$(addprefix $(OBJDIR)/,httpParser.o httpServer.o httpUtil.o)
|
||||
endif
|
||||
ifeq ($(ENABLE_SNTP),yes)
|
||||
OBJS+=$(addprefix $(OBJDIR)/,sntp.o)
|
||||
endif
|
||||
ifeq ($(ENABLE_MQTT),yes)
|
||||
OBJS+=$(addprefix $(OBJDIR)/,MQTTConnectClient.o MQTTConnectServer.o MQTTDeserializePublish.o \
|
||||
MQTTFormat.o MQTTPacket.o MQTTSerializePublish.o MQTTSubscribeClient.o MQTTSubscribeServer.o \
|
||||
MQTTUnsubscribeClient.o MQTTUnsubscribeServer.o mqtt_interface.o MQTTClient.o)
|
||||
endif
|
||||
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
$(AR) rcs w5500.a $^
|
||||
cp w5500.a ../build/
|
||||
|
||||
$(OBJDIR)/%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJS): | $(OBJDIR)
|
||||
|
||||
$(OBJDIR):
|
||||
mkdir $(OBJDIR)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -rf $(OBJDIR)
|
Reference in New Issue
Block a user