【XR806开发板试用】基于MQTT与Cjson库的花式点灯

一、项目介绍

久闻openharmony大名,一直没有机会接触,感谢极术社区和全志社区的这次活动,让我能够了解并上手这个系统。

openhamony 1.1的内核是基于liteos内核系统进行构建的,liteos作为物联网系统,结合xr806小型开发板,特别适合用于构建iot项目,同时openharmony拥有丰富的中间件,使得开发变得容易,因此考虑结合mqtt与cjson这两个iot开发过程中必不可少的两项技术来进行花式点灯。下图是xr806的配置图。

在这里插入图片描述

二、环境准备

1、mqtt系统搭建

MQTT协议作为一种轻量、简单、开放和易于实现的协议,由服务端与客户端构成,客户端负责发布与订阅消息,服务端则负责完成客户端的管理与设备间的信息交互。本项目中就是通过云服务器来实现pc与开发板间的交互。

1.1、客户端(开发板)

本项目使用所提供的开发包中的mqtt例程进行改写的,该例程调用Eclipse Paho MQTT开发库进行编写,使用MQTTClient-C库,将开发板作为客户端。可以在该目录下找到例程。

harmony\device\xradio\xr806\xr\_skylark\project\example\mqtt

1.2、客户端(PC)

本项目中使用MQTT.fx软件来作为PC的客户端,MQTT.fx是一款也是基于Eclipse Paho库的软件,通过配置后与服务端进行交互。主界面如下图所示,通过添加服务器的地址来与服务器进行交互。
在这里插入图片描述
在这里插入图片描述

.png")

1.3、服务端

本项目中服务端使用阿里云服务器进行mqtt服务端搭建,有云服务器的小伙伴可以参考这篇文章。

https://blog.csdn.net/qq\_45168614/article/details/107183583

没有云服务可以使用阿里云或者腾讯云的提供的物联网服务,也提供了mqtt服务器的功能,并且功能更加强大。

mqtt服务端的界面如下图所示。
在这里插入图片描述
.png")

三、代码编写

main.c代码如下:

