引入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,114 @@
|
||||
#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"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if !defined(LOG_TAG)
|
||||
#define LOG_TAG "MJE1S2"
|
||||
#endif
|
||||
#include <elog.h>
|
||||
|
||||
|
||||
ALIGN (RT_ALIGN_SIZE)
|
||||
static char thread_stack[4096];
|
||||
static struct rt_thread thread;
|
||||
static char tcprxbbuff[1200];
|
||||
static char tcptxbbuff[1200];
|
||||
|
||||
|
||||
|
||||
netDrv_t g_MJEth1Drv =
|
||||
{
|
||||
0, // 信号值
|
||||
"", // iccid
|
||||
Init, // 状态
|
||||
tcprxbbuff, // 接受缓存
|
||||
0, // 接受数据长度
|
||||
tcptxbbuff, // 发送数据缓存
|
||||
0, // 发送数据长度
|
||||
};
|
||||
|
||||
|
||||
static void mje1s2f_rx_done (void)
|
||||
{
|
||||
rt_event_send (gUartEvents, EVENT_UART_ETH1_RX);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void thread_entry (void * argument)
|
||||
{
|
||||
|
||||
|
||||
|
||||
uint8_t low_leve = 0; // 高电平时间
|
||||
g_ETH1Drv.rxdone = mje1s2f_rx_done;
|
||||
g_ETH1Drv.BaudRate = 115200;
|
||||
// 启动4G 模块电源
|
||||
// 拉高4G 模块复位
|
||||
MX_UART_Init (&g_ETH1Drv);
|
||||
HAL_GPIO_WritePin (ETH_RST_GPIO_Port, ETH_RST_Pin, GPIO_PIN_SET);
|
||||
rt_thread_mdelay (1000);
|
||||
HAL_GPIO_WritePin (GPIOA, ETH_PW_Pin | GSM_PW_Pin, GPIO_PIN_SET);
|
||||
rt_thread_mdelay (3000);
|
||||
while (1)
|
||||
{
|
||||
MODE_RST:
|
||||
MX_UART_Init (&g_ETH1Drv);
|
||||
HAL_GPIO_WritePin (ETH_RST_GPIO_Port, ETH_RST_Pin, GPIO_PIN_SET);
|
||||
rt_thread_mdelay (1000);
|
||||
HAL_GPIO_WritePin (GPIOA, ETH_PW_Pin | GSM_PW_Pin, GPIO_PIN_SET);
|
||||
rt_thread_mdelay (3000);
|
||||
while (1) // 判断是否链接成功
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//// rt_kprintf("zs0010+++++++++++++++++++\r\n");
|
||||
// MX_UART_PutBuffer(&g_ETH1Drv,(char *)readip,13) ;
|
||||
//
|
||||
// 发送数据
|
||||
if (RT_EOK == rt_event_recv (gUartEvents, EVENT_UART_ETH1_RX, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 2000, RT_NULL)) // 需要发送数据
|
||||
{
|
||||
for (int i = 0 ; i < g_ETH1Drv.rx_size; i++)
|
||||
{
|
||||
rt_kprintf ("%02X", g_ETH1Drv.rx_buffer[i]);
|
||||
}
|
||||
rt_kprintf ("\r\n");
|
||||
MX_UART_Clear (&g_ETH1Drv) ;
|
||||
}
|
||||
|
||||
rt_thread_mdelay (10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void MJEth1ThreadStart (void)
|
||||
{
|
||||
/* 创建线程1,名称是thread1,入口是thread1_entry */
|
||||
rt_thread_init (&thread, "mjeth1_thread",
|
||||
thread_entry, RT_NULL,
|
||||
&thread_stack[0],
|
||||
sizeof (thread_stack),
|
||||
MJETH1_THREAD_PRIORITY, MJETH1_THREAD_TIMESLICE);
|
||||
rt_thread_startup (&thread);
|
||||
|
||||
return ;
|
||||
}
|
||||
Reference in new issue
Block a user