Qhov teeb meem no rau koj los thawb lub tswv yim zoo heev Diwen Developer Forum Award-winning open source case - T5L-based smtp mail sender, engineers siv T5L ntse screen, los ntawm WiFi module kom nkag mus rau smtp server, kom ua tiav txoj haujlwm xa email. rau tus thawj coj, kev ua haujlwm ntawm lub vijtsam nkag mus rau tus neeg txais email chaw nyob, email npe, email cov ntsiab lus thiab lwm yam ntaub ntawv tuaj yeem nkag rau ntawm lub vijtsam. Nws yog ib qho tsim nyog sau cia tias cov ntsiab lus email tseem txhawb cov ntawv nyeem, kev tswj hwm kev teeb tsa, teeb tsa cov ntawv xim thiab lwm txoj hauv kev kho.
1.Programme Architecture
T5L ntse npo tswj lub WiFi module kom cuam tshuam nrog smtp server los ntawm serial chaw nres nkoj 5 kom ua tiav txoj haujlwm ntawm kev xa email.
2.Interface Development
DGUS software ua tiav kev txhim kho ntawm cov zaub thiab kov lub luag haujlwm los ntawm superposition ntawm txheej. Cov neeg siv tsuas yog yuav tsum tau thauj cov ntaub ntawv duab npaj rau hauv DGUS software thiab teeb tsa cov duab thiab kov cov haujlwm.
1 c51SoftwareDkos npe
T5L ntse npo serial chaw nres nkoj 5 sib txuas lus nrog WiFi module kom tiav kev sib cuam tshuam nrog smtp server. Ib feem ntawm lub ntsiab code yog raws li nram no:
void uart5_init(u32 baud)
{
SCON3T = 0x80;
SCON3R = 0x80;
baud = (u32)((ob npaug)(FOSC/8.0)/baud);
BODE3_DIV_H = (baud>>8)&0xff;
BODE3_DIV_L = baud&0xff;
ES3R = 0;
ES3T = 0;
}
void u5_send_byte(u8 byte)
{
SBUF3_TX = byte;
thaum(!(SCON3T&0x01));
SCON3T &= 0xfe;
}
void u5_send_bytes(u8 *bytes,u16 len)
{
u16 ;ua.
rau (i = 0; i
{
SBUF3_TX = bytes;
thaum(!(SCON3T&0x01));
SCON3T &= 0xfe;
}
}
void get_input(u8 * val, u8 len)
{
ua 8i;.
rau (i = 0; i
{
if(val==0xf)
{
val = 0x00;
val[i+1] = 0x00;
rov qab los;
}
}
}
u8 esp8266_send_cmd(u8 *cmd,u8 *ack,u16 waittime,u8 clearBuffer)
{
ua 8;0.
rx_stay=0;
yog (ack&&waittime&&cmd)
{
thaum (-- tos lub sijhawm)
{
sys_delay_ms(10);
if(rx_sta&0X8000)
{
yog (esp8266_check_respond(ack))
tawg;
}
}
if(waittime==0)res=1;
if(clearBuffer==1)rx_sta=0;
}
rov res;
}
typedef struct {
ua 8cmd;.
u8 email[20];
u8 npe[20];
u8 npe[20];
u8 msg [60];
}EMAIL_INFO;
EMAIL_INFO email_info;
u8 teb[80];
u8 wifi_name[30];
u8 wifi_passwd[30];
u8 server[30];
u8 chaw nres nkoj[30];
u8 username[30];
u8 auth_code[30];
u 8 rx;.
sys_read_vp(0x1000,(u8*)&btn_val,1);
yog tias (btn_val)
{
if(btn_val==1)
{
sys_read_vp(0x3000,email_info.name,10);
sys_read_vp(0x3020, email_info.email, 10);
sys_read_vp(0x3040,email_info.title,10);
sys_read_vp(0x3060, email_info.msg, 30);
get_input(email_info.name, 20);
get_input(email_info.email, 20);
get_input(email_info.title, 20);
get_input(email_info.msg,60);
send_packet((u8*)&email_info,sizeof(EMAIL_INFO));
if(rx_sta)
xa_mail(email_info.email,email_info.title,email_info.msg);
}lse yog(btn_val==2)
{
sys_read_vp(0x3100,wifi_name,15);
sys_read_vp(0x3120,wifi_passwd,15);
get_input(wifi_name, 30);
get_input(wifi_passwd, 30);
}lse yog(btn_val==3)
{
sys_read_vp(0x3200, server, 15);
sys_read_vp(0x3220, chaw nres nkoj, 15);
sys_read_vp(0x3240, npe, 15);
sys_read_vp(0x3260,auth_code,15);
get_input(server, 30);
get_input(port, 30);
get_input(username, 30);
get_input(auth_code, 30);
}
btn_val = 0;
sys_write_vp(0x1000,(u8*)&btn_val,1);
}
sys_read_vp(0x2050,(u8*)&btn_val2,1);
yog tias(btn_val2!=old_val)
{
if(btn_val2==1)
sys_write_vp(0x3060,"Nov yog email los ntawm T5L!\0\0",30);
else if(btn_val2==2)
sys_write_vp(0x3060,"
\0\0", 30);
else if(btn_val2==3)
sys_write_vp(0x3060", Ua siab loj
Liab
\0\0", 30);
old_val = btn_val2;
}
Post lub sij hawm: Oct-31-2023