feat support PRIV_SHELL_CMD_FUNCTION to fit heterogeneous OS

This commit is contained in:
Liu_Weichao
2022-09-26 17:04:04 +08:00
parent fd69c3d400
commit dbca22a1a6
64 changed files with 916 additions and 893 deletions

View File

@@ -110,10 +110,4 @@ int Adapter4GTest(void)
return 0;
}
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(Adapter4GTest,a EC200T adpter sample);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, Adapter4GTest, Adapter4GTest, show adapter 4G information);
#endif
PRIV_SHELL_CMD_FUNCTION(Adapter4GTest, a EC200T adpter sample, PRIV_SHELL_CMD_FUNC_ATTR);

View File

@@ -111,9 +111,4 @@ int AdapterBlueToothTest(void)
return 0;
}
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(AdapterBlueToothTest,a bt adpter sample);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterBlueToothTest, AdapterBlueToothTest, show adapter bluetooth information);
#endif
PRIV_SHELL_CMD_FUNCTION(AdapterBlueToothTest, a bluetooth test sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@@ -122,8 +122,4 @@ int AdapterEthernetTest(void)
return 0;
}
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(AdapterEthernetTest,a ethernet adpter sample);
#elif definded ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterEthernetTest, AdapterEthernetTest, show adapter ethernet information);
#endif
PRIV_SHELL_CMD_FUNCTION(AdapterEthernetTest, a ethernet test sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@@ -205,4 +205,4 @@ int AdapterEthercatTest(void)
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_PARAM_NUM(0) | SHELL_CMD_DISABLE_RETURN, AdapterEthercatTest, AdapterEthercatTest, show adapter ethercat information);
PRIV_SHELL_CMD_FUNCTION(AdapterEthercatTest, a ethercat test sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@@ -4,25 +4,11 @@
#ifdef POWERLINK_MN
extern int OplkDemoMnConsole(int argc, char *argv[]);
SHELL_EXPORT_CMD(
SHELL_CMD_PERMISSION(0) |
SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) |
SHELL_CMD_PARAM_NUM(0) |
SHELL_CMD_DISABLE_RETURN,
OplkDemoMnConsole,
OplkDemoMnConsole,
openPOWERLINK demo MN (console version));
PRIV_SHELL_CMD_FUNCTION(OplkDemoMnConsole, a openPOWERLINK MN sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif
#ifdef POWERLINK_CN
extern int OplkDemoCnConsole(int argc, char *argv[]);
SHELL_EXPORT_CMD(
SHELL_CMD_PERMISSION(0) |
SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) |
SHELL_CMD_PARAM_NUM(0) |
SHELL_CMD_DISABLE_RETURN,
OplkDemoCnConsole,
OplkDemoCnConsole,
openPOWERLINK demo CN (console version));
PRIV_SHELL_CMD_FUNCTION(OplkDemoCnConsole, a openPOWERLINK CN sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@@ -979,10 +979,4 @@ int AdapterLoraTest(void)
return 0;
}
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(AdapterLoraTest,a Lora adpter sample);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterLoraTest, AdapterLoraTest, show adapter lora information);
#endif
PRIV_SHELL_CMD_FUNCTION(AdapterLoraTest, a lora test sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@@ -705,8 +705,7 @@ static void LoraTest(void)
return;
}
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
LoraTest, LoraTest, lora send and receive message);
PRIV_SHELL_CMD_FUNCTION(LoraTest, a lora test init sample, PRIV_SHELL_CMD_MAIN_ATTR);
static void LoraSend(int argc, char *argv[])
{
@@ -724,8 +723,7 @@ static void LoraSend(int argc, char *argv[])
E220Send(adapter, Msg, strlen(Msg));
}
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
LoraSend, LoraSend, lora send message);
PRIV_SHELL_CMD_FUNCTION(LoraSend, a lora test send sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif
#ifdef ADD_NUTTX_FETURES
@@ -765,39 +763,40 @@ void E220LoraSend(int argc, char *argv[])
#endif
#ifdef ADD_RTTHREAD_FETURES
static void LoraReadStart(void)
{
int ret;
LoraOpen();
rt_thread_t tid= rt_thread_create("LoraReadStart", LoraRead, RT_NULL,2048,10,5);
if(tid!=RT_NULL){
rt_thread_t tid = rt_thread_create("LoraReadStart", LoraRead, RT_NULL,2048,10,5);
if(tid!=RT_NULL) {
rt_thread_startup(tid);
}else{
} else {
rt_kprintf("LoraReadStart task_lora_read failed \r\n");
return;
}
}
MSH_CMD_EXPORT(LoraReadStart,Lora read task start sample);
PRIV_SHELL_CMD_FUNCTION(LoraReadStart, a lora test start sample, PRIV_SHELL_CMD_MAIN_ATTR);
#define E22400T_M1_PIN (11U)
#define E22400T_M0_PIN (9U)
static void LoraSend(int argc, char *argv[])
{
int8_t cmd[10]={0xFF,0xFF,0x02,0xAA,0XBB,0xCC}; //sned AA BB CC to address 01 channel05
LoraOpen();
int8_t cmd[10]={0xFF,0xFF,0x02,0xAA,0XBB,0xCC}; //sned AA BB CC to address 01 channel05
LoraOpen();
struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_LORA_NAME);
if (NULL == adapter) {
printf("LoraRead find lora adapter error\n");
return;
}
rt_pin_mode (E22400T_M1_PIN, PIN_MODE_OUTPUT);
rt_pin_mode (E22400T_M0_PIN, PIN_MODE_OUTPUT);
rt_pin_mode (E22400T_M1_PIN, PIN_MODE_OUTPUT);
rt_pin_mode (E22400T_M0_PIN, PIN_MODE_OUTPUT);
rt_pin_write(E22400T_M1_PIN, PIN_LOW);
rt_pin_write(E22400T_M0_PIN, PIN_HIGH);
rt_pin_write(E22400T_M0_PIN, PIN_HIGH);
E220Send(adapter, cmd, 6);
}
MSH_CMD_EXPORT(LoraSend,Lora send sample);
PRIV_SHELL_CMD_FUNCTION(LoraSend, a lora test send sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@@ -17,6 +17,7 @@
* @author AIIT XUOS Lab
* @date 2021.06.25
*/
#include <transform.h>
#include <adapter.h>
#include <stdlib.h>
@@ -80,7 +81,7 @@ int AdapterNbiotInit(void)
}
/******************TEST*********************/
int opennb(void)
int OpenNb(void)
{
int ret = 0;
@@ -88,23 +89,18 @@ int opennb(void)
#ifdef ADAPTER_BC28
ret = AdapterDeviceOpen(adapter);
if(ret < 0){
if(ret < 0) {
printf("open adapter failed\n");
return -1;
}
#endif
return 0;
}
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(opennb,open nb sample);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, opennb, opennb, show adapter nb information);
#endif
return 0;
}
PRIV_SHELL_CMD_FUNCTION(OpenNb, a NBiot open sample, PRIV_SHELL_CMD_MAIN_ATTR);
int closenb(void)
int CloseNb(void)
{
int ret = 0;
@@ -112,87 +108,62 @@ int closenb(void)
#ifdef ADAPTER_BC28
ret = AdapterDeviceClose(adapter);
if(ret < 0){
if(ret < 0) {
printf("open adapter failed\n");
return -1;
}
#endif
return 0;
}
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(closenb,close nb sample);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, closenb, closenb, show adapter nb information);
#endif
return 0;
}
PRIV_SHELL_CMD_FUNCTION(CloseNb, a NBiot close sample, PRIV_SHELL_CMD_MAIN_ATTR);
int connectnb(int argc, char *argv[])
{
const char *send_msg = argv[1];
int ret = 0;
int ConnectNb(int argc, char *argv[])
{
const char *send_msg = argv[1];
int ret = 0;
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
ret = AdapterDeviceConnect(adapter, 1, "101.68.82.219","9898",1);
if(ret < 0){
printf(" adapter send failed\n");
return -1;
}
ret = AdapterDeviceConnect(adapter, 1, "101.68.82.219","9898",1);
if(ret < 0) {
printf(" adapter send failed\n");
return -1;
}
return 0;
}
PRIV_SHELL_CMD_FUNCTION(ConnectNb, a NBiot connect sample, PRIV_SHELL_CMD_MAIN_ATTR);
return 0;
}
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(connectnb,connect nb test);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, connectnb, connectnb, show adapter nb information);
#endif
int SendNb(int argc, char *argv[])
{
const char *send_msg = argv[1];
int msg_len = atoi(argv[2]);
int ret = 0;
int sendnb(int argc, char *argv[])
{
const char *send_msg = argv[1];
int msg_len = atoi(argv[2]);
int ret = 0;
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
printf("send argv1 %s len = %d\n",argv[1],msg_len);
ret = AdapterDeviceSend(adapter, send_msg, msg_len);
if(ret < 0) {
printf(" adapter send failed\n");
return -1;
}
printf("nb send msg %s\n", send_msg);
printf("send argv1 %s len = %d\n",argv[1],msg_len);
ret = AdapterDeviceSend(adapter, send_msg, msg_len);
if(ret < 0){
printf(" adapter send failed\n");
return -1;
}
printf("nb send msg %s\n", send_msg);
return 0;
}
PRIV_SHELL_CMD_FUNCTION(SendNb, a NBiot send sample, PRIV_SHELL_CMD_MAIN_ATTR);
int RecvNb(void)
{
char recv_msg[128];
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
memset(recv_msg,0,128);
AdapterDeviceRecv(adapter, recv_msg, 128);
PrivTaskDelay(2000);
printf("nb recv msg %s\n", recv_msg);
return 0;
}
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(sendnb,send nb test);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendnb, sendnb, show adapter nb information);
#endif
int recvnb(void)
{
char recv_msg[128];
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
memset(recv_msg,0,128);
AdapterDeviceRecv(adapter, recv_msg, 128);
PrivTaskDelay(2000);
printf("nb recv msg %s\n", recv_msg);
return 0;
}
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(recvnb,receive nb test);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvnb, recvnb, show adapter nb information);
#endif
return 0;
}
PRIV_SHELL_CMD_FUNCTION(RecvNb, a NBiot receive sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@@ -1,3 +1,23 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file adapter_nbiot.h
* @brief Implement the connection nbiot adapter function
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.06.25
*/
#ifndef ADAPTER_NBIOT_H
#define ADAPTER_NBIOT_H

View File

@@ -11,7 +11,7 @@
*/
/**
* @file adapter_wifiiiii.c
* @file adapter_wifi.c
* @brief Implement the connection wifi adapter function
* @version 1.1
* @author AIIT XUOS Lab
@@ -20,9 +20,6 @@
#include <adapter.h>
#include "adapter_wifi.h"
#ifdef ADD_XIZI_FETURES
#include <bus_pin.h>
#endif
#ifdef ADAPTER_HFA21_WIFI
extern AdapterProductInfoType Hfa21WifiAttach(struct Adapter *adapter);
@@ -100,7 +97,6 @@ int AdapterWifiInit(void)
}
/******************wifi TEST*********************/
#ifdef ADD_XIZI_FETURES
int AdapterWifiTest(void)
{
char cmd[64];
@@ -108,6 +104,7 @@ int AdapterWifiTest(void)
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
#if 0
#ifdef ADAPTER_HFA21_DRIVER_EXT_PORT
static BusType ch438_pin;
ch438_pin = PinBusInitGet();
@@ -154,7 +151,7 @@ int AdapterWifiTest(void)
PrivClose(pin_fd);
#endif
#endif
AdapterDeviceOpen(adapter);
// AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
@@ -182,38 +179,23 @@ int AdapterWifiTest(void)
PrivTaskDelay(1000);
}
}
#endif
PRIV_SHELL_CMD_FUNCTION(AdapterWifiTest, a WiFi test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(AdapterWifiTest,a wifi adpter sample);
#endif
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterWifiTest, AdapterWifiTest, show adapter wifi information);
#endif
int wifiopen(void)
int WifiOpen(void)
{
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
return AdapterDeviceOpen(adapter);
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, wifiopen, wifiopen, open adapter wifi );
#endif
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(wifiopen,a wifi adpter sample);
#endif
int wificlose(void)
PRIV_SHELL_CMD_FUNCTION(WifiOpen, a WiFi open sample, PRIV_SHELL_CMD_MAIN_ATTR);
int WifiClose(void)
{
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
return AdapterDeviceClose(adapter);
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, wificlose, wificlose, close adapter wifi );
#endif
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(wificlose,a wifi adpter sample);
#endif
int wifisetup(int argc, char *argv[])
PRIV_SHELL_CMD_FUNCTION(WifiClose, a WiFi close sample, PRIV_SHELL_CMD_MAIN_ATTR);
int WifiSetup(int argc, char *argv[])
{
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
struct WifiParam param;
@@ -225,13 +207,9 @@ int wifisetup(int argc, char *argv[])
return AdapterDeviceSetUp(adapter);
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3)|SHELL_CMD_DISABLE_RETURN, wifisetup, wifisetup, setup adapter wifi );
#endif
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(wifisetup,a wifi adpter sample:wifisetup <server|client>);
#endif
int wifiaddrset(int argc, char *argv[])
PRIV_SHELL_CMD_FUNCTION(WifiSetup, a WiFi setup sample, PRIV_SHELL_CMD_MAIN_ATTR);
int WifiAddrSet(int argc, char *argv[])
{
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
char *ip = argv[1];
@@ -242,25 +220,17 @@ int wifiaddrset(int argc, char *argv[])
AdapterDevicePing(adapter, "36.152.44.95");///< ping www.baidu.com
return AdapterDeviceNetstat(adapter);
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(4)|SHELL_CMD_DISABLE_RETURN, wifiaddrset, wifiaddrset, addrset adapter wifi);
#endif
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(wifiaddrset,a wifi adpter sample:wifiaddrset <server|client>);
#endif
int wifiping(int argc, char *argv[])
PRIV_SHELL_CMD_FUNCTION(WifiAddrSet, a WiFi addr set sample, PRIV_SHELL_CMD_MAIN_ATTR);
int WifiPing(int argc, char *argv[])
{
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
printf("ping %s\n",argv[1]);
return AdapterDevicePing(adapter, argv[1]);
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3), wifiping, wifiping, wifiping adapter );
#endif
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(wifiping,a wifi adpter sample:wifiping <server|client>);
#endif
int wificonnect(int argc, char *argv[])
PRIV_SHELL_CMD_FUNCTION(WifiPing, a WiFi ping sample, PRIV_SHELL_CMD_MAIN_ATTR);
int WifiConnect(int argc, char *argv[])
{
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
char *ip = argv[1];
@@ -278,13 +248,9 @@ int wificonnect(int argc, char *argv[])
return AdapterDeviceConnect(adapter, net_role, ip, port, ip_type);
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(4)|SHELL_CMD_DISABLE_RETURN, wificonnect, wificonnect, wificonnect adapter);
#endif
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(wificonnect,a wifi adpter sample:wificonnect <server|client>);
#endif
int wifisend(int argc, char *argv[])
PRIV_SHELL_CMD_FUNCTION(WifiConnect, a WiFi connect sample, PRIV_SHELL_CMD_MAIN_ATTR);
int WifiSend(int argc, char *argv[])
{
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
@@ -296,13 +262,9 @@ int wifisend(int argc, char *argv[])
}
return 0;
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3)|SHELL_CMD_DISABLE_RETURN, wifisend, wifisend, wifisend adapter wifi information);
#endif
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(wifisend,a wifi adpter sample:wifisend <server|client>);
#endif
int wifirecv(int argc, char *argv[])
PRIV_SHELL_CMD_FUNCTION(WifiSend, a WiFi send sample, PRIV_SHELL_CMD_MAIN_ATTR);
int WifiRecv(int argc, char *argv[])
{
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
@@ -313,12 +275,7 @@ int wifirecv(int argc, char *argv[])
printf("wifi recv [%s]\n",wifi_recv_msg);
}
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3)|SHELL_CMD_DISABLE_RETURN, wifirecv, wifirecv, wifirecv adapter wifi information);
#endif
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(wifirecv,a wifi adpter sample:wifirecv <server|client>);
#endif
PRIV_SHELL_CMD_FUNCTION(WifiRecv, a WiFi receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
#ifdef ADD_NUTTX_FETURES

View File

@@ -1,3 +1,23 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file adapter_wifi.h
* @brief Implement the connection wifi adapter function
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.07.25
*/
#ifndef ADAPTER_WIFI_H
#define ADAPTER_WIFI_H

View File

@@ -90,7 +90,7 @@ int AdapterZigbeeInit(void)
}
/******************TEST*********************/
int openzigbee(void)
int OpenZigbee(void)
{
int ret = 0;
@@ -98,19 +98,19 @@ int openzigbee(void)
#ifdef ADAPTER_E18
ret = AdapterDeviceOpen(adapter);
if(ret < 0){
if(ret < 0) {
printf("open adapter failed\n");
return -1;
}
adapter->info->work_mode = 1;
ret = AdapterDeviceControl(adapter, CONFIG_ZIGBEE_NET_MODE,NULL);
if(ret < 0){
if(ret < 0) {
printf("control adapter failed\n");
return -1;
}
ret = AdapterDeviceJoin(adapter, NULL);
if(ret < 0){
if(ret < 0) {
printf("join adapter failed\n");
return -1;
}
@@ -118,12 +118,9 @@ int openzigbee(void)
return 0;
}
PRIV_SHELL_CMD_FUNCTION(OpenZigbee, a ZigBee open sample, PRIV_SHELL_CMD_MAIN_ATTR);
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, openzigbee, openzigbee, show adapter zigbee information);
#endif
int sendzigbee(int argc, char *argv[])
int SendZigbee(int argc, char *argv[])
{
const char *send_msg = argv[1];
int ret = 0;
@@ -132,20 +129,17 @@ int sendzigbee(int argc, char *argv[])
printf("send argv1 %s\n",argv[1]);
ret = AdapterDeviceSend(adapter, send_msg, strlen(send_msg));
if(ret < 0){
if(ret < 0) {
printf(" adapter send failed\n");
return -1;
}
printf("zigbee send msg %s\n", send_msg);
return 0;
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendzigbee, sendzigbee, show adapter zigbee information);
#endif
PRIV_SHELL_CMD_FUNCTION(SendZigbee, a ZigBee send sample, PRIV_SHELL_CMD_MAIN_ATTR);
int recvzigbee(void)
int RecvZigbee(void)
{
char recv_msg[128];
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_ZIGBEE_NAME);
@@ -156,7 +150,4 @@ int recvzigbee(void)
return 0;
}
#ifdef ADD_XIZI_FETURES
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvzigbee, recvzigbee, show adapter zigbee information);
#endif
PRIV_SHELL_CMD_FUNCTION(RecvZigbee, a ZigBee receive sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@@ -1,3 +1,23 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file adapter_zigbee.h
* @brief Implement the connection zigbee adapter function
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.09.15
*/
#ifndef ADAPTER_ZIGBEE_H
#define ADAPTER_ZIGBEE_H

View File

@@ -460,7 +460,7 @@ static int E18Recv(struct Adapter *adapter, void *buf, size_t len)
return 0;
}
static int E18Quit(struct Adapter *adapter)
static int E18Quit(struct Adapter *adapter, unsigned char *priv_net_group)
{
return 0;

View File

@@ -358,7 +358,3 @@ void PlcSocketTask(int argc, char *argv[])
lwip_config_net(lwip_ipaddr, lwip_netmask, param->ip);
PrivTaskCreate(&th_id, &attr, PlcSocketStart, param);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
PlcSocket, PlcSocketTask, Test PLC Socket);

View File

@@ -112,9 +112,6 @@ void CtlCreateFileTest(void)
CtlFileClose(fd);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
CtlCreateFile, CtlCreateFileTest, Test control file);
#ifdef LIB_USING_CJSON
void CtlParseJsonArray(cJSON *dat, int *cmd_len, char *cmd)
@@ -205,9 +202,5 @@ void CtlParseFileTest(void)
CtlParseJsonData(file_buf);
free(file_buf);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
CtlParseFile, CtlParseFileTest, Parse control file);
#endif

View File

@@ -24,30 +24,30 @@
void sm3_test_case(){
uint8_t result[SM3_DIGEST_LENGTH] = { 0 };
//test case 1
KPrintf("\n#################### sm3 test ##########################\n");
printf("\n#################### sm3 test ##########################\n");
char *msg = "abc";
KPrintf("\n####sm3 test case 1:\n");
KPrintf( "%-15s %s\n", "digest message1:",msg);
printf("\n####sm3 test case 1:\n");
printf( "%-15s %s\n", "digest message1:",msg);
sm3(msg,3,result);
KPrintf("%-15s ","digest result1: ");
printf("%-15s ","digest result1: ");
for ( int i = 0 ; i < SM3_DIGEST_LENGTH ; i++){
KPrintf("%02x",result[i]);
printf("%02x",result[i]);
}
KPrintf("\n");
printf("\n");
//test case 2
KPrintf("\n####sm3 test case 2:\n");
printf("\n####sm3 test case 2:\n");
//msg = "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd"
char msg1[64] = { 0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 ,0x61, 0x62, 0x63, 0x64 };
KPrintf("digest message2: ");
printf("digest message2: ");
for ( int i = 0 ; i < 64 ; i++){
KPrintf("%02x",msg1[i]);
printf("%02x",msg1[i]);
}
KPrintf("\n");
printf("\n");
sm3(msg1, 64,result);
KPrintf("digest result2: ");
printf("digest result2: ");
for ( int i = 0 ; i < SM3_DIGEST_LENGTH ; i++){
KPrintf("%02x",result[i]);
printf("%02x",result[i]);
}
KPrintf("\n");
KPrintf("\n########################################################\n");
printf("\n");
printf("\n########################################################\n");
}

View File

@@ -31,63 +31,63 @@ void sm4_test_case(){
sms4_key_t key;
//test case 1
KPrintf("\n#################### sm4 test ##########################\n");
KPrintf("\n####sm4 test case1:\n");
KPrintf("plaintext: ");
printf("\n#################### sm4 test ##########################\n");
printf("\n####sm4 test case1:\n");
printf("plaintext: ");
for (int i = 0; i< 16; i++){
KPrintf("%02x ",input[i]);
printf("%02x ",input[i]);
}
KPrintf("\n");
KPrintf("key: ");
printf("\n");
printf("key: ");
for (int i = 0; i< 16; i++){
KPrintf("%02x",ukey[i]);
printf("%02x",ukey[i]);
}
KPrintf("\n");
printf("\n");
KPrintf("encryption:\n");
printf("encryption:\n");
sms4_set_encrypt_key(&key, ukey);
Sms4EcbEncryptNoPadding(input,16,res,&olen,&key);
KPrintf("ciphertext: ");
printf("ciphertext: ");
for (int i = 0; i< 16; i++){
KPrintf("%02x",res[i]);
printf("%02x",res[i]);
}
KPrintf("\n");
KPrintf("decryption:\n");
printf("\n");
printf("decryption:\n");
sms4_set_decrypt_key(&key, ukey);
KPrintf("round key in sms4_set_decrypt_key:\n");
printf("round key in sms4_set_decrypt_key:\n");
for (int i = 0; i < 32; i++){
KPrintf("rk%d:%08x\n", i, key.rk[i]);
printf("rk%d:%08x\n", i, key.rk[i]);
}
Sms4EcbDecryptNoPadding(res,16,res,&olen,&key);
printf("plaintext: ");
for (int i = 0; i< 16; i++){
KPrintf("%02x",res[i]);
printf("%02x",res[i]);
}
printf("\n");
////test case 2
KPrintf("\n####sm4 test case2:\n");
KPrintf("plaintext: ");
printf("\n####sm4 test case2:\n");
printf("plaintext: ");
for (int i = 0; i< 16; i++){
KPrintf("%02x",input[i]);
printf("%02x",input[i]);
}
KPrintf("\n");
KPrintf("key: ");
printf("\n");
printf("key: ");
for (int i = 0; i< 16; i++){
KPrintf("%02x",ukey[i]);
printf("%02x",ukey[i]);
}
KPrintf("\n");
KPrintf("encrypt 1000000 times:\n");
printf("\n");
printf("encrypt 1000000 times:\n");
sms4_set_encrypt_key(&key, ukey);
memcpy(plaintext, input, 16);
for (int i = 0;i< 1000000; i++){
Sms4EcbEncryptNoPadding(plaintext,16,ciphertext,&olen,&key);
memcpy(plaintext, ciphertext, 16);
}
KPrintf("ciphertext: ");
printf("ciphertext: ");
for (int i = 0; i< 16; i++){
KPrintf("%02x",ciphertext[i]);
printf("%02x",ciphertext[i]);
}
KPrintf("\n");
KPrintf("\n########################################################\n");
printf("\n");
printf("\n########################################################\n");
}

View File

@@ -62,11 +62,11 @@ void SignAndVerifyTest()
SM9Init();
KPrintf("------------------------------below is ks---------------------------------\n");
printf("------------------------------below is ks---------------------------------\n");
Big8wPrint(&ks);
Ppub_s = G2PointMult(ks, P2);
KPrintf("------------------------------below is Ppub_s-----------------------------\n");
printf("------------------------------below is Ppub_s-----------------------------\n");
Big8wPrint(&Ppub_s.x.high);
Big8wPrint(&Ppub_s.x.low);
Big8wPrint(&Ppub_s.y.high);
@@ -75,79 +75,79 @@ void SignAndVerifyTest()
JoinIDhid(ID_Alice, 5, hid, Id_Alice_hid);
t1 = Big8wAddMod(H(Id_Alice_hid, 5 + 1, 0x01), ks, curve.N);
KPrintf("------------------------------below is t1---------------------------------\n");
printf("------------------------------below is t1---------------------------------\n");
Big8wPrint(&t1);
t2 = Big8wMultMod(ks, Big8wReverse(t1, curve.N), curve.N);
KPrintf("------------------------------below is t2---------------------------------\n");
printf("------------------------------below is t2---------------------------------\n");
Big8wPrint(&t2);
dsA = G1pointMult(t2, P1);
KPrintf("------------------------------below is dsA--------------------------------\n");
printf("------------------------------below is dsA--------------------------------\n");
Big8wPrint(&dsA.x);
Big8wPrint(&dsA.y);
g = BiLinearPairing(P1, Ppub_s);
KPrintf("------------------------below is bilineapairing---------------------------\n");
printf("------------------------below is bilineapairing---------------------------\n");
Q12Print(&g);
w = Q12PowerMod(g, r);
KPrintf("------------------------------below is w----------------------------------\n");
printf("------------------------------below is w----------------------------------\n");
Q12Print(&w);
msg_w = (uint8_t*)(malloc(msglen + BIG8W_BYTESIZE * 12));
JoinMsgW(message, msglen, &w, msg_w);
h = H(msg_w, msglen + BIG8W_BYTESIZE * 12, 0x02);
KPrintf("------------------------------below is h----------------------------------\n");
printf("------------------------------below is h----------------------------------\n");
Big8wPrint(&h);
big8w L = Big8wMinusMod(r, h, curve.N);
KPrintf("------------------------------below is L----------------------------------\n");
printf("------------------------------below is L----------------------------------\n");
Big8wPrint(&L);
G1point S = G1pointMult(L, dsA);
KPrintf("------------------------------below is S----------------------------------\n");
printf("------------------------------below is S----------------------------------\n");
Big8wPrint(&S.x);
Big8wPrint(&S.y);
KPrintf("\n");
printf("\n");
// verify the signature
g = BiLinearPairing(P1, Ppub_s);
KPrintf("------------------------below is bilineapairing---------------------------\n");
printf("------------------------below is bilineapairing---------------------------\n");
Q12Print(&g);
t = Q12PowerMod(g, h);
KPrintf("-----------------------------below is t-----------------------------------\n");
printf("-----------------------------below is t-----------------------------------\n");
Q12Print(&t);
h1 = H(Id_Alice_hid, 5 + 1, 0x01);
KPrintf("-----------------------------below is h1----------------------------------\n");
printf("-----------------------------below is h1----------------------------------\n");
Big8wPrint(&h1);
P = G2PointAdd(Ppub_s, G2PointMult(h1, P2));
KPrintf("------------------------------below is P----------------------------------\n");
printf("------------------------------below is P----------------------------------\n");
G2pointPrint(&P);
u = BiLinearPairing(S, P);
KPrintf("------------------------------below is u----------------------------------\n");
printf("------------------------------below is u----------------------------------\n");
Q12Print(&u);
w = Q12MultMod(u, t);
KPrintf("------------------------------below is w----------------------------------\n");
printf("------------------------------below is w----------------------------------\n");
Q12Print(&w);
h2 = H(msg_w, msglen + BIG8W_BYTESIZE * 12, 0x02);
KPrintf("------------------------------below is h2---------------------------------\n");
printf("------------------------------below is h2---------------------------------\n");
Big8wPrint(&h2);
KPrintf("------------------------------below is h----------------------------------\n");
printf("------------------------------below is h----------------------------------\n");
Big8wPrint(&h);
if (Big8wEqual(&h2, &h))
KPrintf("\nh2 = h, test verify success!\n");
printf("\nh2 = h, test verify success!\n");
sig = SM9Sign(message, msglen, dsA, Ppub_s);
if (SM9VerifySignature(ID_Alice, 5, hid, message, msglen, sig, Ppub_s))
KPrintf("SM9 Sign and VerifySignature API run success!\n");
printf("SM9 Sign and VerifySignature API run success!\n");
/*
@@ -172,8 +172,8 @@ void SignAndVerifyTest()
end = clock();
end_start = end - start;
KPrintf("\n");
KPrintf("runtime of sign in: %d ms\n", end_start);
printf("\n");
printf("runtime of sign in: %d ms\n", end_start);
*/
free(Id_Alice_hid);
@@ -239,21 +239,21 @@ void SM9KeyExchangeTest()
SM9Init();
Ppub_e = G1pointMult(ke, P1);
KPrintf("------------------------------below is Ppub_e-----------------------------\n");
printf("------------------------------below is Ppub_e-----------------------------\n");
Big8wPrint(&Ppub_e.x);
Big8wPrint(&Ppub_e.y);
JoinIDhid(ID_Alice, 5, hid, Id_Alice_hid);
t1 = Big8wAddMod(H(Id_Alice_hid, 5 + 1, 0x01), ke, curve.N);
KPrintf("-----------------------------below is t1----------------------------------\n");
printf("-----------------------------below is t1----------------------------------\n");
Big8wPrint(&t1);
t2 = Big8wMultMod(ke, Big8wReverse(t1, curve.N), curve.N);
KPrintf("-----------------------------below is t2----------------------------------\n");
printf("-----------------------------below is t2----------------------------------\n");
Big8wPrint(&t2);
deA = G2PointMult(t2, P2);
KPrintf("------------------------------below is deA--------------------------------\n");
printf("------------------------------below is deA--------------------------------\n");
Big8wPrint(&deA.x.high);
Big8wPrint(&deA.x.low);
Big8wPrint(&deA.y.high);
@@ -262,15 +262,15 @@ void SM9KeyExchangeTest()
JoinIDhid(ID_Bob, 3, hid, ID_Bob_hid);
t3 = Big8wAddMod(H(ID_Bob_hid, 3 + 1, 0x01), ke, curve.N);
KPrintf("-----------------------------below is t3----------------------------------\n");
printf("-----------------------------below is t3----------------------------------\n");
Big8wPrint(&t3);
t4 = Big8wMultMod(ke, Big8wReverse(t3, curve.N), curve.N);
KPrintf("-----------------------------below is t4----------------------------------\n");
printf("-----------------------------below is t4----------------------------------\n");
Big8wPrint(&t4);
deB = G2PointMult(t4, P2);
KPrintf("------------------------------below is deB--------------------------------\n");
printf("------------------------------below is deB--------------------------------\n");
Big8wPrint(&deB.x.high);
Big8wPrint(&deB.x.low);
Big8wPrint(&deB.y.high);
@@ -279,208 +279,208 @@ void SM9KeyExchangeTest()
JoinIDhid(ID_Bob, 3, hid, ID_Bob_hid);
h1 = H(ID_Bob_hid, 3 + 1, 0x01);
KPrintf("-----------------------------below is h1----------------------------------\n");
printf("-----------------------------below is h1----------------------------------\n");
Big8wPrint(&h1);
QB = G1pointAdd(Ppub_e, G1pointMult(h1, P1));
KPrintf("-----------------------------below is QB----------------------------------\n");
printf("-----------------------------below is QB----------------------------------\n");
Big8wPrint(&QB.x);
Big8wPrint(&QB.y);
RA = G1pointMult(rA, QB);
KPrintf("-----------------------------below is RA----------------------------------\n");
printf("-----------------------------below is RA----------------------------------\n");
Big8wPrint(&RA.x);
Big8wPrint(&RA.y);
JoinIDhid(ID_Alice, 5, hid, Id_Alice_hid);
h1 = H(Id_Alice_hid, 5 + 1, 0x01);
KPrintf("-----------------------------below is h1----------------------------------\n");
printf("-----------------------------below is h1----------------------------------\n");
Big8wPrint(&h1);
QA = G1pointAdd(Ppub_e, G1pointMult(h1, P1));
KPrintf("-----------------------------below is QA----------------------------------\n");
printf("-----------------------------below is QA----------------------------------\n");
Big8wPrint(&QA.x);
Big8wPrint(&QA.y);
RB = G1pointMult(rB, QA);
KPrintf("-----------------------------below is RB----------------------------------\n");
printf("-----------------------------below is RB----------------------------------\n");
Big8wPrint(&RB.x);
Big8wPrint(&RB.y);
g1 = BiLinearPairing(RA, deB);
KPrintf("-----------------------------below is g1----------------------------------\n");
printf("-----------------------------below is g1----------------------------------\n");
Q12Print(&g1);
g2 = BiLinearPairing(Ppub_e, P2);
g2 = Q12PowerMod(g2, rB);
KPrintf("-----------------------------below is g2----------------------------------\n");
printf("-----------------------------below is g2----------------------------------\n");
Q12Print(&g2);
g3 = Q12PowerMod(g1, rB);
KPrintf("-----------------------------below is g3----------------------------------\n");
printf("-----------------------------below is g3----------------------------------\n");
Q12Print(&g3);
JoinIDAIDBRARBg123(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, strA);
KDF(strA, 5 + 3 + BIG8W_BYTESIZE * 2 * 2 + BIG8W_BYTESIZE * 12 * 3, klen, SKB);
KPrintf("-----------------------------below is SKB---------------------------------\n");
printf("-----------------------------below is SKB---------------------------------\n");
for (i = 0; i < klen/8; i++){
KPrintf("%02x", SKB[i]);
printf("%02x", SKB[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
}
KPrintf("\n");
KPrintf("-----------------------------below is SB----------------------------------\n");
HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x82, SB);
HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x83, S2);
for (i = 0; i < 256/8; i++){
KPrintf("%02x", SB[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
}
KPrintf("\n");
g1 = BiLinearPairing(Ppub_e, P2);
g1 = Q12PowerMod(g1, rA);
KPrintf("-----------------------------below is g1----------------------------------\n");
Q12Print(&g1);
g2 = BiLinearPairing(RB, deA);
KPrintf("-----------------------------below is g2----------------------------------\n");
Q12Print(&g2);
g3 = Q12PowerMod(g2, rA);
KPrintf("-----------------------------below is g3----------------------------------\n");
Q12Print(&g3);
KPrintf("-----------------------------below is S1----------------------------------\n");
HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x82, S1);
for (i = 0; i < 256/8; i++){
KPrintf("%02x", S1[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
}
KPrintf("\n");
KDF(strA, 5 + 3 + BIG8W_BYTESIZE * 2 * 2 + BIG8W_BYTESIZE * 12 * 3, klen, SKA);
KPrintf("-----------------------------below is SKA---------------------------------\n");
for (i = 0; i < klen/8; i++){
KPrintf("%02x", SKA[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
printf("\n");
KPrintf("-----------------------------below is SA----------------------------------\n");
printf("-----------------------------below is SB----------------------------------\n");
HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x82, SB);
HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x83, S2);
for (i = 0; i < 256/8; i++){
printf("%02x", SB[i]);
if (((i+1)&0x3) == 0)
printf(" ");
if (((i + 1) % 32) == 0)
printf("\n");
}
printf("\n");
g1 = BiLinearPairing(Ppub_e, P2);
g1 = Q12PowerMod(g1, rA);
printf("-----------------------------below is g1----------------------------------\n");
Q12Print(&g1);
g2 = BiLinearPairing(RB, deA);
printf("-----------------------------below is g2----------------------------------\n");
Q12Print(&g2);
g3 = Q12PowerMod(g2, rA);
printf("-----------------------------below is g3----------------------------------\n");
Q12Print(&g3);
printf("-----------------------------below is S1----------------------------------\n");
HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x82, S1);
for (i = 0; i < 256/8; i++){
printf("%02x", S1[i]);
if (((i+1)&0x3) == 0)
printf(" ");
if (((i + 1) % 32) == 0)
printf("\n");
}
printf("\n");
KDF(strA, 5 + 3 + BIG8W_BYTESIZE * 2 * 2 + BIG8W_BYTESIZE * 12 * 3, klen, SKA);
printf("-----------------------------below is SKA---------------------------------\n");
for (i = 0; i < klen/8; i++){
printf("%02x", SKA[i]);
if (((i+1)&0x3) == 0)
printf(" ");
if (((i + 1) % 32) == 0)
printf("\n");
}
printf("\n");
printf("-----------------------------below is SA----------------------------------\n");
HashTwice(ID_Alice, 5, ID_Bob, 3, &RA, &RB, &g1, &g2, &g3, 0x83, SA);
for (i = 0; i < 256/8; i++){
KPrintf("%02x", SA[i]);
printf("%02x", SA[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
KPrintf("-----------------------------below is S2----------------------------------\n");
printf("-----------------------------below is S2----------------------------------\n");
for (i = 0; i < 256/8; i++){
KPrintf("%02x", S2[i]);
printf("%02x", S2[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
// Following is test of API, random big number generated in SM9KeyExchangeProduceR, so result is different from the former.
// To get the same result, you should delete the line "*r = RandomNumGenerate();" in function SM9KeyExchangeR. (or set as note)
KPrintf("---------------------------SM9 key exchange API test----------------------\n");
printf("---------------------------SM9 key exchange API test----------------------\n");
SM9KeyExchangeProduceR(ID_Bob, 3, &rA, &RA, Ppub_e);
KPrintf("-----------------------------below is RA----------------------------------\n");
printf("-----------------------------below is RA----------------------------------\n");
Big8wPrint(&RA.x);
Big8wPrint(&RA.y);
SM9KeyExchangeProduceR(ID_Alice, 5, &rB, &RB, Ppub_e);
KPrintf("-----------------------------below is RB----------------------------------\n");
printf("-----------------------------below is RB----------------------------------\n");
Big8wPrint(&RB.x);
Big8wPrint(&RB.y);
SM9KeyExchangeProduceKey(&RA, &RB, &rA, klen, ID_Alice, 5, ID_Bob, 3, &g1, &g2, &g3, SKA, true, Ppub_e, deA);
KPrintf("-----------------------------below is g1----------------------------------\n");
printf("-----------------------------below is g1----------------------------------\n");
Q12Print(&g1);
KPrintf("-----------------------------below is g2----------------------------------\n");
printf("-----------------------------below is g2----------------------------------\n");
Q12Print(&g2);
KPrintf("-----------------------------below is g3----------------------------------\n");
printf("-----------------------------below is g3----------------------------------\n");
Q12Print(&g3);
KPrintf("-----------------------------below is SKA---------------------------------\n");
printf("-----------------------------below is SKA---------------------------------\n");
for (i = 0; i < klen/8; i++){
KPrintf("%02x", SKA[i]);
printf("%02x", SKA[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
// g1,g2,g3 changed
// SM9KeyExchangeProduceKey(&RA, &RB, &rB, klen, ID_Alice, 5, ID_Bob, 3, &g1, &g2, &g3, SKB, false, Ppub_e, deB);
SM9KeyExchangeVerifyKey(&g1, &g2, &g3, &RA, &RB, ID_Alice, 5, ID_Bob, 3, S1, SA);
KPrintf("-----------------------------below is SA----------------------------------\n");
printf("-----------------------------below is SA----------------------------------\n");
for (i = 0; i < 256/8; i++){
KPrintf("%02x", SA[i]);
printf("%02x", SA[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
KPrintf("-----------------------------below is S1----------------------------------\n");
printf("-----------------------------below is S1----------------------------------\n");
for (i = 0; i < 256/8; i++){
KPrintf("%02x", S1[i]);
printf("%02x", S1[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
SM9KeyExchangeVerifyKey(&g1, &g2, &g3, &RA, &RB, ID_Alice, 5, ID_Bob, 3, SB, S2);
KPrintf("-----------------------------below is SB----------------------------------\n");
printf("-----------------------------below is SB----------------------------------\n");
for (i = 0; i < 256/8; i++){
KPrintf("%02x", SB[i]);
printf("%02x", SB[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
KPrintf("-----------------------------below is S2----------------------------------\n");
printf("-----------------------------below is S2----------------------------------\n");
for (i = 0; i < 256/8; i++){
KPrintf("%02x", S2[i]);
printf("%02x", S2[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
free(strA);
free(strB);
@@ -535,25 +535,25 @@ void SM9PackDepackTest()
SM9Init();
Ppub_e = G1pointMult(ke, P1);
KPrintf("-----------------------------below is Ppub_e------------------------------\n");
printf("-----------------------------below is Ppub_e------------------------------\n");
Big8wPrint(&Ppub_e.x);
Big8wPrint(&Ppub_e.y);
JoinIDhid(ID_Bob, 3, hid, ID_Bob_hid);
t1 = H(ID_Bob_hid, 3 + 1, 0x01);
KPrintf("-----------------------------below is H1()--------------------------------\n");
printf("-----------------------------below is H1()--------------------------------\n");
Big8wPrint(&t1);
t1 = Big8wAddMod(t1, ke, curve.N);
KPrintf("-----------------------------below is t1----------------------------------\n");
printf("-----------------------------below is t1----------------------------------\n");
Big8wPrint(&t1);
t1 = Big8wReverse(t1, curve.N);
t2 = Big8wMultMod(ke, t1, curve.N);
KPrintf("-----------------------------below is t2----------------------------------\n");
printf("-----------------------------below is t2----------------------------------\n");
Big8wPrint(&t2);
deB = G2PointMult(t2, P2);
KPrintf("------------------------------below is deB--------------------------------\n");
printf("------------------------------below is deB--------------------------------\n");
Big8wPrint(&deB.x.high);
Big8wPrint(&deB.x.low);
Big8wPrint(&deB.y.high);
@@ -562,53 +562,53 @@ void SM9PackDepackTest()
QB = G1pointAdd(
G1pointMult(H(ID_Bob_hid, 3 + 1, 0x01), P1),
Ppub_e);
KPrintf("-----------------------------below is QB----------------------------------\n");
printf("-----------------------------below is QB----------------------------------\n");
Big8wPrint(&QB.x);
Big8wPrint(&QB.y);
C = G1pointMult(r, QB);
KPrintf("-----------------------------below is C----------------------------------\n");
printf("-----------------------------below is C----------------------------------\n");
Big8wPrint(&C.x);
Big8wPrint(&C.y);
g = BiLinearPairing(Ppub_e, P2);
KPrintf("-----------------------------below is g----------------------------------\n");
printf("-----------------------------below is g----------------------------------\n");
Q12Print(&g);
w = Q12PowerMod(g, r);
KPrintf("-----------------------------below is w----------------------------------\n");
printf("-----------------------------below is w----------------------------------\n");
Q12Print(&w);
JoinCwID(&C, &w, ID_Bob, 3, c_w_id);
KDF(c_w_id, c_w_id_len, klen, K_encap);
KPrintf("-----------------------------below is K-----------------------------------\n");
printf("-----------------------------below is K-----------------------------------\n");
for (i = 0; i < klen / 8; i++){
KPrintf("%02x", K_encap[i]);
printf("%02x", K_encap[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
w = BiLinearPairing(C, deB);
KPrintf("-----------------------------below is w'----------------------------------\n");
printf("-----------------------------below is w'----------------------------------\n");
Q12Print(&w);
JoinCwID(&C, &w, ID_Bob, 3, c_w_id);
KDF(c_w_id, c_w_id_len, klen, K_encap);
KPrintf("-----------------------------below is K'----------------------------------\n");
printf("-----------------------------below is K'----------------------------------\n");
for (i = 0; i < klen / 8; i++){
KPrintf("%02x", K_encap[i]);
printf("%02x", K_encap[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
KPrintf("pack and depack done\n");
printf("\n");
printf("pack and depack done\n");
free(ID_Bob_hid);
free(K_encap);
@@ -671,22 +671,22 @@ void SM9EncryptDecryptTest()
SM9Init();
Ppub_e = G1pointMult(ke, P1);
KPrintf("-----------------------------below is Ppub_e------------------------------\n");
printf("-----------------------------below is Ppub_e------------------------------\n");
Big8wPrint(&Ppub_e.x);
Big8wPrint(&Ppub_e.y);
JoinIDhid(ID_Bob, 3, hid, ID_Bob_hid);
t1 = Big8wAddMod(H(ID_Bob_hid, 3 + 1, 0x01), ke, curve.N);
KPrintf("-----------------------------below is t1----------------------------------\n");
printf("-----------------------------below is t1----------------------------------\n");
Big8wPrint(&t1);
t1 = Big8wReverse(t1, curve.N);
t2 = Big8wMultMod(ke, t1, curve.N);
KPrintf("-----------------------------below is t2----------------------------------\n");
printf("-----------------------------below is t2----------------------------------\n");
Big8wPrint(&t2);
deB = G2PointMult(t2, P2);
KPrintf("------------------------------below is deB--------------------------------\n");
printf("------------------------------below is deB--------------------------------\n");
Big8wPrint(&deB.x.high);
Big8wPrint(&deB.x.low);
Big8wPrint(&deB.y.high);
@@ -695,46 +695,46 @@ void SM9EncryptDecryptTest()
QB = G1pointAdd(
G1pointMult(H(ID_Bob_hid, 3 + 1, 0x01), P1),
Ppub_e);
KPrintf("-----------------------------below is QB----------------------------------\n");
printf("-----------------------------below is QB----------------------------------\n");
Big8wPrint(&QB.x);
Big8wPrint(&QB.y);
C1 = G1pointMult(r, QB);
KPrintf("-----------------------------below is C1----------------------------------\n");
printf("-----------------------------below is C1----------------------------------\n");
Big8wPrint(&C1.x);
Big8wPrint(&C1.y);
g = BiLinearPairing(Ppub_e, P2);
KPrintf("-----------------------------below is g-----------------------------------\n");
printf("-----------------------------below is g-----------------------------------\n");
Q12Print(&g);
w = Q12PowerMod(g, r);
KPrintf("-----------------------------below is w-----------------------------------\n");
printf("-----------------------------below is w-----------------------------------\n");
Q12Print(&w);
JoinCwID(&C1, &w, ID_Bob, 3, C_w_id);
KDF(C_w_id, c_w_id_len, klen, K);
KPrintf("-----------------------------below is K-----------------------------------\n");
printf("-----------------------------below is K-----------------------------------\n");
for (i = 0; i < klen / 8; i++) {
KPrintf("%02x", K[i]);
printf("%02x", K[i]);
if (((i+1)&0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
XOR(message, mlen / 8, K, C2);
KPrintf("-----------------------------below is C2----------------------------------\n");
printf("-----------------------------below is C2----------------------------------\n");
for (i = 0; i < mlen / 8; i++) {
KPrintf("%02x", C2[i]);
printf("%02x", C2[i]);
if (((i + 1) & 0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
for (i = 0; i < mlen / 8; i++)
C2K2[i] = C2[i];
@@ -742,15 +742,15 @@ void SM9EncryptDecryptTest()
C2K2[i] = K[i];
sm3(C2K2, (mlen / 8) + (K2_len / 8), C3);
KPrintf("----------------------------below is C3-----------------------------------\n");
printf("----------------------------below is C3-----------------------------------\n");
for (i = 0; i < 256/8; i++) {
KPrintf("%02x", C3[i]);
printf("%02x", C3[i]);
if (((i + 1) & 0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
i = 0;
Big8wIntou8string(&C1.x, C, i);
@@ -764,44 +764,44 @@ void SM9EncryptDecryptTest()
for (; i < BIG8W_BYTESIZE * 2 + (256 / 8) + (mlen / 8); i++)
C[i] = C2[i - (BIG8W_BYTESIZE * 2 + 256 / 8)];
KPrintf("----------------------------below is C------------------------------------\n");
printf("----------------------------below is C------------------------------------\n");
for (i = 0; i < BIG8W_BYTESIZE * 2 + (256 / 8) + (mlen / 8); i++) {
KPrintf("%02x", C[i]);
printf("%02x", C[i]);
if (((i + 1) & 0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
// decrypt
w = BiLinearPairing(C1, deB);
KPrintf("----------------------------below is w'-----------------------------------\n");
printf("----------------------------below is w'-----------------------------------\n");
Q12Print(&w);
JoinCwID(&C1, &w, ID_Bob, 3, C_w_id);
KDF(C_w_id, c_w_id_len, klen, K);
KPrintf("----------------------------below is K'----------------------------------\n");
printf("----------------------------below is K'----------------------------------\n");
for (i = 0; i < (klen / 8); i++) {
KPrintf("%02x", K[i]);
printf("%02x", K[i]);
if (((i + 1) & 0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
XOR(C2, mlen / 8, K, message);
KPrintf("----------------------------below is M'----------------------------------\n");
printf("----------------------------below is M'----------------------------------\n");
for (i = 0; i < mlen / 8; i++) {
KPrintf("%02x", message[i]);
printf("%02x", message[i]);
if (((i + 1) & 0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
for (i = 0; i < mlen / 8; i++)
C2K2[i] = C2[i];
@@ -809,53 +809,53 @@ void SM9EncryptDecryptTest()
C2K2[i] = K[i];
sm3(C2K2, (mlen / 8) + (K2_len / 8), C3);
KPrintf("----------------------------below is u-----------------------------------\n");
printf("----------------------------below is u-----------------------------------\n");
for (i = 0; i < 256 / 8; i++) {
KPrintf("%02x", C3[i]);
printf("%02x", C3[i]);
if (((i + 1) & 0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
KPrintf("decrypted message:\n%s\n", message);
printf("decrypted message:\n%s\n", message);
KPrintf("-------------SM9EncryptWithKDF and SM9DecryptWithKDF test----------------\n");
printf("-------------SM9EncryptWithKDF and SM9DecryptWithKDF test----------------\n");
SM9EncryptWithKDF(message, mlen, K2_len, ID_Bob, 3, hid, Ppub_e, C);
KPrintf("------------------below is C, encrypted message--------------------------\n");
printf("------------------below is C, encrypted message--------------------------\n");
for (i = 0; i < Cbyteslen_KDF; i++) {
KPrintf("%02x", C[i]);
printf("%02x", C[i]);
if (((i + 1) & 0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
SM9DecryptWithKDF(ID_Bob, 3, message, 20 * 8, K2_len, C, deB);
KPrintf("---------------below is M, decrypted message in test.c-------------------\n");
KPrintf("message:\n%s\n", message);
printf("---------------below is M, decrypted message in test.c-------------------\n");
printf("message:\n%s\n", message);
KPrintf("-------------SM9EncryptWithSM4 and SM9DecryptWithSM4 test----------------\n");
printf("-------------SM9EncryptWithSM4 and SM9DecryptWithSM4 test----------------\n");
SM9EncryptWithSM4(message, mlen, K1_len, K2_len, ID_Bob, 3, hid, Ppub_e, C_SM4);
KPrintf("---------------below is C_SM4 in test.c, encrypted message---------------\n");
printf("---------------below is C_SM4 in test.c, encrypted message---------------\n");
for (i = 0; i < Cbyteslen_SM4; i++) {
KPrintf("%02x", C_SM4[i]);
printf("%02x", C_SM4[i]);
if (((i + 1) & 0x3) == 0)
KPrintf(" ");
printf(" ");
if (((i + 1) % 32) == 0)
KPrintf("\n");
printf("\n");
}
KPrintf("\n");
printf("\n");
if (!SM9DecryptWithSM4(ID_Bob, 3, sm4msg, (mlen / 8), K1_len, K2_len, C_SM4, Cbyteslen_SM4, deB))
KPrintf("SM9DecryptWithSM4 failed\n");
KPrintf("---------------------below is M, decrypted message-----------------------\n");
printf("SM9DecryptWithSM4 failed\n");
printf("---------------------below is M, decrypted message-----------------------\n");
for (i = 0; i < (mlen / 8); i++)
KPrintf("%c", sm4msg[i]);
KPrintf("\n");
printf("%c", sm4msg[i]);
printf("\n");
free(C_w_id);
free(K);

View File

@@ -177,6 +177,22 @@ FAR void *realloc(FAR void *oldmem, size_t size);
FAR void *calloc(size_t n, size_t elem_size);
void free(FAR void *mem);
/*********************shell***********************/
//for int func(int argc, char *agrv[])
#define PRIV_SHELL_CMD_MAIN_ATTR
//for int func(int i, char ch, char *str)
#define PRIV_SHELL_CMD_FUNC_ATTR
/**
* @brief Priv-shell Command definition
*
* @param _func Command function
* @param _desc Command description
* @param _attr Command attributes if need
*/
#define PRIV_SHELL_CMD_FUNCTION(_func, _desc, _attr)
/**********************mutex**************************/
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr);

View File

@@ -165,6 +165,23 @@ struct PrivIoctlCfg
void *args;
};
/*********************shell***********************/
//for int func(int argc, char *agrv[])
#define PRIV_SHELL_CMD_MAIN_ATTR
//for int func(int i, char ch, char *str)
#define PRIV_SHELL_CMD_FUNC_ATTR
/**
* @brief Priv-shell Command definition
*
* @param _func Command function
* @param _desc Command description
* @param _attr Command attributes if need
*/
#define PRIV_SHELL_CMD_FUNCTION(_func, _desc, _attr) \
MSH_CMD_EXPORT(_func, _desc)
/**********************mutex**************************/
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr);

View File

@@ -24,6 +24,7 @@
#include <pthread.h>
#include <signal.h>
#include <semaphore.h>
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <time.h>
@@ -200,6 +201,24 @@ typedef struct
#define PRIV_TOUCH_DEV "/dev/touch_dev"
#define MY_INDEV_X BSP_LCD_Y_MAX
#define MY_INDEV_Y BSP_LCD_X_MAX
/*********************shell***********************/
//for int func(int argc, char *agrv[])
#define PRIV_SHELL_CMD_MAIN_ATTR (SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN))
//for int func(int i, char ch, char *str)
#define PRIV_SHELL_CMD_FUNC_ATTR (SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC))
/**
* @brief Priv-shell Command definition
*
* @param _func Command function
* @param _desc Command description
* @param _attr Command attributes if need
*/
#define PRIV_SHELL_CMD_FUNCTION(_func, _desc, _attr) \
SHELL_EXPORT_CMD(_attr, _func, _func, _desc)
/**********************mutex**************************/
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr);