[RVB2601 Creative Application Development] Project Talk
[Copy link]
This post was last edited by lugl4313820 on 2022-4-2 21:47
[Thanks] Special thanks to @xinmeng_wit , his post [New Reminder] [Pingtou Ge RVB2601 Creative Application Development] 3. WiFi Network Communication - Pingtou Ge RISC-V RVB2601 Activity Zone - Electronic Engineering World - Forum (eeworld.com.cn) , helped me understand how to write WiFi reception callback functions and register command functions. Thanks again.
[Miscellaneous] This time I participated in Pingtou Ge's creative activity. My idea was to make a management system for temperature monitoring of cold storage, because an important part of my business is to manage the temperature of vaccines in cold storage and refrigerators (everyone has received the new crown vaccine, right?). I entered the field of single-chip microcomputers because I wanted to do temperature monitoring. At that time, one temperature cost several thousand yuan, and there was no funding at the time, so I thought about doing it myself. As a result, 5 years have passed, and I haven't done it yet. Although the finished product has been made, it cannot be promoted. First of all, this industry does not mean that your product is good and the price is cheap, you can launch it. But I still insist on making a smarter product, even if it may die before it is born.
The first idea was to use wifi (ESP8266) to collect data and send it to the server through the local area network. In fact, this solution was approved and was also used for free by several brother units. However, the battery of ESP8266 cannot be solved. In addition, the refrigerator is made of iron, and the signal is unstable, especially in the cold storage, which is made of iron on all sides. Later, in order to control power consumption, I learned stm8L and used it to shut down ESP8266 at a fixed time. This was also achieved, but due to work transfer, I was no longer responsible for the vaccine. Later, because the temperature was too accurate, the comrade in charge often received alarms, so he was killed and the project was stopped.
In 2020, due to the COVID-19 pandemic, I returned to the vaccine management position. The implementation of the Vaccine Management Law further strengthened the vaccine management requirements, but when I returned, I also equipped an online vaccine temperature monitoring system. Of course, the price is also shockingly expensive, but the existing temperature monitoring is still just simple temperature monitoring, and power supply monitoring management has not been introduced.
My idea is to increase the monitoring of the power supply, monitor the voltage and current of the power supply, and inform the user in advance in case of power outage or equipment not operating, so as to avoid alarm information due to temperature out of control.
[Difficulties encountered so far] I liked this development board because it had wifi and a screen, and I thought it would be easy to implement. But when I got the development board and wanted to combine lVGL+WIFI, it showed insufficient memory and insufficient serial ports. It was far from what I imagined, or maybe I was too young. And there are very few learning resources for this board.
A few days ago, the administrator kindly reminded me to speed up the progress of the project. I felt a lot of pressure and had thoughts of giving up.
But looking back, I decided to find a way to overcome the difficulties and keep going.
Today is a holiday. I got up in the morning and calmed down to open hello world and started to study the original code. At the same time, I also went to Pingtou Ge to learn the basic concepts of Yoc. In the morning, I sorted out some basic concepts such as system initialization.
Let's get to the point. Here is some information about sending and receiving Wi-Fi:
Actually, I also knew that the address for configuring the network connection is network_init(). I also wrote a post at that time, how to connect to the network. After learning from @ xinmeng_wit 's article, I learned how to add the callback function for receiving data:
static void network_init()
{
w800_wifi_param_t w800_param;
/* init wifi driver and network */
w800_param.reset_pin = PA21;
w800_param.baud = 1*1000000;
w800_param.cs_pin = PA15;
w800_param.wakeup_pin = PA25;
w800_param.int_pin = PA22;
w800_param.channel_id = 0;
w800_param.buffer_size = 4*1024;
wifi_w800_register(NULL, &w800_param);
app_netmgr_hdl = netmgr_dev_wifi_init();
if (app_netmgr_hdl) {
utask_t *task = utask_new("netmgr", 2 * 1024, QUEUE_MSG_COUNT, AOS_DEFAULT_APP_PRI);
netmgr_service_init(task);
netmgr_config_wifi(app_netmgr_hdl, "HUAWEI-myssid", sizeof("HUAWEI-myssid"), "mypasswd...", sizeof("mypasswd..."));//配置上网,当然这个在后面需要改正的地方,不知道有没有象esp8266一样有用手机配网的方法
w800_packet_input_cb_register(&w800_data_receive_callback);//就是这里加入接收到数据的回调函数!!!
netmgr_start(app_netmgr_hdl);
}
}
Then there is the command sent in the function increment after obtaining the IP registered in the main function:
static void network_event(uint32_t event_id, const void *param, void *context)
{
switch(event_id) {
case EVENT_NETMGR_GOT_IP:
LOGD(TAG, "net got ip");
connect_tcp_server("192.168.3.192",3333);//这里在取得IP后发送一条指令
break;
case EVENT_NETMGR_NET_DISCON:
LOGD(TAG, "net disconnect");
break;
}
/*do exception process */
app_exception_event(event_id);
}
In fact, if you want to send data in the following projects, just execute this command.
Then the command to register the console is added under ..\my_pro\__workspace_pack__\sal\v7.4.3\cli\cl_ping.c:
int cli_reg_cmd_at(void)
{
static const struct cli_command at_cmd_info = {
"tcp_client_test",
"tcp client test",
cmd_at_client_handler,
};
aos_cli_register_command(&at_cmd_info);//注册控制台命令。
return 0;
}
//在以后的发送数据中使用这条指令
static void cmd_at_client_handler(char *wbuf, int wbuf_len, int argc, char **argv)
{
const uint8_t pdata[] = "Hello RVB2601!\r\n";
int len = sizeof(pdata);
int timeout=120;
w800_send_data(pdata, len, timeout);
}
At this point, the sending and receiving of TCP data has basically been completed, but there is still a question, how to POST and MQTT data, this road is still long, I hope everyone can guide me, please!
|