引入mqtt 引入cjson
This commit is contained in:
1 parent
a69c1a58d6
commit
f8591b8b99
86 files changed
+12141
-2157
No files matched your search
@@ -0,0 +1,161 @@
|
||||
#include <cat1drv.h>
|
||||
#include <rtthread.h>
|
||||
#include <os-app.h>
|
||||
#include "main.h"
|
||||
#include "usart-board.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <easyflash.h>
|
||||
#include "netdrv.h"
|
||||
#include "dtu-board.h"
|
||||
|
||||
extern netDrv_t g_cat1Drv;
|
||||
extern netDrv_t g_MJEth1Drv;
|
||||
extern netDrv_t g_dtuDrv;
|
||||
|
||||
|
||||
netDrv_t * g_netDrv;
|
||||
|
||||
|
||||
static int mysock = 0;
|
||||
static int offset = 0;
|
||||
|
||||
|
||||
|
||||
void netdrv_init (void)
|
||||
{
|
||||
char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
{
|
||||
g_netDrv = &g_dtuDrv;
|
||||
DTUThreadStart();
|
||||
}
|
||||
else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
{
|
||||
g_netDrv = &g_cat1Drv;
|
||||
|
||||
CAT1ThreadStart();
|
||||
}
|
||||
// else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
// {
|
||||
// g_netDrv = &g_MJEth1Drv;
|
||||
// MJEth1ThreadStart();
|
||||
// }
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void netdrv_service_tx (uint8_t * data, int length)
|
||||
{
|
||||
char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
{
|
||||
dtu_service_tx ( (char *) data, length);
|
||||
}
|
||||
else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
{
|
||||
cat1_service_tx ( (char *) data, length);
|
||||
}
|
||||
else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void netdrv_reset (void)
|
||||
{
|
||||
char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
{
|
||||
dtu_netreset();
|
||||
}
|
||||
else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
{
|
||||
//cat1_service_tx ( (char *) data, length);
|
||||
}
|
||||
else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int netdrv_getdata (unsigned char* buf, int count)
|
||||
{
|
||||
int tsize = 0;
|
||||
char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
{
|
||||
if (offset + count > g_netDrv->rx_size)
|
||||
{
|
||||
tsize = g_netDrv->rx_size - offset;
|
||||
rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
tsize = count;
|
||||
rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
}
|
||||
|
||||
}
|
||||
else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
{
|
||||
if (offset + count > g_netDrv->rx_size)
|
||||
{
|
||||
tsize = g_netDrv->rx_size - offset;
|
||||
rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
tsize = count;
|
||||
rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
}
|
||||
}
|
||||
else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
offset += count;
|
||||
return tsize;
|
||||
}
|
||||
|
||||
|
||||
int netdrv_clear (void)
|
||||
{
|
||||
|
||||
char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
{
|
||||
MX_UART_Clear (&g_ETH1Drv);
|
||||
|
||||
}
|
||||
else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
{
|
||||
//rt_memcpy(buf, &g_cat1Drv.rxbuff[offset], count);
|
||||
}
|
||||
else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
offset = 0;
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user