/** Copyright (C) 2017 XRADIO TECHNOLOGY CO., LTD. All rights reserved.**  Redistribution and use in source and binary forms, with or without*  modification, are permitted provided that the following conditions*  are met:*    1. Redistributions of source code must retain the above copyright*       notice, this list of conditions and the following disclaimer.*    2. Redistributions in binary form must reproduce the above copyright*       notice, this list of conditions and the following disclaimer in the*       documentation and/or other materials provided with the*       distribution.*    3. Neither the name of XRADIO TECHNOLOGY CO., LTD. nor the names of*       its contributors may be used to endorse or promote products derived*       from this software without specific prior written permission.**  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/#include <stdio.h>
#include <stdlib.h>
#include "ohos_init.h"
#include "kernel/os/os.h"
#include <string.h>
#include "wifi_device.h"
#include "wifi_hotspot.h"
#include "cjson/cJSON.h"
#include "common/framework/platform_init.h"
#include "net/wlan/wlan.h"
#include "common/framework/net_ctrl.h"
#include "net/mqtt/MQTTClient-C/MQTTClient.h"
#include "iot_gpio.h"                                                           //(8)#define MQTT_DEMO_THREAD_STACK_SIZE (8 * 1024) /* ssl need more stack */
static OS_Thread_t mqtt_demo_thread;
static OS_Thread_t blink_thread;static MQTTPacket_connectData mqtt_demo_connectData = MQTTPacket_connectData_initializer;
static Client mqtt_demo_client;
static Network mqtt_demo_network;#define WIFI_DEVICE_CONNECT_AP_SSID "xtg2018" //填写wifi名称
#define WIFI_DEVICE_CONNECT_AP_PSK "xtg2018"  //填写wifi密码#define MQTT_DEMO_CLIENT_ID "IOT control"
#define MQTT_DEMO_HOST_NAME "xxx.xxx.xxx.xxx" //填写mqtt服务器地址
#define MQTT_DEMO_PORT      "1883"
#define MQTT_DEMO_USERNAME  "easitmickly"     //填写mqtt用户名
#define MQTT_DEMO_PASSWORD  ""                //填写mqtt密码
#define MQTT_DEMO_TOPIC     "/vo84Hm3xbUj/xr806_senor_set0/data"
#define MQTT_DEMO_TOPIC2    "/vo84Hm3xbUj/xr806_senor_set1/data"
#define GPIO_ID_PA21 21#define MQTT_DEMO_BUF_SIZE (2*1024)#define MQTT_DEMO_MSG_TEXT "mqtt demo test"
static OS_Thread_t g_main_thread;void wifi_scan_connect(){if(WIFI_SUCCESS != EnableWifi()){printf("Error:wifi enable fail!\n");return;}if(WIFI_SUCCESS != Scan()){printf("Error:wifi scan fail!\n");}printf("WIFI SCAN STARTED!\n");OS_Sleep(3);WifiScanInfo scan_result[30];unsigned int scan_num = 30;if(WIFI_SUCCESS != GetScanInfoList(scan_result, &scan_num)){printf("Error: get scan result fail!\n");return;}printf("Scan successful,you've got:\n");for(int i = 0;i < scan_num;i++){printf("SSID: %s ",scan_result[i].ssid);printf("RSSI: %d",scan_result[i].rssi);}printf("Scan End \n");const char ssid_want_connect[] = WIFI_DEVICE_CONNECT_AP_SSID;const char psk[] = WIFI_DEVICE_CONNECT_AP_PSK;printf("Connecting...");if(WIFI_STA_ACTIVE == IsWifiActive()){printf("Wifi is active.\n");}OS_Sleep(1);WifiDeviceConfig config = {0};int netId = 0;int i;for(i = 0;i < scan_num;i++){if(0 == strcmp(scan_result[i].ssid, ssid_want_connect)){memcpy(config.ssid, scan_result[i].ssid, WIFI_MAX_SSID_LEN);memcpy(config.bssid, scan_result[i].bssid, WIFI_MAC_LEN);strcpy(config.preSharedKey, psk);config.securityType = scan_result[i].securityType;config.wapiPskType = WIFI_PSK_TYPE_ASCII;config.freq = scan_result[i].frequency;break;}}if(i >= scan_num){printf("Error: No SSID SET FOUND!\n");return;}printf("Found Correct SSID in Scan List!\n");if(WIFI_SUCCESS != AddDeviceConfig(&config, &netId)){printf("Error: Add Device config failed!\n");return;}printf("Add Device Config successful!\n");if(WIFI_SUCCESS != ConnectTo(netId)){printf("Error: Connect to Wifi FAILED!\n");return;}printf("Connect to %s successful!\n",config.ssid);OS_Sleep(3);
}static int mqtt_demo_init(void)
{char *send_buf;char *recv_buf;/* init client id */mqtt_demo_connectData.clientID.cstring = MQTT_DEMO_CLIENT_ID;/* init keep alive interval */mqtt_demo_connectData.keepAliveInterval = 30; // 30s/* enable session reuse */mqtt_demo_connectData.cleansession = 0;/* set mqtt version */mqtt_demo_connectData.MQTTVersion = 4; //Version of MQTT 3.1.1/* send/recv buffer must free when mqtt deinit */send_buf = malloc(MQTT_DEMO_BUF_SIZE);if (send_buf == NULL) {printf("no memory\n");return -1;}recv_buf = malloc(MQTT_DEMO_BUF_SIZE);if (recv_buf == NULL) {free(send_buf);printf("no memory\n");return -1;}/* init network */NewNetwork(&mqtt_demo_network);/* init mqtt client object */MQTTClient(&mqtt_demo_client, &mqtt_demo_network, 6000,(unsigned char *)send_buf, MQTT_DEMO_BUF_SIZE,(unsigned char *)recv_buf, MQTT_DEMO_BUF_SIZE);/*** set will function, when this client disconnect,* server will sent the message to every client in MQTT_DEMO_TOPIC*/mqtt_demo_connectData.willFlag = 1;mqtt_demo_connectData.will.topicName.cstring = MQTT_DEMO_TOPIC;mqtt_demo_connectData.will.message.cstring = "I am disconnected";mqtt_demo_connectData.will.retained = 0;mqtt_demo_connectData.will.qos = 0;/* set username and password */mqtt_demo_connectData.username.cstring = MQTT_DEMO_USERNAME;mqtt_demo_connectData.password.cstring = MQTT_DEMO_PASSWORD;return 0;
}static int mqtt_demo_connect(char *host_name, char *host_port)
{int ret = -1;/* need connect the server in tcp level first, if use ssl, use TLSConnectNetwork() */ret = ConnectNetwork(&mqtt_demo_network, host_name, atoi(host_port));if (ret != 0) {printf("mqtt connect faild, ret:%d, host:%s, port:%s\n", ret, host_name, host_port);goto exit;}/* if tcp level connected, then connect mqtt level */ret = MQTTConnect(&mqtt_demo_client, &mqtt_demo_connectData);if (ret != 0) {printf("mqtt connect faild, ret:%d\n", ret);/* disconnect the tcp level */mqtt_demo_network.disconnect(&mqtt_demo_network);goto exit;}printf("mqtt connected\n");exit:return ret;
}static void mqtt_demo_msg_cb(MessageData *data)
{printf("get a message, topic: %.*s, msg: %.*s\n", data->topicName->lenstring.len,data->topicName->lenstring.data, data->message->payloadlen,(char *)data->message->payload);parse_json((char *)data->message->payload);
}void Led_blink(void *arg)
{int *pinter = (int *)arg;int inter = *pinter;printf("transport inter is %d\n", *pinter);while(1){IoTGpioSetOutputVal(GPIO_ID_PA21, 0);OS_MSleep(1000 * inter);IoTGpioSetOutputVal(GPIO_ID_PA21, 1);OS_MSleep(1000 * inter);}
}int parse_json(char *s)
{cJSON *root = cJSON_Parse(s);if(!root) {printf("get root faild !\n");return -1;}cJSON *js_list = cJSON_GetObjectItem(root, "list");if(!js_list) {printf("no list!\n");return -1;}printf("list type is %d\n",js_list->type);cJSON *pin = cJSON_GetObjectItem(js_list, "pin style");if(!pin) {printf("No pin style!\n");return -1;}printf("pin style is %s\n",pin->valuestring);cJSON *inter = cJSON_GetObjectItem(js_list, "inter");if(!inter) {printf("no inter!\n");return -1;}printf("inter is %d\n",inter->valueint);if(pin){OS_ThreadDelete(&blink_thread);if (0 == strcmp(pin->valuestring, "open")){IoTGpioSetOutputVal(GPIO_ID_PA21, 1);}else if(0 == strcmp(pin->valuestring, "close")){IoTGpioSetOutputVal(GPIO_ID_PA21, 0);}else if(0 == strcmp(pin->valuestring, "blink")){if(inter){if(OS_ThreadCreate(&blink_thread, "BlinkThread", Led_blink, &inter->valueint, OS_THREAD_PRIO_APP, 4 * 1024) != OS_OK){printf("[ERR] Create BlinkThread Failed\n");}}}else{printf("unknown pin style\n");}}if(root)cJSON_Delete(root);return 0;
}static int mqtt_demo_subscribe(char *topic)
{int ret = -1;if (mqtt_demo_client.isconnected) {/* set the message callback */ret = MQTTSubscribe(&mqtt_demo_client, topic, 0, mqtt_demo_msg_cb);if (ret != 0)printf("mqtt subscribe faild ret:%d\n", ret);}return ret;
}static int mqtt_demo_unsubscribe(char *topic)
{int ret = -1;if (mqtt_demo_client.isconnected) {ret = MQTTUnsubscribe(&mqtt_demo_client, topic);if (ret != 0)printf("mqtt unsubscribe faild, ret:%d\n", ret);}return ret;
}static int mqtt_demo_publish(char *topic, char *msg)
{int ret = -1;MQTTMessage message;memset(&message, 0, sizeof(message));message.qos = 0;message.retained = 0; /* disable retain the message in server */message.payload = msg;message.payloadlen = strlen(msg);ret = MQTTPublish(&mqtt_demo_client, topic, &message);if (ret != 0)printf("mqtt publish faild, ret:%d\n", ret);return ret;
}static int mqtt_demo_disconnect(void)
{int ret = -1;if (mqtt_demo_client.isconnected) {/* need disconnect mqtt level first */ret = MQTTDisconnect(&mqtt_demo_client);if (ret != 0)printf("mqtt disconnect fail, ret:%d\n", ret);/* then disconnect tcp level */mqtt_demo_network.disconnect(&mqtt_demo_network);}return ret;
}static void mqtt_demo_deinit(void)
{if (mqtt_demo_client.buf) {free(mqtt_demo_client.buf);mqtt_demo_client.buf = NULL;}if (mqtt_demo_client.readbuf) {free(mqtt_demo_client.readbuf);mqtt_demo_client.readbuf = NULL;}
}static void mqtt_demo_fun(void *arg)
{int ret;int reconnect_times = 0;/* mqtt init */mqtt_demo_init();/* mqtt connect */ret = mqtt_demo_connect(MQTT_DEMO_HOST_NAME, MQTT_DEMO_PORT);if (ret != 0)goto exit;/* subscribe topic */ret = mqtt_demo_subscribe(MQTT_DEMO_TOPIC2);if (ret != 0)goto exit;while (1) {/* publish message to topic */mqtt_demo_publish(MQTT_DEMO_TOPIC, MQTT_DEMO_MSG_TEXT);ret = MQTTYield(&mqtt_demo_client, 300);if (ret != 0) {printf("mqtt yield err, ret:%d\n", ret);
reconnect:printf("mqtt reconnect\n");mqtt_demo_disconnect();ret = mqtt_demo_connect(MQTT_DEMO_HOST_NAME, MQTT_DEMO_PORT);if (ret != 0) {reconnect_times++;if (reconnect_times > 5)goto exit;OS_MSleep(5000); //5sgoto reconnect;}}OS_MSleep(1000); //1s}exit:mqtt_demo_unsubscribe(MQTT_DEMO_TOPIC2);mqtt_demo_disconnect();mqtt_demo_deinit();OS_ThreadDelete(&mqtt_demo_thread);
}static void MainThread(void *arg)
{wifi_scan_connect();
}int main(void)
{IoTGpioInit(GPIO_ID_PA21);IoTGpioSetDir(GPIO_ID_PA21, IOT_GPIO_DIR_OUT);if(OS_ThreadCreate(&g_main_thread, "MainThread", MainThread, NULL, OS_THREAD_PRIO_APP, 4 * 1024) != OS_OK){printf("[ERR] Create MainThread Failed\n");}OS_MSleep(10000); //10sif (OS_ThreadCreate(&mqtt_demo_thread,"mqtt_demo_thread",mqtt_demo_fun,(void *)NULL,OS_THREAD_PRIO_APP,MQTT_DEMO_THREAD_STACK_SIZE) != OS_OK) {printf("[ERR] Create MainThread Failed\n");}}SYS_RUN(main);

build文件如下:

import("//device/xradio/xr806/liteos_m/config.gni")static_library("app_mqtt") {configs = []sources = ["main.c",]cflags = board_cflagsinclude_dirs = board_include_dirsinclude_dirs += [".","//kernel/liteos_m/kernel/arch/include","//base/iot_hardware/peripheral/interfaces/kits","//utils/native/lite/include","//foundation/communication/wifi_lite/interfaces/wifiservice","//device/xradio/xr806/xr_skylark/include/cjson","//device/xradio/xr806/xr_skylark/project"]
}

main.c代码使用mqtt例程与wifi例程中提供的函数,并调用cjson库。

    if(OS_ThreadCreate(&g_main_thread, "MainThread", MainThread, NULL, OS_THREAD_PRIO_APP, 4 * 1024) != OS_OK){printf("[ERR] Create MainThread Failed\n");}OS_MSleep(10000); //10sif (OS_ThreadCreate(&mqtt_demo_thread,"mqtt_demo_thread",mqtt_demo_fun,(void *)NULL,OS_THREAD_PRIO_APP,MQTT_DEMO_THREAD_STACK_SIZE) != OS_OK) {printf("[ERR] Create MainThread Failed\n");}

main函数中首先对led端口进行初始化,然后初始化wifi,延时10s使得wifi连接网络,最后进行mqtt连接。

int parse_json(char *s)
{cJSON *root = cJSON_Parse(s);if(!root) {printf("get root faild !\n");return -1;}cJSON *js_list = cJSON_GetObjectItem(root, "list");if(!js_list) {printf("no list!\n");return -1;}printf("list type is %d\n",js_list->type);cJSON *pin = cJSON_GetObjectItem(js_list, "pin style");if(!pin) {printf("No pin style!\n");return -1;}printf("pin style is %s\n",pin->valuestring);cJSON *inter = cJSON_GetObjectItem(js_list, "inter");if(!inter) {printf("no inter!\n");return -1;}printf("inter is %d\n",inter->valueint);if(pin){if (0 == strcmp(pin->valuestring, "open")){IoTGpioSetOutputVal(GPIO_ID_PA21, 1);}else if(0 == strcmp(pin->valuestring, "close")){IoTGpioSetOutputVal(GPIO_ID_PA21, 0);}else if(0 == strcmp(pin->valuestring, "blink")){if(inter){if(OS_ThreadDelete(&blink_thread)){printf("[ERR] Create OS_ThreadDelete BlinkThread Failed\n");}if(OS_ThreadCreate(&blink_thread, "BlinkThread", Led_blink, &inter->valueint, OS_THREAD_PRIO_APP, 4 * 1024) != OS_OK){printf("[ERR] Create BlinkThread Failed\n");}}}else{printf("unknown pin style\n");}}if(root)cJSON_Delete(root);return 0;
}

parse\_json函数对接受到的json消息进行解析,消息体中包含两个参数:点灯类型和跳动间隔。消息体如下:

{“list”:{“pin style”:“blink”,“inter”:3}}

pin style有三个参数:open、close和blink,而inter参数则在blink状态生效。当pin style参数为blink时,将进入Led\_blink线程,循环点灯。

四、效果展示

服务端展示的两个客户端状态如图所示:
在这里插入图片描述
.png")

pc端收到的开发板消息如下图:
在这里插入图片描述
.png")

开发板显示消息如下:

====================================================================Hello! OpenHarmony!System tag : OpenHarmony 1.1.2_LTS
====================================================================use default flash chip mJedec 0x0
[FD I]: mode: 0x10, freq: 96000000Hz, drv: 0
[FD I]: jedec: 0x0, suspend_support: 1
mode select:e[2022-01-22 13:28:55.546]# RECV ASCII>wlan information ===================================================
firmware:version : R0-XR_C07.08.52.65_02.84 May 27 2021 11:41:33-Y02.84 buffer  : 8
driver:version : XR_V02.05
mac address:in use        : 0c:6d:88:3d:34:01in use        : 0c:6d:88:3d:34:02
====================================================================wlan mode:a
[VFS INF] SPIFFS mount success.platform information ===============================================
XR806 SDK v1.2.0  Jan 19 2022 20:05:38heap space [0x229344, 0x247c00), size 125116cpu  clock 160000000 Hz
HF   clock  40000000 Hzsdk option:XIP           : enableINT LF OSC    : enableSIP flash     : enablemac address:efuse         : 80:74:84:05:b9:0ein use        : 0c:6d:88:3d:34:01
====================================================================IoTGpioInit port0, pin21
[net INF] no need to switch wlan mode 0
WIFI SCAN STARTED![2022-01-22 13:28:56.088]# RECV ASCII>
[net INF] msg <wlan scan success>[2022-01-22 13:28:58.579]# RECV ASCII>
Scan successful,you've got:
SSID: xtgy2018 RSSI: 122SSID: LUCIO_Wi-Fi5 RSSI: 42SSID: ChinaNet-KFVB6L RSSI: 38SSID: TP-LINK_shc RSSI: 34SSID: CMCC-V5xN RSSI: 32SSID: ziroom501 RSSI: 26SSID: ChinaNet-UnjV RSSI: 22SSID: ChinaNet-aDhv RSSI: 6SSID: CMCC-FSU6 RSSI: -2SSID: 201 RSSI: -6SSID:  RSSI: -16SSID: CMCC-d5Nj RSSI: -20Scan End 
Connecting...Wifi is active.[2022-01-22 13:28:59.593]# RECV ASCII>
Found Correct SSID in Scan List!
Add Device Config successful!
[net INF] no need to switch wlan mode 0[2022-01-22 13:29:00.354]# RECV ASCII>
en1: Trying to associate with cc:2d:21:86:4b:01 (SSID='xtg2018' freq=2437 MHz)
Connect to xtgy2018 successful![2022-01-22 13:29:00.512]# RECV ASCII>
en1: Associated with cc:2d:21:86:4b:01
en1: WPA: Key negotiation completed with cc:2d:21:86:4b:01 [PTK=CCMP GTK=TKIP]
en1: CTRL-EVENT-CONNECTED - Connection to cc:2d:21:86:4b:01 completed [id=0 id_str=]
[net INF] msg <wlan connected>
[net INF] netif is link up
[net INF] start DHCP...[2022-01-22 13:29:01.401]# RECV ASCII>
[net INF] netif (IPv4) is up
[net INF] address: 192.168.0.128
[net INF] gateway: 192.168.0.1
[net INF] netmask: 255.255.255.0
[net INF] msg <network IPv6 state>[2022-01-22 13:29:02.398]# RECV ASCII>
[net INF] IPv6 addr state change: 0x0 --> 0x1
[net INF] msg <>[2022-01-22 13:29:04.396]# RECV ASCII>
WAR drop=1117, fctl=0x00d0.[2022-01-22 13:29:05.536]# RECV ASCII>
hiview init success.
console init success[2022-01-22 13:29:05.631]# RECV ASCII>
mqtt connected[2022-01-22 13:29:14.784]# RECV ASCII>
get a message, topic: /vo84Hm3xbUj/xr806_senor_set1/data, msg: {"list":{"pin style":"blink","inter":3}}
list type is 64
pin style is blink
inter is 3
[os E] OS_ThreadDelete():110, handle 0
transport inter is 3

可以从消息中看出已经连接上了wifi与mqtt服务器,并接受到了从pc端发送的消息,视频演示如下:

https://www.bilibili.com/video/BV12q4y1A7zM/?aid=550751435&cid=489852768&page=1

可以看出已经达到想要的效果。

感谢阅读!感兴趣可以交流,谢谢。~~~~

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/8105.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Git】Commit后进行事务回滚

起因 因为一直使用git add .&#xff0c;在学习pytorch中添加了一个较大的数据集后&#xff0c;导致git push失败&#xff0c;而这个大数据集并不是必须要上传到仓库的&#xff0c;但是因为自己在设置.gitignore前已经进行了git comit&#xff0c;所以&#xff0c;需要进行事务…

十九、分布式数据库MyCat

目录 一、概述 1、MyCat是什么&#xff1f; 2、原理&#xff1a; 3、能干什么 1、读写分离 2、数据分片 3、多数据源整合 4、Mycat监控 4、安装部署 1、环境准备 2、安装 3、Mycat配置详解 1、server.xml user 标签 2、schema.xml schema标签&#xff1a; table标签&…

宜选影票在线选座电影票小程序开发如何获取api接口?

要开发一个在线选座电影票小程序并获取API接口&#xff0c;你需要遵循几个关键步骤。以下是通常的流程&#xff1a; 明确需求和目标&#xff1a; 在开始之前&#xff0c;明确你的小程序需要哪些功能&#xff0c;例如电影查询、场次查询、在线选座、购票支付等。确定你需要从AP…

普通人适合做大模型吗?过程中会发生什么潜在的挑战?

对于普通人来说&#xff0c;直接进行大模型的研发和训练可能存在一定的挑战&#xff0c;因为这通常需要以下资源和知识&#xff1a; 专业知识&#xff1a; 大模型的开发需要深入理解机器学习、深度学习、神经网络等领域的知识。 计算资源&#xff1a; 大模型的训练需要高性能的…

Docker基本操作 挂载数据卷

在创建一个容器的时候让容器挂载到一个数据卷: 命令:docker run --name mn -p 80:80 -v html:/usr/share/nginx/html -d nginx 这里的数据卷如果没有提前创好会自动创建 下边是命令解析 将容器挂载到一个数据卷之后 可以在查看数据卷的目录 在数据卷的目录可以找到容器的内容…

比亚迪CAN数据实时监控分析应用数字化差异化的决策价值洞察

在当今这个信息化飞速发展的时代&#xff0c;汽车数字化转型已成为企业持续竞争力的关键。中国新能源汽车行业的领军企业——比亚迪&#xff0c;其数字化之旅充分展现了企业的创新精神和对未来的深远洞察。 比亚迪的数字化战略不是简单的技术应用&#xff0c;而是一场深刻的商…

【算法】基础算法004之前缀和

&#x1f440;樊梓慕&#xff1a;个人主页 &#x1f3a5;个人专栏&#xff1a;《C语言》《数据结构》《蓝桥杯试题》《LeetCode刷题笔记》《实训项目》《C》《Linux》《算法》 &#x1f31d;每一个不曾起舞的日子&#xff0c;都是对生命的辜负 前言 本篇文章为大家带来前缀和…

【强训笔记】day14

NO.1 思路&#xff1a;用一个哈希表&#xff0c;先遍历s1&#xff0c;统计哈希表内的字符个数&#xff0c;在遍历s2&#xff0c;s2中的字符在哈希表中减去&#xff0c;如果哈希表中的字符个数小于0那么就输出No。 代码实现&#xff1a; #include <iostream> #include&…

森林消防—高扬程水泵:守护绿色屏障的专业利器/恒峰智慧科技

在广袤的森林中&#xff0c;火灾无疑是最具破坏性的灾难之一。为了及时应对森林火灾&#xff0c;保护珍贵的自然资源和生态平衡&#xff0c;高效的消防设备显得尤为重要。森林消防高扬程水泵便是其中一款专业设备&#xff0c;以其高效输送水源的能力&#xff0c;成为守护森林绿…

doris经典bug

在部署完登录web页面查看的时候会发现只有一个节点可以读取信息剩余的节点什么也没读取到 在发现问题后&#xff0c;我们去对应的节点去看log日志&#xff0c;发现它自己绑定到前端的地址上了 现在我们已经发现问题了&#xff0c;以下就开始解决问题 重置doris 首先对be进行操…

使用 Docker 部署 TaleBook 私人书籍管理系统

1&#xff09;项目介绍 GitHub&#xff1a;https://github.com/talebook/talebook Talebook 是一个简洁但强大的私人书籍管理系统。它基于 Calibre 项目构建&#xff0c;具备书籍管理、在线阅读与推送、用户管理、SSO 登录、从百度/豆瓣拉取书籍信息等功能。 友情提醒&#x…

矾液回收矾树脂

五氧化二钒溶液提取矾树脂A-654的过程&#xff0c;是一个涉及五氧化二钒提纯的重要步骤。我们将详细介绍这一提取过程。 首先&#xff0c;我们需要了解五氧化二钒和净化矾树脂A-654的基本性质。五氧化二钒是一种无机化合物&#xff0c; 净化矾树脂A-654 是一款加载了复杂的多胺…

亚马逊最新的 Echo Show 5 和 Show 8

爆爆&#xff01;亚马逊最新智能显示器终于来了&#xff01;Show 8可是一个功能超强的小工具&#xff0c;既能当数码相框、智能家居控制器和闹钟&#xff0c;还能控制您家中的几乎所有设备&#xff01;8英寸的显示屏让您流媒体和视频通话体验更加流畅&#xff01; 如果您不需要…

【Python】京东商品详情数据采集返回商品详情主题主图SKU

文章目录 Python请求 京东API接口 接入文档 接入参数 返回示例 Python请求 # coding:utf-8 """ Compatible for python2.x and python3.x requirement: pip install requests """ from __future__ import print_function import requests…

算法基础01一快速排序,归并排序,二分

一.排序 1.快速 排序 基于分治 确定分界点 左 右 中间 随机划分区间 左半边<x >x在右半边递归处理左右两端 #include<iostream>using namespace std;const int N 1e6 10;int n; int q[N]; void quick_sort(int q[],int l,int r) {if(l>r)return;//边界&…

东莞厂家冷风机的通风降温优点

工业冷风机的通风降温优点主要体现在以下几个方面&#xff1a; 高效降温&#xff1a;工业冷风机采用水蒸发原理&#xff0c;通过将热空气经过湿帘或水幕冷却&#xff0c;能够迅速降低空气温度。这种降温方式相比传统压缩机空调系统更为高效&#xff0c;有助于员工在高温环境中…

【新三个数排序的自创算法,这是我厉年来很满意的一次排序算法设计,最好小于O(N)最坏O((NN/3)/2)。】2024-5-7

缘由如何用C&#xff0b;&#xff0b;解决一下问题_编程语言-CSDN问答 int a[]{1, 4, 7, 8, 5, 2, 3, 6, 9, 7}, n 10, x n, jh 0, j 0;px:if (j < n) {//缘由https://ask.csdn.net/questions/8099444if (--x < 2 j)x n - 1, j 3;if (x < n - 1 && a[x…

档案数字化电子文件检测工具

在档案数字化的过程中&#xff0c;需要注意扫描的电子文件属性和质量是否符合要求。nhdeep电子文件属性检测工具&#xff0c;支持对图片、pdf和ofd文件&#xff0c;显示文件的基本属性&#xff1a;文件类型、文件大小、创建时间&#xff1b;采集文件的分辨率、图片颜色、图片的…

Agent AI智能体:我们的生活即将如何改变?

你有没有想过&#xff0c;那个帮你设置闹钟、提醒你朋友的生日&#xff0c;甚至帮你订外卖的智能助手&#xff0c;其实就是Agent AI智能体&#xff1f;它们已经在我们生活中扮演了越来越重要的角色。现在&#xff0c;让我们一起想象一下&#xff0c;随着这些AI智能体变得越来越…

基于STM32的智能垃圾桶设计(论文+源码)_kaic

基于STM32的智能垃圾桶设计 摘 要 随着社会科学技术的迅猛进展&#xff0c;人们的生活质量和速度也在不断提高。然而&#xff0c;大多数传统的家庭垃圾桶已经过时且缺乏创新&#xff0c;缺乏人性化设计。它们使用起来不方便、不卫生&#xff0c;所有的生活和废物垃圾都被混合…