apply.c

来自「STC51系列的源码」· C语言 代码 · 共 63 行

C
63 行
字号
/********************************************************************************/
/* filename: net_apply.c                                                        */
/* version : v1.00                                                              */
/* created : hw-chen                                                            */
/********************************************************************************/
#include "../CPU/CPU.h"
#include "../CFG/CFG.h"
#include "../UART/UART.h"
#include "../TC1602A/TC1602A.h"
#include "uip.h"
#include "etherdev.h"
#include "apply.h"

struct uip_conn * da18b20_connect;
unsigned char ds18b20_buffer[0x20];
unsigned char ds18b20_flag;
unsigned char ds18b20_lenth;

/********************************************************************************/
/* function : main_apply_initialize()                                           */
/* created  : hw-chen                                                           */
/* descript : TCP服务器工作初始化                                               */
/********************************************************************************/
void main_apply_initialize(void)
{   uip_listen(65000);  //* 侦听
}

/********************************************************************************/
/* function : apply_poll_ds18b20()                                              */
/* created  : hw-chen                                                           */
/* descript : 读取缓冲区数据                                                    */
/********************************************************************************/
void apply_poll_ds18b20(void)
{   if(ds18b20_flag==0x0)
    {   return ;
    }
    ds18b20_flag=0x0;
    uip_send(ds18b20_buffer,ds18b20_lenth);
}
 
/********************************************************************************/
/* function : main_apply_process()                                              */
/* created  : hw-chen                                                           */
/* descript : TCP服务器工作任务                                                 */
/********************************************************************************/
unsigned char wellcome[]="hello,wellcome.\r\n";
unsigned char recv_buffer[0x200];
unsigned int recv_length;
void main_apply_process(void)
{   if(uip_connected())
    {   uip_send(wellcome,strlen(wellcome));
        return ;//net_client_proc_connected();
    }
    if(uip_newdata())//* 设备作为客户端,收到对方发送过来的数据
    {   UART_printf("tcp:%s.\r\n",uip_appdata);
        uip_send(uip_appdata,uip_len);
    }
    if(uip_poll()) 
    {   apply_poll_ds18b20();
    }
    return;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?