[+] 鸿蒙

This commit is contained in:
acgist
2023-03-19 10:56:01 +08:00
parent dcdf4c0217
commit 36c5bc59e8
6 changed files with 69 additions and 8 deletions

View File

@@ -101,9 +101,9 @@ userfs_jffs2.imguserfs
串口:`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
```

View File

@@ -9,7 +9,7 @@
"ohos": {
"os": "3.0.0",
"board": "hi3518",
"kernel": "linux"
"kernel": "liteos_a"
},
"base": {
"name": "@ohos/hispark_aries",

View File

@@ -9,7 +9,7 @@
"ohos": {
"os": "3.0.0",
"board": "hi3518",
"kernel": "linux"
"kernel": "liteos_a"
},
"base": {
"name": "@ohos/hispark_aries",

View File

@@ -0,0 +1,12 @@
#pragma once
// 通道类型rtp
#define TRANSPORT_RTP "RTP"
// 通道类型webrtc
#define TRANSPORT_WEBRTC "WEBRTC"
namespace acgist {
}

View File

@@ -10,6 +10,8 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <ctime>
#include <mutex>
#include <thread>
#include <iostream>
@@ -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);
/**
* 关闭信令
*/

View File

@@ -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) {