1396 views|6 replies

6822

Posts

11

Resources
The OP
 

[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!

Latest reply

It is indeed necessary to prepare some knowledge for POST and MQTT data   Details Published on 2022-4-2 21:47
 
 

6565

Posts

0

Resources
2
 

It is indeed necessary to prepare some knowledge for POST and MQTT data

Comments

To achieve communication, you need to use AT primitive commands. Tomorrow I will see if w800 has MQTT commands. If you are not afraid, just use the serial port to connect to NB-IOT, and w800 will let him game over   Details Published on 2022-4-2 21:49
 
 
 

6822

Posts

11

Resources
3
 
This post was last edited by lugl4313820 on 2022-4-2 21:51
Jacktang published on 2022-4-2 21:47 It is indeed necessary to prepare some knowledge for POST and MQTT data

Maybe it needs to be implemented through AT original commands. Tomorrow I will see if w800 has MQTT commands. If not, I will just use the serial port to connect to NB-IOT, and w800 will let him game over.

 
 
 

6822

Posts

11

Resources
4
 

int w800_at0(void)
{
int ret = -1;
int count = 3;

aos_mutex_lock(&g_cmd_mutex, AOS_WAIT_FOREVER);

atparser_clr_buf(g_atparser_uservice_t);

if (atparser_send(g_atparser_uservice_t, "AT") == 0) {
while (count --) {
if (atparser_recv(g_atparser_uservice_t, "OK\n") == 0) {
ret = 0;
break;
}
}
}

atparser_cmd_exit(g_atparser_uservice_t);

aos_mutex_unlock(&g_cmd_mutex);

return ret;
}

You may need to refer to this example and write a function yourself to implement it. You can't find the AT command set of w800.

 
 
 

6822

Posts

11

Resources
5
 
 
 

6822

Posts

11

Resources
6
 

GPIO · GitBook (t-head.cn) Here is Yoc's user manual.

 
 
 

6822

Posts

11

Resources
7
 

Is the Bluetooth of this development board w800 open for use? If it has Bluetooth, that would be great. It would be convenient to configure the network and everything.

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list