From 36c5bc59e85b56ea2f9e08652c820558a9998850 Mon Sep 17 00:00:00 2001 From: acgist <289547414@qq.com> Date: Sun, 19 Mar 2023 10:56:01 +0800 Subject: [PATCH] =?UTF-8?q?[+]=20=E9=B8=BF=E8=92=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taoyao-client-harmony/README.md | 6 ++-- taoyao-client-harmony/os/bundle.json | 2 +- taoyao-client-harmony/os/bundle.release.json | 2 +- .../taoyao/include/Publisher.hpp | 12 ++++++++ .../taoyao/include/Taoyao.hpp | 26 ++++++++++++++++- .../taoyao/src/signal/Taoyao.cpp | 29 +++++++++++++++++-- 6 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 taoyao-client-harmony/taoyao/include/Publisher.hpp diff --git a/taoyao-client-harmony/README.md b/taoyao-client-harmony/README.md index a064fde..421b2b1 100644 --- a/taoyao-client-harmony/README.md +++ b/taoyao-client-harmony/README.md @@ -101,9 +101,9 @@ userfs_jffs2.img:userfs 串口:`115200` ``` -setenv bootcmd "sf probe 0;sf read 0x40000000 0x100000 0x600000;go 0x40000000"; -setenv bootargs "console=ttyAMA0,115200n8 root=flash fstype=jffs2 rw rootaddr=7M rootsize=8M"; -save; +setenv bootcmd "sf probe 0;sf read 0x40000000 0x100000 0x600000;go 0x40000000" +setenv bootargs "console=ttyAMA0,115200n8 root=flash fstype=jffs2 rw rootaddr=7M rootsize=8M" +save reset ./bin/wpa_supplicant -iwlan0 -c /etc/wpa_supplicant.conf ``` diff --git a/taoyao-client-harmony/os/bundle.json b/taoyao-client-harmony/os/bundle.json index 5efa293..e8c8671 100644 --- a/taoyao-client-harmony/os/bundle.json +++ b/taoyao-client-harmony/os/bundle.json @@ -9,7 +9,7 @@ "ohos": { "os": "3.0.0", "board": "hi3518", - "kernel": "linux" + "kernel": "liteos_a" }, "base": { "name": "@ohos/hispark_aries", diff --git a/taoyao-client-harmony/os/bundle.release.json b/taoyao-client-harmony/os/bundle.release.json index 9bbc670..e059025 100644 --- a/taoyao-client-harmony/os/bundle.release.json +++ b/taoyao-client-harmony/os/bundle.release.json @@ -9,7 +9,7 @@ "ohos": { "os": "3.0.0", "board": "hi3518", - "kernel": "linux" + "kernel": "liteos_a" }, "base": { "name": "@ohos/hispark_aries", diff --git a/taoyao-client-harmony/taoyao/include/Publisher.hpp b/taoyao-client-harmony/taoyao/include/Publisher.hpp new file mode 100644 index 0000000..7eb2543 --- /dev/null +++ b/taoyao-client-harmony/taoyao/include/Publisher.hpp @@ -0,0 +1,12 @@ +#pragma once + +// 通道类型:rtp +#define TRANSPORT_RTP "RTP" +// 通道类型:webrtc +#define TRANSPORT_WEBRTC "WEBRTC" + +namespace acgist { + + + +} \ No newline at end of file diff --git a/taoyao-client-harmony/taoyao/include/Taoyao.hpp b/taoyao-client-harmony/taoyao/include/Taoyao.hpp index 6c56b95..396bad6 100644 --- a/taoyao-client-harmony/taoyao/include/Taoyao.hpp +++ b/taoyao-client-harmony/taoyao/include/Taoyao.hpp @@ -10,6 +10,8 @@ #include #include +#include +#include #include #include @@ -34,6 +36,15 @@ private: struct timeval timeout; // 地址 struct sockaddr_in serverAddress; +private: + // 当前索引 + int index = 0; + // 最大索引 + int maxIndex = 999; + // 终端索引 + int clientIndex = 99999; + // 索引互斥 + std::mutex indexMutex; public: /** * @param port 端口 @@ -46,6 +57,19 @@ public: */ virtual ~Taoyao(); private: + /** + * 生成ID + */ + long long buildId(); + /** + * @param signal 信令标识 + * @param body 消息主体 + * @param id 消息ID + * @param v 消息版本 + * + * @returns 信令消息 + */ + std::string buildMessage(std::string signal, json body, long long id, std::string v); /** * 接收消息 */ @@ -62,7 +86,7 @@ public: /** * 请求消息 */ - void request(std::string message); + // void request(std::string message); /** * 关闭信令 */ diff --git a/taoyao-client-harmony/taoyao/src/signal/Taoyao.cpp b/taoyao-client-harmony/taoyao/src/signal/Taoyao.cpp index 2996519..0ca1fdb 100644 --- a/taoyao-client-harmony/taoyao/src/signal/Taoyao.cpp +++ b/taoyao-client-harmony/taoyao/src/signal/Taoyao.cpp @@ -18,6 +18,31 @@ Taoyao::Taoyao(int port, std::string address, int timeout = 5) { Taoyao::~Taoyao() { } +long long Taoyao::buildId() { + this->indexMutex.lock(); + int index = this->index; + if (++index > this->maxIndex) { + index = 0; + } + this->index = index; + this->indexMutex.unlock(); + time_t curtime; + time(&curtime); + tm *pCurtime = localtime(&curtime); + return ( + 100000000000000 * pCurtime->tm_mday + + 1000000000000 * pCurtime->tm_hour + + 10000000000 * pCurtime->tm_min + + 100000000 * pCurtime->tm_sec + + 1000 * this->clientIndex + + index + ); +} + +std::string Taoyao::buildMessage(std::string signal, json body, long long id = this->buildId(), std::string v = "1.0.0") { + +} + void Taoyao::acceptSignal() { int status; char recvbuf[BUFFER_SIZE]; @@ -61,8 +86,8 @@ void Taoyao::push(std::string message) { memset(sendbuf, 0, sizeof(sendbuf)); } -void Taoyao::request(std::string message) { -} +// void Taoyao::request(std::string message) { +// } void Taoyao::closeSignal() { if(this->socketChannel != 0) {