Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
wirerope
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
IOT
wirerope
Commits
d2b4ee17
Commit
d2b4ee17
authored
Jan 17, 2024
by
aohui.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加状态机、开启4G和以太网、开启以太网静态IP可配(v1.01)
parent
28d624b9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1080 additions
and
435 deletions
+1080
-435
wit.c
components/Application/wit.c
+832
-350
wit.h
components/Application/wit.h
+67
-18
wit_config.h
components/config/wit_config.h
+5
-2
ts_iot01b.c
components/eth_parsing/ts_iot01b.c
+93
-4
ts_iot01b.h
components/eth_parsing/ts_iot01b.h
+24
-10
httputil.c
components/infa/APP/httputil.c
+6
-4
tcp_server.c
components/infa/APP/tcp_server.c
+35
-27
w5100s_conf.c
components/infa/eth/w5100s_conf.c
+6
-2
celluar_gpio.c
components/infa/generation/Celluar/celluar_gpio.c
+3
-3
celluar_usb.c
components/infa/generation/Celluar/celluar_usb.c
+1
-1
app_main.c
main/app_main.c
+6
-12
sdkconfig
sdkconfig
+2
-2
No files found.
components/Application/wit.c
View file @
d2b4ee17
This diff is collapsed.
Click to expand it.
components/Application/wit.h
View file @
d2b4ee17
#ifndef WIT_H
#define WIT_H
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "freertos/queue.h"
#include "freertos/timers.h"
#include "wit_config.h"
#include "stdbool.h"
#if CONFIG_W5100S_SPI_ETHERNET > 0
#include "../Telecom/eth/W5100S/wizchip_conf.h"
#endif
#include "../Telecom/eth/W5100S/wizchip_conf.h"
#include "mb.h"
#include "ts_iot01b.h"
...
...
@@ -120,25 +123,73 @@ typedef struct {
#endif
typedef
enum
{
IDEL
=
0
,
// 空闲,必须第一位,防止清空flash之后,初始化错误
POWER_ON
=
1
,
// 上电应答
CONFIG_THR
=
2
,
// 配置阈值状态
DETECTING
=
3
,
// 检测获取数据工作
PUSH
=
4
,
// 正常上报MQTT
MISSING
=
5
,
// 失联
STOP
=
6
}
IOT_STATUS
;
typedef
enum
{
LEVEL_UNKNOWN
=
0
,
// 未知状态
LEVEL_0
,
// 轻度损耗
LEVEL_1
,
// 中度损伤
LEVEL_2
,
// 重度损伤
LEVEL_3
,
// 停止使用
}
LEVEL
;
typedef
enum
{
NO_WORKING
=
0
,
WORKING
,
SENSOR_FINE
,
SENSOR_ERROR
}
IOT_WORK_STATUS_RESP
;
#define ALIAS_MAX_NAME_LENGTH 8
//配置数据 (配置存储到内部FLASH --- 阈值与存储数据存储到外部FLASH)
typedef
struct
{
unsigned
short
addr
;
unsigned
short
id
;
unsigned
short
sn
;
bool
bIsTimeout
;
unsigned
short
id
;
unsigned
short
sn
;
char
alias
[
ALIAS_MAX_NAME_LENGTH
];
bool
bIsUsed
;
bool
bIsPlugIn
;
unsigned
int
rope_value
;
bool
beingWaiting
;
unsigned
char
status
;
}
IOTDev
;
bool
beingDataWaiting
;
bool
beingStopWaiting
;
bool
beingConfigWaiting
;
unsigned
long
g_ts
;
unsigned
short
rope_value
;
LEVEL
level
;
bool
emergency
;
IOT_STATUS
status_machine
;
unsigned
short
fifo_tail
;
unsigned
short
fifo_data
[
FIFO_SIZE
];
bool
bIsFull
;
unsigned
long
alarmRecord
;
}
wireRopeDev
;
typedef
struct
{
wireRopeDev
wireRopeDevs
[
EACH_GROUP_MAX_NUM
];
TimerHandle_t
pxDataSendTimer
;
bool
DataSendFlag
;
}
wireRopeGroup
;
typedef
struct
{
char
cModuleName
[
WIT_MODULE_NAME_MAX_SIZE
];
//模块名称
unsigned
long
ulModuleNameValue
;
//检查模块名是否配置过
unsigned
long
ulPeriod
;
//发送周期
unsigned
long
ulDataPeriod
;
//发送周期
unsigned
long
ulFeaturePeriod
;
//发送周期
unsigned
long
ulConfigureValue
;
//检查以上内容是否配置过
unsigned
long
ulSerialNumber
;
//序列号
unsigned
long
ulPackageID
;
//包ID
...
...
@@ -181,12 +232,9 @@ typedef struct
sSenTable
xSenTable
[
WIT_SENSOR_MAX_CONNECT_NUM
*
WIT_SENSOR_GROUP_MAX_NUM
];
unsigned
long
ulBleBinSize
;
unsigned
long
ulSenParmInfoValue
;
#if CONFIG_W5100S_SPI_ETHERNET > 0
wiz_NetInfo
g_xConfigIp
;
wiz_NetInfo
g_xConfigIp
;
unsigned
long
ulEthNetInfoValue
;
//检查以上信息是否配置过
#endif
IOTDev
my_IOTDev
[
IOTDEV_MAX_NUM
];
unsigned
long
my_IOTThreshold
;
wireRopeGroup
g_wireRopeGroup
[
WIREROPE_GROUP_MAX_NUM
];
#endif
}
WIT_Configure
;
...
...
@@ -254,11 +302,12 @@ bool WIT_GetMotorWork(unsigned char ucIndex);
unsigned
long
*
get_ulPort
(
void
);
char
*
sent_mqtt_ip
(
void
);
#endif
#if CONFIG_W5100S_SPI_ETHERNET > 0
//
#if CONFIG_W5100S_SPI_ETHERNET > 0
unsigned
long
get_status_dhcp
(
void
);
wiz_NetInfo
*
get_gw_eth_info
(
void
);
#endif
//
#endif
void
Message_Deal_Function
(
void
);
unsigned
long
getIotConnectNum
(
void
);
void
Sensor_Status_Machine
(
void
);
#endif
components/config/wit_config.h
View file @
d2b4ee17
...
...
@@ -11,8 +11,8 @@ extern "C"
#define TAG "Witium"
//软件版本号
#define WIT_VERSION "1.0
0
"
#define WIT_VERSION_HEX 0x010
0
#define WIT_VERSION "1.0
1
"
#define WIT_VERSION_HEX 0x010
1
//此宏直接在下载正式程序用
#define WIT_FIXED_MODULE_NAME 1
...
...
@@ -84,6 +84,9 @@ extern "C"
#define WIT_MAX_TIME (0xFFFFFED8) // MOTT上发最大时长
#define WIT_ALARM_COUNT_THRESHOLD 5 // 预警N次才上报预警
#define WIT_FEATURE_PERIOD (15 * 60 * 1000)
#define WIT_DATA_PERIOD (15 * 60 * 1000)
#ifdef __cplusplus
}
#endif
...
...
components/eth_parsing/ts_iot01b.c
View file @
d2b4ee17
...
...
@@ -100,7 +100,15 @@ bool ACK_0AH(unsigned short id, unsigned short sn)
unsigned
char
cmd
=
0x0A
;
unsigned
char
data_size
=
0x01
;
unsigned
char
data
[
1
]
=
{
0x01
};
printf
(
"Send 0x0A
\n
"
);
return
Response_Package
(
id
,
sn
,
cmd
,
data_size
,
data
);
}
//68 00 3F 00 01 68 0C 01 02 1F 16
bool
InquireStatus
(
unsigned
short
id
,
unsigned
short
sn
)
{
unsigned
char
cmd
=
0x0C
;
unsigned
char
data_size
=
0x01
;
unsigned
char
data
[
1
]
=
{
0x02
};
return
Response_Package
(
id
,
sn
,
cmd
,
data_size
,
data
);
}
...
...
@@ -109,7 +117,7 @@ bool Start_Detect(unsigned short id, unsigned short sn)
unsigned
char
cmd
=
0x04
;
unsigned
char
data_size
=
0x01
;
unsigned
char
data
[
1
]
=
{
0x00
};
printf
(
"Send Start_Detect
\n
"
);
//
printf("Send Start_Detect\n");
return
Response_Package
(
id
,
sn
,
cmd
,
data_size
,
data
);
}
...
...
@@ -123,7 +131,7 @@ bool Stop_Detect(unsigned short id, unsigned short sn)
unsigned
char
cmd
=
0x06
;
unsigned
char
data_size
=
0x01
;
unsigned
char
data
[
1
]
=
{
0x00
};
printf
(
"Send Stop_Detect
\n
"
);
//
printf("Send Stop_Detect\n");
return
Response_Package
(
id
,
sn
,
cmd
,
data_size
,
data
);
}
...
...
@@ -194,7 +202,7 @@ bool data_frame_parsing(unsigned char *buf, int len, sIOT01B_Format* data)
// basic check
if
(
data
->
ucHeader
!=
0x68
||
data
->
ucTail
!=
0x16
)
{
printf
(
"Header or Tail Error.
\n
"
);
// printf("Header[%2x] & Tail[%2x] Error.\n", data->ucHeader, data->ucTail
);
return
false
;
}
...
...
@@ -231,3 +239,84 @@ eIOT01B_Info IOT01B_Get_Collect_Data(sIOT01B_Format *df, unsigned short *value)
return
EIOT01B_OK
;
}
void
queueInitFifo
(
unsigned
short
*
fifo_tail
,
unsigned
short
fifo_data
[],
bool
*
isFull
)
{
(
*
fifo_tail
)
=
0
;
for
(
unsigned
short
i
=
0
;
i
<
FIFO_SIZE
;
i
++
)
{
fifo_data
[
i
]
=
0
;
}
(
*
isFull
)
=
false
;
}
unsigned
short
calculateAverage
(
unsigned
short
fifo_data
[],
bool
isFull
)
{
if
(
isFull
!=
true
)
return
0
;
unsigned
short
sum
=
0
;
for
(
int
i
=
0
;
i
<
FIFO_SIZE
;
i
++
)
{
sum
+=
fifo_data
[
i
];
}
printf
(
"sum: %d
\n
"
,
sum
);
return
sum
/
FIFO_SIZE
;
}
void
enqueueDataFifo
(
unsigned
short
*
fifo_tail
,
unsigned
short
*
fifo_data
,
int
data
,
bool
*
isFull
)
{
fifo_data
[(
*
fifo_tail
)]
=
data
;
(
*
fifo_tail
)
=
(
*
fifo_tail
)
+
1
;
if
((
*
fifo_tail
)
>=
FIFO_SIZE
)
{
(
*
fifo_tail
)
=
0
;
*
isFull
=
true
;
// printf("\n");
// for(int i = 0; i< FIFO_SIZE; i++)
// {
// printf("%d ", fifo_data[i]);
// }
// printf("\n");
}
}
unsigned
short
maxDataWireRope
(
unsigned
short
fifo_data
[],
bool
isFull
)
{
if
(
isFull
!=
true
)
return
0
;
int
max
=
0
;
for
(
int
i
=
0
;
i
<
FIFO_SIZE
;
i
++
)
{
if
(
fifo_data
[
i
]
>
max
)
{
max
=
fifo_data
[
i
];
}
}
return
max
;
}
int
getAlarm
(
int
alarmRecord
,
bool
isFull
)
{
if
(
isFull
!=
true
)
return
0
;
return
(
alarmRecord
);
}
void
setAlarm
(
unsigned
long
*
alarmRecord
)
{
if
((
*
alarmRecord
)
>=
999999
)
{
(
*
alarmRecord
)
=
999999
;
}
else
{
(
*
alarmRecord
)
++
;
}
}
components/eth_parsing/ts_iot01b.h
View file @
d2b4ee17
...
...
@@ -3,16 +3,19 @@
#include <stdint.h>
#include <stdbool.h>
// Slave Command
#define SLAVE_POWER_ON_CONTACK 0x01
#define SLAVE_ACK 0x03
#define SLAVE_HEARTBEAT 0x05
#define SLAVE_LINE_DETECT_DATA 0x07
#define SLAVE_RES_SYS_PARAMETER 0x09
#define WIREROPE_CMD_WAIT_AWAKE 0x01
#define WIREROPE_CMD_ACK_OR_NACK 0x03
#define WIREROPE_CMD_HEARTBEAT 0x05
#define WIREROPE_CMD_DATA_PERCENT 0x07
#define WIREROPE_CMD_SYSTEM_PARAM 0x09
#define WIREROPE_CMD_WORK_STATUS_MESSAGE 0x0B
#define WIREROPE_CMD_WORK_PARAM 0x0D
// Master Command
#define MASTER_ACK 0x0A
#define MASTER_START_DETECT 0x04
#define MASTER_ACK
0x0A
#define MASTER_START_DETECT
0x04
// Frame Define
...
...
@@ -21,10 +24,14 @@
#define FRAME_TAIL 0x16
#define TCP_MESSAGE_MAX_LEN 256
#define TCP_MESSAGE_MAX_LEN 280
#define EACH_GROUP_MAX_NUM 4
#define WIREROPE_GROUP_MAX_NUM 2
#define IOTDEV_MAX_NUM 10
#define FIFO_SIZE 100
typedef
enum
{
EIOT01B_OK
=
0
,
...
...
@@ -65,12 +72,13 @@ eIOT01B_Info IOT01B_Set_Stop_Collect(unsigned long ulDevId);
eIOT01B_Info
IOT01B_Get_Collect_Data
(
sIOT01B_Format
*
df
,
unsigned
short
*
value
);
eIOT01B_Info
IOT01B_Data_Parsing
(
void
*
ulData
,
unsigned
short
usSize
);
void
Message_Deal_Start_T
ask
(
void
);
void
message_deal_start_t
ask
(
void
);
void
message_hex
(
unsigned
char
*
buf
,
unsigned
short
len
);
bool
Message_Send
(
uint8_t
*
smessage
,
int
len
);
bool
data_frame_parsing
(
unsigned
char
*
buf
,
int
len
,
sIOT01B_Format
*
data
);
eIOT01B_Info
IOT01B_Data_Parsing
(
void
*
ulData
,
unsigned
short
usSize
);
bool
ACK_0AH
(
unsigned
short
id
,
unsigned
short
sn
);
bool
InquireStatus
(
unsigned
short
id
,
unsigned
short
sn
);
bool
Set_Threshold
(
unsigned
short
id
,
unsigned
short
sn
,
unsigned
short
threshold
);
bool
Start_Detect
(
unsigned
short
id
,
unsigned
short
sn
);
bool
Stop_Detect
(
unsigned
short
id
,
unsigned
short
sn
);
...
...
@@ -78,6 +86,12 @@ void Get_SensorIOT_Data(unsigned short id, unsigned short sn);
void
IOT_SetConfig
();
// unsigned long getIotConnectNum(void);
void
queueInitFifo
(
unsigned
short
*
fifo_tail
,
unsigned
short
fifo_data
[],
bool
*
isFull
);
unsigned
short
calculateAverage
(
unsigned
short
fifo_data
[],
bool
isFull
)
;
unsigned
short
maxDataWireRope
(
unsigned
short
fifo_data
[],
bool
isFull
)
;
int
getAlarm
(
int
alarmRecord
,
bool
isFull
);
void
setAlarm
(
unsigned
long
*
alarmRecord
);
void
enqueueDataFifo
(
unsigned
short
*
fifo_tail
,
unsigned
short
*
fifo_data
,
int
data
,
bool
*
isFull
)
;
...
...
components/infa/APP/httputil.c
View file @
d2b4ee17
...
...
@@ -36,6 +36,8 @@ extern uint8 pub_buf[1024];
void
ReadData
(
void
);
static
void
make_basic_config_setting_json_callback
(
int8
*
buf
,
CONFIG_MSG
config_msg
)
{
sprintf
(
buf
,
"settingsCallback({
\"
ver
\"
:
\"
%X.%02X
\"
,\
...
...
@@ -224,9 +226,9 @@ void WriteData(CONFIG_MSG *config, uint16_t length)
wiz_NetInfo
*
eth_info
=
NULL
;
unsigned
long
*
value
=
NULL
;
char
*
mqtt_ip
=
NULL
;
#if CONFIG_W5100S_SPI_ETHERNET > 0
//
#if CONFIG_W5100S_SPI_ETHERNET > 0
eth_info
=
get_gw_eth_info
();
#endif
//
#endif
value
=
get_ulPort
();
mqtt_ip
=
sent_mqtt_ip
();
if
(
eth_info
==
NULL
||
value
==
NULL
||
mqtt_ip
==
NULL
)
...
...
@@ -268,9 +270,9 @@ void ReadData(void)
ConfigMsg
.
mqttport
[
0
]
=
*
value
%
256
;
ConfigMsg
.
mqttport
[
1
]
=
*
value
/
256
;
#if CONFIG_W5100S_SPI_ETHERNET > 0
//
#if CONFIG_W5100S_SPI_ETHERNET > 0
ConfigMsg
.
dhcpconfig
=
get_status_dhcp
();
#endif
//
#endif
ConfigMsg
.
dhcpconfig
-=
1
;
printf
(
"IP, GW and Subnet updated successfully in gWIZNETINFO.
\r\n
"
);
...
...
components/infa/APP/tcp_server.c
View file @
d2b4ee17
...
...
@@ -18,7 +18,9 @@
#include "socket.h"
#include "wizchip_conf.h"
#include "w5100s_conf.h"
#include "eth.h"
#if CONFIG_W5100S_SPI_ETHERNET > 0
#include "eth.h"
#endif
#include "ts_iot01b.h"
#include "freertos/FreeRTOS.h"
...
...
@@ -34,28 +36,24 @@ uint16 local_port = 11111; // 定义本地端口11111
uint8_t
g_IOTBuffer
[
200
];
Tcp_Message
g_Tcp_Message
;
extern
QueueHandle_t
xMessageQueueHandle
;
TimerHandle_t
xSensorTimer
=
NULL
;
TimerHandle_t
xSensorData
Fresh
Timer
=
NULL
;
TimerHandle_t
xSensorTime
outTime
r
=
NULL
;
TimerHandle_t
xSensorData
Update
Timer
=
NULL
;
TCP_STATUS
g_TcpServerStatus
=
TCP_SERVER_SOCKET_CLOSE
;
extern
TimerHandle_t
g_xDataSendTimer
[];
void
do_tcp_server
(
void
)
{
uint8_t
count
=
0
;
my_socket
(
2
,
Sn_MR_TCP
,
11111
,
0
);
uint8_t
ret
;
uint16
len
;
portBASE_TYPE
ret_pB
;
// my_socket(2, Sn_MR_TCP, 11111, 0);
while
(
1
)
{
uint16
len
=
0
;
uint8_t
ret
=
getSn_SR
(
SOCK_TCPS
);
count
++
;
if
(
count
==
500
)
{
count
=
0
;
printf
(
">>>>>getSn_SR %d
\n
"
,
ret
);
}
// printf(" getSn_SR %d\n",ret);
len
=
0
;
ret
=
getSn_SR
(
SOCK_TCPS
);
switch
(
ret
)
// 获取socket的状态
{
case
SOCK_CLOSED
:
// socket处于关闭状态
...
...
@@ -82,18 +80,24 @@ void do_tcp_server(void)
len
=
getSn_RX_RSR
(
SOCK_TCPS
);
// 定义len为已接收数据的长度
if
(
len
>
0
)
{
if
(
len
>
2
56
)
if
(
len
>
2
80
)
{
len
=
256
;
len
=
265
;
}
recv
(
SOCK_TCPS
,
g_Tcp_Message
.
message
,
len
);
// 接收来自Client的数据
g_Tcp_Message
.
rec_len
=
len
;
// 添加字符串结束符
// printf("sock receive len[%d]: %s\n", g_Tcp_Message.rec_len, g_Tcp_Message.message);
if
(
xMessageQueueHandle
!=
NULL
)
{
xQueueSend
(
xMessageQueueHandle
,
&
g_Tcp_Message
,
0
);
// disconnect(SOCK_TCPS); // 断开当前TCP连接
// close(SOCK_TCPS); // 关闭当前所使用socket
ret_pB
=
xQueueSend
(
xMessageQueueHandle
,
&
g_Tcp_Message
,
0
);
// 将数据发送到消息队列中
if
(
ret_pB
==
pdTRUE
)
{
// printf("xQSend OK\n");
}
else
printf
(
"xQSend Exx
\n
"
);
}
else
{
...
...
@@ -129,7 +133,7 @@ bool Message_Send(uint8_t *smessage, int len)
}
else
{
printf
(
"TCP SERVER DISCONNECT!!!
\n
TCP_SERVER_STATUS is [%d
]
\n
"
,
g_TcpServerStatus
);
// printf("No Client ESTABLISHED [%x
]\n", g_TcpServerStatus);
return
false
;
}
}
...
...
@@ -137,14 +141,18 @@ bool Message_Send(uint8_t *smessage, int len)
void
tcp_server_task_start
(
void
)
{
printf
(
"
tcp_server_task START
\n
"
);
printf
(
"
1 start
\n
"
);
xTaskCreate
(
do_tcp_server
,
"tcp_server_task"
,
2048
,
NULL
,
5
,
NULL
);
}
void
Message_Deal_Start_T
ask
(
void
)
void
message_deal_start_t
ask
(
void
)
{
printf
(
"Message_Deal_Task START
\n
"
);
xMessageQueueHandle
=
xQueueCreate
(
40
,
sizeof
(
Tcp_Message
));
xTaskCreate
(
Message_Deal_Function
,
"Message_Deal_Function"
,
8192
,
NULL
,
5
,
NULL
);
printf
(
"2 start
\n
"
);
while
(
xMessageQueueHandle
==
NULL
)
{
xMessageQueueHandle
=
xQueueCreate
(
100
,
sizeof
(
Tcp_Message
));
}
xTaskCreate
(
Sensor_Status_Machine
,
"StatusMachine"
,
5120
,
NULL
,
5
,
NULL
);
xTaskCreate
(
Message_Deal_Function
,
"MessageDealFunction"
,
10240
,
NULL
,
5
,
NULL
);
}
components/infa/eth/w5100s_conf.c
View file @
d2b4ee17
...
...
@@ -22,7 +22,9 @@
#include "driver/gpio.h"
#include "spi.h"
#include "esp_rom_gpio.h"
#include "eth.h"
#if CONFIG_W5100S_SPI_ETHERNET > 0
#include "eth.h"
#endif
#include "wit.h"
#include "freertos/FreeRTOS.h"
...
...
@@ -74,7 +76,9 @@ void ETHERNET_Init(bool *bModuleStatus, bool *bCableStatus)
vTaskDelay
(
2000
/
portTICK_PERIOD_MS
);
}
// hw_ping_init();
if_eth_task_init
();
#if CONFIG_W5100S_SPI_ETHERNET > 0
if_eth_task_init
();
#endif
}
/**
...
...
components/infa/generation/Celluar/celluar_gpio.c
View file @
d2b4ee17
...
...
@@ -12,7 +12,7 @@
/* Private macros ------------------------------------------------------------*/
#define CELLUAR_POWER_KEY_PIN 1
#define CELLUAR_STATUS_PIN 38
#define POWER_KEY_PIN
46
#define POWER_KEY_PIN
3
#define CELLUAR_POWER_BASE_TIME 500 //500ms
...
...
@@ -26,8 +26,8 @@ void Celluar_ConfigureGPIO(void)
esp_rom_gpio_pad_select_gpio
(
CELLUAR_STATUS_PIN
);
gpio_set_direction
(
CELLUAR_STATUS_PIN
,
GPIO_MODE_INPUT
);
//
// POWER_KEY_PIN
//
esp_rom_gpio_pad_select_gpio(POWER_KEY_PIN); // 选择个GPIO
//
gpio_set_direction(POWER_KEY_PIN, GPIO_MODE_OUTPUT); // 把这个GPIO作为输出
esp_rom_gpio_pad_select_gpio
(
POWER_KEY_PIN
);
// 选择个GPIO
gpio_set_direction
(
POWER_KEY_PIN
,
GPIO_MODE_OUTPUT
);
// 把这个GPIO作为输出
gpio_set_level
(
POWER_KEY_PIN
,
1
);
// // EC20 PWR设置
...
...
components/infa/generation/Celluar/celluar_usb.c
View file @
d2b4ee17
...
...
@@ -98,7 +98,7 @@ void Celluar_ConfigureUSB(void (*pFuncIdleCallBack)(void), void (*pFuncRxneCallB
{
usbh_cdc_driver_install
(
&
config
);
/* Waiting for USB device connected */
usbh_cdc_wait_connect
(
portMAX_DELAY
);
usbh_cdc_wait_connect
(
5000
);
g_xUSBHandler
.
pFuncRxneHandler
=
pFuncRxneCallBack
;
g_xUSBHandler
.
pFuncIdleHandler
=
pFuncIdleCallBack
;
gUSBSemaphore
=
xSemaphoreCreateBinary
();
...
...
main/app_main.c
View file @
d2b4ee17
...
...
@@ -21,25 +21,22 @@
#include "freertos/queue.h"
#include "wit.h"
#if CONFIG_W5100S_SPI_ETHERNET > 0
#include "httputil.h"
#endif
#define MAIN_TASK_STK (configMINIMAL_STACK_SIZE * 10)
#define MAIN_TASK_PRIORITY (tskIDLE_PRIORITY + 3)
#if CONFIG_W5100S_SPI_ETHERNET > 0
#define HTTP_TASK_STK (configMINIMAL_STACK_SIZE * 20)
#define HTTP_TASK_PRIORITY (tskIDLE_PRIORITY + 2)
#endif
#define TWDT_TIMEOUT_S 3 // TWDT超时时间
#define TASK_RESET_PERIOD_S 2 // 任务重置周期时间
static
void
Main_Task
(
void
*
pvParameter
);
#if CONFIG_W5100S_SPI_ETHERNET > 0
static
void
Http_Task
(
void
*
pvParameter
);
#endif
static
void
Http_Task
(
void
*
pvParameter
);
static
int
bWITInitFin
=
0
;
...
...
@@ -48,9 +45,7 @@ void app_main(void)
int
rc
=
0
;
ESP_ERROR_CHECK
(
nvs_flash_init
());
xTaskCreate
(
Main_Task
,
"Main Task"
,
MAIN_TASK_STK
,
NULL
,
MAIN_TASK_PRIORITY
,
NULL
);
#if CONFIG_W5100S_SPI_ETHERNET > 0
rc
=
xTaskCreate
(
Http_Task
,
"Http Task"
,
HTTP_TASK_STK
,
NULL
,
HTTP_TASK_PRIORITY
,
NULL
);
#endif
printf
(
"rc is %d
\r\n
"
,
rc
);
}
...
...
@@ -68,11 +63,10 @@ static void Main_Task(void *pvParameter)
vTaskDelay
(
20
/
portTICK_PERIOD_MS
);
}
}
#if CONFIG_W5100S_SPI_ETHERNET > 0
static
void
Http_Task
(
void
*
pvParameter
)
{
//Init
// printf("Enter Http Task\n");
while
(
1
)
{
if
(
bWITInitFin
==
1
)
...
...
@@ -82,4 +76,4 @@ static void Http_Task(void *pvParameter)
vTaskDelay
(
1
/
portTICK_PERIOD_MS
);
}
}
#endif
sdkconfig
View file @
d2b4ee17
...
...
@@ -471,8 +471,8 @@ CONFIG_PARTITION_TABLE_MD5=y
# Witium Gateway Configure
#
# CONFIG_ESP32_WIFI is not set
# CONFIG_EC200S_USB_4G is not set
CONFIG_W5100S_SPI_ETHERNET=y
CONFIG_EC200S_USB_4G=y
# CONFIG_W5100S_SPI_ETHERNET is not set
# CONFIG_RS485_RTU is not set
CONFIG_BLUETOOTH=y
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment