Browse Source

move security to APP_Framework

master
Wang_Weigen 10 months ago
parent
commit
ce480336d8
  1. 1
      APP_Framework/Framework/Kconfig
  2. 3
      APP_Framework/Framework/Makefile
  3. 0
      APP_Framework/Framework/security/Kconfig
  4. 0
      APP_Framework/Framework/security/Makefile
  5. 0
      APP_Framework/Framework/security/crypto/Makefile
  6. 2
      APP_Framework/Framework/security/crypto/include/bignum.h
  7. 0
      APP_Framework/Framework/security/crypto/include/ecc.h
  8. 0
      APP_Framework/Framework/security/crypto/include/join.h
  9. 0
      APP_Framework/Framework/security/crypto/include/qn.h
  10. 0
      APP_Framework/Framework/security/crypto/include/sm3.h
  11. 0
      APP_Framework/Framework/security/crypto/include/sm4.h
  12. 0
      APP_Framework/Framework/security/crypto/include/sm9.h
  13. 0
      APP_Framework/Framework/security/crypto/include/sm9_para.h
  14. 0
      APP_Framework/Framework/security/crypto/include/sm9_test.h
  15. 0
      APP_Framework/Framework/security/crypto/include/sm9_util.h
  16. 0
      APP_Framework/Framework/security/crypto/sm3/sm3.c
  17. 0
      APP_Framework/Framework/security/crypto/sm3/sm3_hmac.c
  18. 0
      APP_Framework/Framework/security/crypto/sm4/sm4_common.c
  19. 0
      APP_Framework/Framework/security/crypto/sm4/sm4_enc_mode.c
  20. 0
      APP_Framework/Framework/security/crypto/sm4/sms4_enc.c
  21. 0
      APP_Framework/Framework/security/crypto/sm4/sms4_lcl.h
  22. 0
      APP_Framework/Framework/security/crypto/sm4/sms4_setkey.c
  23. 0
      APP_Framework/Framework/security/crypto/sm9/bignum.c
  24. 0
      APP_Framework/Framework/security/crypto/sm9/ecc.c
  25. 0
      APP_Framework/Framework/security/crypto/sm9/join.c
  26. 0
      APP_Framework/Framework/security/crypto/sm9/qn.c
  27. 0
      APP_Framework/Framework/security/crypto/sm9/sm9.c
  28. 0
      APP_Framework/Framework/security/crypto/sm9/sm9_para.c
  29. 0
      APP_Framework/Framework/security/crypto/sm9/sm9_util.c
  30. 2
      APP_Framework/Framework/security/crypto/test/sm3_test.c
  31. 2
      APP_Framework/Framework/security/crypto/test/sm4_test.c
  32. 0
      APP_Framework/Framework/security/crypto/test/sm9_test.c
  33. 9
      APP_Framework/lib/app_newlib/fs_syscalls.c
  34. 15
      Ubiquitous/XiUOS/framework/Kconfig
  35. 3
      Ubiquitous/XiUOS/framework/Makefile
  36. 31
      Ubiquitous/XiUOS/framework/connection/Adapter/Kconfig
  37. 32
      Ubiquitous/XiUOS/framework/connection/Adapter/Makefile
  38. 3
      Ubiquitous/XiUOS/framework/connection/Adapter/bluetooth/Makefile
  39. 45
      Ubiquitous/XiUOS/framework/connection/Adapter/bluetooth/xs_adaper_bluetooth_register.c
  40. 155
      Ubiquitous/XiUOS/framework/connection/Adapter/bluetooth/xs_adapter_bluetooth.c
  41. 5
      Ubiquitous/XiUOS/framework/connection/Adapter/ethernet/Makefile
  42. 409
      Ubiquitous/XiUOS/framework/connection/Adapter/ethernet/xs_adapterAT_ethernet.c
  43. 70
      Ubiquitous/XiUOS/framework/connection/Adapter/ethernet/xs_adapterAT_ethernet_register.c
  44. 72
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter.h
  45. 94
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_at.h
  46. 81
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_at_agent.h
  47. 48
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_at_ethernet.h
  48. 57
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_at_nbiot.h
  49. 50
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_at_wifi.h
  50. 41
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_bluetooth.h
  51. 77
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_def.h
  52. 184
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_lora.h
  53. 43
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_manager.h
  54. 41
      Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_zigbee.h
  55. 30
      Ubiquitous/XiUOS/framework/connection/Adapter/lora/Kconfig
  56. 3
      Ubiquitous/XiUOS/framework/connection/Adapter/lora/Makefile
  57. 849
      Ubiquitous/XiUOS/framework/connection/Adapter/lora/xs_adapter_lora.c
  58. 3
      Ubiquitous/XiUOS/framework/connection/Adapter/nbiot/Makefile
  59. 3
      Ubiquitous/XiUOS/framework/connection/Adapter/nbiot/bc28/Makefile
  60. 339
      Ubiquitous/XiUOS/framework/connection/Adapter/nbiot/bc28/xs_adapter_at_nbiot.c
  61. 69
      Ubiquitous/XiUOS/framework/connection/Adapter/nbiot/bc28/xs_adapter_at_nbiot_register.c
  62. 4
      Ubiquitous/XiUOS/framework/connection/Adapter/src/Makefile
  63. 485
      Ubiquitous/XiUOS/framework/connection/Adapter/src/xs_adapter_at_agent.c
  64. 169
      Ubiquitous/XiUOS/framework/connection/Adapter/src/xs_adapter_manager.c
  65. 4
      Ubiquitous/XiUOS/framework/connection/Adapter/wifi/Makefile
  66. 482
      Ubiquitous/XiUOS/framework/connection/Adapter/wifi/xs_adapter_at_wifi.c
  67. 73
      Ubiquitous/XiUOS/framework/connection/Adapter/wifi/xs_adapter_at_wifi_register.c
  68. 11
      Ubiquitous/XiUOS/framework/connection/Adapter/zigbee/Kconfig
  69. 3
      Ubiquitous/XiUOS/framework/connection/Adapter/zigbee/Makefile
  70. 45
      Ubiquitous/XiUOS/framework/connection/Adapter/zigbee/xs_adaper_zigbee_register.c
  71. 190
      Ubiquitous/XiUOS/framework/connection/Adapter/zigbee/xs_adapter_zigbee.c
  72. 11
      Ubiquitous/XiUOS/framework/connection/Kconfig
  73. 5
      Ubiquitous/XiUOS/framework/connection/Makefile
  74. 2
      Ubiquitous/XiUOS/framework/control/Kconfig
  75. 5
      Ubiquitous/XiUOS/framework/intelligent/Kconfig
  76. 3
      Ubiquitous/XiUOS/framework/intelligent/Makefile
  77. 4
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/Kconfig
  78. 89
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/Makefile
  79. 203
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/LICENSE
  80. 139
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/core/public/version.h
  81. 484
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/c/builtin_op_data.h
  82. 92
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/c/c_api_types.h
  83. 236
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/c/common.c
  84. 913
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/c/common.h
  85. 38
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/core/api/error_reporter.cc
  86. 59
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/core/api/error_reporter.h
  87. 1945
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/core/api/flatbuffer_conversions.cc
  88. 301
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/core/api/flatbuffer_conversions.h
  89. 67
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/core/api/op_resolver.cc
  90. 60
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/core/api/op_resolver.h
  91. 194
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/core/api/profiler.h
  92. 50
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/core/api/tensor_utils.cc
  93. 28
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/core/api/tensor_utils.h
  94. 1037
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/kernels/internal/common.h
  95. 117
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/kernels/internal/compatibility.h
  96. 40
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/kernels/internal/cppmath.h
  97. 35
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/kernels/internal/max.h
  98. 35
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/kernels/internal/min.h
  99. 40
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/kernels/internal/optimized/neon_check.h
  100. 122
      Ubiquitous/XiUOS/framework/intelligent/tflite-mcu/source/tensorflow/lite/kernels/internal/portable_tensor.h

1
APP_Framework/Framework/Kconfig

@ -22,6 +22,7 @@ menu "Framework"
source "$APP_DIR/Framework/connection/Kconfig"
source "$APP_DIR/Framework/knowing/Kconfig"
source "$APP_DIR/Framework/control/Kconfig"
source "$APP_DIR/Framework/security/Kconfig"
endmenu

3
APP_Framework/Framework/Makefile

@ -16,6 +16,9 @@ ifeq ($(CONFIG_SUPPORT_CONTROL_FRAMEWORK),y)
SRC_DIR += control
endif
ifeq ($(CONFIG_CRYPTO),y)
SRC_DIR += security
endif
include $(KERNEL_ROOT)/compiler.mk

0
Ubiquitous/XiUOS/framework/security/Kconfig → APP_Framework/Framework/security/Kconfig

0
Ubiquitous/XiUOS/framework/security/Makefile → APP_Framework/Framework/security/Makefile

0
Ubiquitous/XiUOS/framework/security/crypto/Makefile → APP_Framework/Framework/security/crypto/Makefile

2
Ubiquitous/XiUOS/framework/security/crypto/include/bignum.h → APP_Framework/Framework/security/crypto/include/bignum.h

@ -27,7 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <xiuos.h>
#include <transform.h>
#define BIGNUMBER_SIZE_8WORD 8
#define BIGNUMBER_SIZE_16WORD 16

0
Ubiquitous/XiUOS/framework/security/crypto/include/ecc.h → APP_Framework/Framework/security/crypto/include/ecc.h

0
Ubiquitous/XiUOS/framework/security/crypto/include/join.h → APP_Framework/Framework/security/crypto/include/join.h

0
Ubiquitous/XiUOS/framework/security/crypto/include/qn.h → APP_Framework/Framework/security/crypto/include/qn.h

0
Ubiquitous/XiUOS/framework/security/crypto/include/sm3.h → APP_Framework/Framework/security/crypto/include/sm3.h

0
Ubiquitous/XiUOS/framework/security/crypto/include/sm4.h → APP_Framework/Framework/security/crypto/include/sm4.h

0
Ubiquitous/XiUOS/framework/security/crypto/include/sm9.h → APP_Framework/Framework/security/crypto/include/sm9.h

0
Ubiquitous/XiUOS/framework/security/crypto/include/sm9_para.h → APP_Framework/Framework/security/crypto/include/sm9_para.h

0
Ubiquitous/XiUOS/framework/security/crypto/include/sm9_test.h → APP_Framework/Framework/security/crypto/include/sm9_test.h

0
Ubiquitous/XiUOS/framework/security/crypto/include/sm9_util.h → APP_Framework/Framework/security/crypto/include/sm9_util.h

0
Ubiquitous/XiUOS/framework/security/crypto/sm3/sm3.c → APP_Framework/Framework/security/crypto/sm3/sm3.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm3/sm3_hmac.c → APP_Framework/Framework/security/crypto/sm3/sm3_hmac.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm4/sm4_common.c → APP_Framework/Framework/security/crypto/sm4/sm4_common.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm4/sm4_enc_mode.c → APP_Framework/Framework/security/crypto/sm4/sm4_enc_mode.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm4/sms4_enc.c → APP_Framework/Framework/security/crypto/sm4/sms4_enc.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm4/sms4_lcl.h → APP_Framework/Framework/security/crypto/sm4/sms4_lcl.h

0
Ubiquitous/XiUOS/framework/security/crypto/sm4/sms4_setkey.c → APP_Framework/Framework/security/crypto/sm4/sms4_setkey.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm9/bignum.c → APP_Framework/Framework/security/crypto/sm9/bignum.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm9/ecc.c → APP_Framework/Framework/security/crypto/sm9/ecc.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm9/join.c → APP_Framework/Framework/security/crypto/sm9/join.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm9/qn.c → APP_Framework/Framework/security/crypto/sm9/qn.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm9/sm9.c → APP_Framework/Framework/security/crypto/sm9/sm9.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm9/sm9_para.c → APP_Framework/Framework/security/crypto/sm9/sm9_para.c

0
Ubiquitous/XiUOS/framework/security/crypto/sm9/sm9_util.c → APP_Framework/Framework/security/crypto/sm9/sm9_util.c

2
Ubiquitous/XiUOS/framework/security/crypto/test/sm3_test.c → APP_Framework/Framework/security/crypto/test/sm3_test.c

@ -19,7 +19,7 @@
*/
#include <sm3.h>
#include <xiuos.h>
#include <transform.h>
void sm3_test_case(){
uint8_t result[SM3_DIGEST_LENGTH] = { 0 };

2
Ubiquitous/XiUOS/framework/security/crypto/test/sm4_test.c → APP_Framework/Framework/security/crypto/test/sm4_test.c

@ -19,7 +19,7 @@
*/
#include <sm4.h>
#include <xiuos.h>
#include <transform.h>
void sm4_test_case(){
unsigned char ukey[16] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe ,0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 };

0
Ubiquitous/XiUOS/framework/security/crypto/test/sm9_test.c → APP_Framework/Framework/security/crypto/test/sm9_test.c

9
APP_Framework/lib/app_newlib/fs_syscalls.c

@ -96,12 +96,3 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
{
return write(fd, buf, nbytes);
}
void exit(int __status);
void _exit(int __status){}
void _kill(int k)
{}
int _getpid(void)
{
}

15
Ubiquitous/XiUOS/framework/Kconfig

@ -1,15 +0,0 @@
menu "APP Framework"
source "$KERNEL_DIR/framework/connection/Kconfig"
source "$KERNEL_DIR/framework/intelligent/Kconfig"
source "$KERNEL_DIR/framework/control/Kconfig"
source "$KERNEL_DIR/lib/Kconfig"
source "$KERNEL_DIR/framework/security/Kconfig"
endmenu

3
Ubiquitous/XiUOS/framework/Makefile

@ -1,3 +0,0 @@
SRC_DIR := intelligent security
include $(KERNEL_ROOT)/compiler.mk

31
Ubiquitous/XiUOS/framework/connection/Adapter/Kconfig

@ -1,31 +0,0 @@
menuconfig CONNECTION_COMMUNICATION_WIFI
bool "Enable Wifi"
default n
menuconfig CONNECTION_COMMUNICATION_LORA
bool "Enable LORA"
default n
if CONNECTION_COMMUNICATION_LORA
source "$KERNEL_DIR/framework/connection/Adapter/lora/Kconfig"
endif
menuconfig CONNECTION_COMMUNICATION_ETHERNET
bool "Enable Ethernet"
default n
menuconfig CONNECTION_COMMUNICATION_ZIGBEE
bool "Enable Zigbee"
default n
menuconfig CONNECTION_COMMUNICATION_NB_IOT
bool "Enable NB-IOT"
default n
menuconfig CONNECTION_COMMUNICATION_4G
bool "Enable 4G"
default n
menuconfig CONNECTION_COMMUNICATION_BLUETOOTH
bool "Enable BlueTooth"
default n

32
Ubiquitous/XiUOS/framework/connection/Adapter/Makefile

@ -1,32 +0,0 @@
SRC_DIR := src
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_LORA), y)
SRC_DIR += lora
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_ETHERNET), y)
SRC_DIR += ethernet
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_WIFI), y)
SRC_DIR += wifi
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_ZIGBEE), y)
SRC_DIR += zigbee
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_NB_IOT), y)
SRC_DIR += nbiot
endif
# ifeq ($(CONFIG_CONNECTION_COMMUNICATION_4G), y)
# SRC_DIR += 4G
# endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_BLUETOOTH), y)
SRC_DIR += bluetooth
endif
include $(KERNEL_ROOT)/compiler.mk

3
Ubiquitous/XiUOS/framework/connection/Adapter/bluetooth/Makefile

@ -1,3 +0,0 @@
SRC_FILES := xs_adapter_bluetooth.c xs_adaper_bluetooth_register.c
include $(KERNEL_ROOT)/compiler.mk

45
Ubiquitous/XiUOS/framework/connection/Adapter/bluetooth/xs_adaper_bluetooth_register.c

@ -1,45 +0,0 @@
/*
* 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: xs_AdaperBluetooth_register.c
* @brief: register Bluetooth in initialization
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021/4/30
*
*/
#include <xs_adapter_bluetooth.h>
#include <xs_adapter_manager.h>
#include <string.h>
/* initialize to the register list*/
int RegisterAdapterBluetooth(void)
{
static struct AdapterBluetooth bluetooth_adapter;
memset(&bluetooth_adapter, 0, sizeof(bluetooth_adapter));
static struct AdapterDone bluetooth_send_done = {
.NetAiitOpen = BluetoothOpen,
.NetAiitClose = BluetoothClose,
.NetAiitSend = BluetoothSend,
.NetAiitReceive = BluetoothReceive,
.NetAiitJoin = NULL,
.NetAiitIoctl = NULL,
};
bluetooth_adapter.parent.done = bluetooth_send_done;
bluetooth_adapter.name = "Bluetooth";
BluetoothAdapterInit();
BluetoothAdapterRegister((adapter_t)&bluetooth_adapter);
return EOK;
}

155
Ubiquitous/XiUOS/framework/connection/Adapter/bluetooth/xs_adapter_bluetooth.c

@ -1,155 +0,0 @@
/*
* 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: xs_Adapterxs_adapter_bluetooth.c
* @brief: bluetooth open close function
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021/4/30
*
*/
#include <xs_adapter_manager.h>
#include "xs_adapter_bluetooth.h"
#include <user_api.h>
#include <bus_serial.h>
#include <dev_serial.h>
#include <string.h>
#ifdef BOARD_K210_EVB
#define SAMPLE_UART_NAME "/dev/uart3_dev3"
#endif
#ifdef BOARD_STM32F407_EVB
#define SAMPLE_UART_NAME "/dev/usart3_dev3"
#endif
static int serial_fd;
static int32_t bluetooth_receive;
static int rx_sem;
char bluetooth_buffer[NAME_NUM_MAX ]={0};
/* initialize srial port to open bluetooth*/
int BluetoothOpen(struct Adapter *padapter)
{
/* Open device in read-write mode */
serial_fd = open(SAMPLE_UART_NAME,O_RDWR);
/* set serial config, serial_baud_rate = 115200 */
struct SerialDataCfg cfg;
cfg.serial_baud_rate = BAUD_RATE_115200;
cfg.serial_data_bits = DATA_BITS_8;
cfg.serial_stop_bits = STOP_BITS_1;
cfg.serial_parity_mode = PARITY_NONE;
cfg.serial_bit_order = 0;
cfg.serial_invert_mode = 0;
cfg.serial_buffer_size = 128;
ioctl(serial_fd, 0, &cfg);
UserTaskDelay(1000);
printf("Bluetooth ready\n");
return 0;
}
/* send message to srial port*/
int BluetoothSend(struct Adapter *padapter, const char* data, int len, bool block, int time_out, int delay, send_success cb, void* param, void* reserved)
{
write(serial_fd,data,strlen(data));
return 0;
}
/*thread to read message from srial port*/
void SerialThreadEntry(void *parameter)
{
char ch;
int i = 0;
int n;
int run = 0;
while (1){
n = read(serial_fd,&ch,1);
if (n>0){
if (ch == '~'){
UserSemaphoreAbandon(rx_sem);
run = 1;
break;
}
bluetooth_buffer[i++] = ch;
}
if (run ==1)
break;
}
}
int BluetoothReceive(struct Adapter *padapter, char* rev_buffer, int buffer_len,int time_out, bool block, void* reserved)
{
x_err_t ret = EOK;
/* Set callback function */
/* Create thread serial */
UtaskType recv;
recv.name[0] = 'z';
recv.func_entry = SerialThreadEntry;
recv.func_param = NONE;
recv.stack_size = 1024;
recv.prio = 25;
memset(bluetooth_buffer, 0, sizeof(bluetooth_buffer));
/* Initialize semaphore */
rx_sem = UserSemaphoreCreate(0);
bluetooth_receive = UserTaskCreate(recv);
UserTaskStartup(bluetooth_receive);
/*copy to the receive buffer*/
UserSemaphoreObtain(rx_sem,-1);
memcpy(rev_buffer,bluetooth_buffer,strlen(bluetooth_buffer)+1 );
return ret;
}
void BluetoothSettingDemo(int argc, char *argv[])
{
adapter_t padapter = BluetoothAdapterFind("Bluetooth");
if (NONE == padapter){
KPrintf("adapter find failed!\n");
return;
}
/*Open adapter*/
if (0 != padapter->done.NetAiitOpen(padapter)){
KPrintf("adapter open failed!\n");
return;
}
BluetoothOpen(padapter);
/*Bluetooth communication settings*/
/*it can be changed if needed*/
char* set5 = "AT";
write(serial_fd,set5,strlen(set5));
UserTaskDelay(1000);
printf("bluetooth setting success!\n");
}
#ifndef SEPARATE_COMPILE
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
BluetoothSettingDemo, BluetoothSettingDemo, bluetooth send function );
#endif
void BluetoothClose(struct Adapter *padapter)
{
UserTaskDelete(bluetooth_receive);
close(serial_fd);
}

5
Ubiquitous/XiUOS/framework/connection/Adapter/ethernet/Makefile

@ -1,5 +0,0 @@
SRC_FILES += xs_adapterAT_ethernet.c \
xs_adapterAT_ethernet_register.c
include $(KERNEL_ROOT)/compiler.mk

409
Ubiquitous/XiUOS/framework/connection/Adapter/ethernet/xs_adapterAT_ethernet.c

@ -1,409 +0,0 @@
/*
* 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 xs_AdapterAT_ethernet.c
* @brief Structure and function declarations of the connection ethernet
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#include <xs_adapter_at_ethernet.h>
#include <xs_adapter_manager.h>
#include <xs_adapter_at_agent.h>
#include <xs_adapter_def.h>
#include <user_api.h>
#include <string.h>
/**
* @description: Close ethernet
* @param padapter - ethernet device pointer
*/
void EthernetClose(struct Adapter *padapter)
{
}
/**
* @description: open ethernet
* @param padapter - ethernet device pointer
*/
int EthernetOpen(struct Adapter *padapter)
{
char *agent_name = "uart3_client";
const char *device_name = ETHERNET_UART_NAME;
uint32 result;
if (InitATAgent(agent_name, device_name, 512, NULL)){
printf("InitATAgent failed ! \n");
result = -ERROR;
return result;
}
ATAgentType at_agent = GetATAgent(agent_name);
if (NULL == at_agent){
printf("GetATAgent failed ! \n");
return -ERROR;
}
UserTaskDelay(5000);
struct AdapterAT *ethernetAT_adapter = (struct AdapterAT *)padapter;
ethernetAT_adapter->agent = at_agent;
return EOK;
}
int EthernetSend(struct Adapter *padapter, const char *data, int len, bool block, int time_out, int delay, send_success cb, void *param, void* p)
{
struct AdapterAT *ethernetAT_adapter = (struct AdapterAT *)padapter;
if (ethernetAT_adapter->agent){
EntmSend(ethernetAT_adapter->agent, data, len);
}
}
int EthernetReceive(struct Adapter *padapter, char *rev_buffer, int buffer_len, int time_out, bool block, void* p)
{
printf("ethernet receive waiting ... \n");
struct AdapterAT *ethernetAT_adapter = (struct AdapterAT *)padapter;
if (ethernetAT_adapter->agent){
if (EntmRecv(ethernetAT_adapter->agent, rev_buffer, buffer_len, 40000))
printf("EntmRecv failed ! \n");
}else{
printf("Can not find agent \n");
}
}
uint32 EthernetInitAtCmd(ATAgentType at_agent)
{
uint32 result;
ATReplyType reply = CreateATReply(64);
if (NULL == reply){
printf("CreateATReply failed ! \n");
result = -ERROR;
goto __exit;
}
ATOrderSend(at_agent, REPLY_TIME_OUT, NULL, "+++");
UserTaskDelay(100);
ATOrderSend(at_agent, REPLY_TIME_OUT, NULL, "a");
UserTaskDelay(500);
return result;
__exit:
if (reply)
DeleteATReply(reply);
return result;
}
static void EthernetSetUpAdapter(void *parameter)
{
#define INIT_RETRY 5
#define LEN_PARA_BUF 128
uint8 server_addr_wifi[LEN_PARA_BUF]="192.168.1.183";
uint8 server_port_wifi[LEN_PARA_BUF]="12345";
uint8 WIFI_ssid[LEN_PARA_BUF]="DDST 2";
uint8 WIFI_pwd[LEN_PARA_BUF]="passw0rd";
char cmd[LEN_PARA_BUF];
struct AdapterAT *adapterAT = (struct AdapterAT *) parameter;
//struct at_device_esp8266 *esp8266 = (struct at_device_esp8266 *) device->UserData;
struct ATAgent *agent = adapterAT->agent;
ATReplyType reply = NONE;
x_err_t result = EOK;
x_size_t retry_num = INIT_RETRY;
//DBG("%s device initialize start.", adapterAT->parent.);
/* wait hfa21 device startup finish */
UserTaskDelay(5000);
reply = CreateATReply(64);
if (reply == NONE){
printf("no memory for reply create.");
return;
}
while (retry_num--){
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "+++");
UserTaskDelay(100);
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "a");
UserTaskDelay(2500);
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "AT+FCLR\r");
UserTaskDelay(30000);
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "+++");
UserTaskDelay(100);
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "a");
UserTaskDelay(2500);
memset(cmd,0,sizeof(cmd));
strcpy(cmd,"AT+WSSSID=");
strcat(cmd,WIFI_ssid);
strcat(cmd,"\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
UserTaskDelay(2500);
memset(cmd,0,sizeof(cmd));
strcpy(cmd,"AT+WSKEY=WPA2PSK,AES,");
strcat(cmd,WIFI_pwd);
strcat(cmd,"\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
UserTaskDelay(2500);
memset(cmd,0,sizeof(cmd));
strcpy(cmd,"AT+WMODE=sta\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
UserTaskDelay(2500);
memset(cmd,0,sizeof(cmd));
strcpy(cmd,"AT+NETP=TCP,CLIENT,");
strcat(cmd,server_port_wifi);
strcat(cmd,",");
strcat(cmd,server_addr_wifi);
strcat(cmd,"\r");
// strcpy(cmd,"AT+NETP\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
UserTaskDelay(2500);
memset(cmd,0,sizeof(cmd));
strcat(cmd,"AT+Z\r");
ATOrderSend(agent, REPLY_TIME_OUT, NULL, cmd);
UserTaskDelay(2500);
/* initialize successfully */
result = EOK;
break;
__exit:
if (result != EOK)
UserTaskDelay(1000);
}
if (reply)
DeleteATReply(reply);
}
int EthernetSetUp(struct AdapterAT *adapterAT)
{
EthernetSetUpAdapter(adapterAT);
return EOK;
}
int EthernetDHCP(struct AdapterAT *adapterAT, bool enable)
{
int result = EOK;
ATReplyType reply = NONE;
char dhcp_status[4];
memset(dhcp_status,0,sizeof(dhcp_status));
if(enable)
strcpy(dhcp_status,"on");
else
strcpy(dhcp_status,"off");
reply = CreateATReply(64);
if (reply == NONE){
printf("no memory for reply struct.");
return -ENOMEMORY;
}
/* send dhcp set commond "AT+CWDHCP_CUR=<mode>,<en>" and wait response */
if (ATOrderSend(adapterAT->agent, REPLY_TIME_OUT, reply, "AT+DHCPDEN=%s", dhcp_status) < 0){
result = -ERROR;
goto __exit;
}
__exit:
if (reply)
DeleteATReply(reply);
return result;
}
int EthernetPing(struct AdapterAT *adapterAT, const char *destination,struct PingResult *ping_resp)
{
char *ping_result = NONE;
ping_result = (char *) UserCalloc(1, 17);
EthernetInitAtCmd(adapterAT->agent);
uint32 result = EOK;
ATReplyType reply = CreateATReply(64);
if (NULL == reply){
printf("CreateATReply failed ! \n");
result = -ERROR;
goto __exit;
}
printf("\\r = 0x%x, \\n = 0x%x\n", '\r', '\n');
//ping baidu.com
uint32 err = ATOrderSend(adapterAT->agent, REPLY_TIME_OUT, reply, "AT+PING=%s", "192.168.250.240\r");
if (err){
printf("at_obj_exec_cmd(AT+PING)failed ! err = %d\n", err);
result = -ERROR;
goto __exit;
}
UserTaskDelay(2500);
ATOrderSend(adapterAT->agent, REPLY_TIME_OUT, NULL, "AT+Z\r");
UserTaskDelay(2000);
const char * result_buf = GetReplyText(reply);
if(!result_buf){
printf("send_dhcp_at_cmd AT+ result_buf = NULL");
result = -ERROR;
goto __exit;
}
char* str = strstr(result_buf, "+ok=");
printf("str is:%s\n",str);
ParseATReply(str, "+ok=%s\r", ping_result);
printf("ping result is:%s\n", ping_result);
__exit:
if (reply)
DeleteATReply(reply);
return result;
}
int EthernetNetstat(struct AdapterAT *adapterAT)
{
#define HFA21_NETSTAT_RESP_SIZE 320
#define HFA21_NETSTAT_TYPE_SIZE 10
#define HFA21_NETSTAT_IPADDR_SIZE 17
#define HFA21_NETP_EXPRESSION "+ok=%[^,],%[^,],%d,%s\r"
#define HFA21_WANN_EXPRESSION "+ok=%[^,],%[^,],%[^,],%[^,]\r"
#define HFA21_LANN_EXPRESSION "+ok=%[^,],%[^,]\r"
#define HFA21_WMODE_EXPRESSION "+ok=%s\r"
ATReplyType reply = NULL;
struct ATAgent *agent = adapterAT->agent;
uint32 result;
char * result_buf = NULL;
char * str = NULL;
/* sta/ap */
char *work_mode = NULL;
/* dhcp/static */
char *ip_mode = NULL;
char *local_ipaddr = NULL;
char *gateway = NULL;
char *netmask = NULL;
local_ipaddr = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
gateway = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
netmask = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
work_mode = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
ip_mode = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
reply = CreateATReply(HFA21_NETSTAT_RESP_SIZE);
if (reply == NULL)
goto __exit;
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "+++");
UserTaskDelay(100);
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "a");
UserTaskDelay(2500);
if (ATOrderSend(agent, REPLY_TIME_OUT, reply, "AT+WMODE\r") < 0)
goto __exit;
UserTaskDelay(2500);
result_buf = GetReplyText(reply);
if(!result_buf){
printf("send_dhcp_at_cmd AT+ result_buf = NULL");
result = -ERROR;
goto __exit;
}
str = strstr(result_buf, "+ok=");
printf("str is:%s\n",str);
/* parse the third line of response data, get the network connection information */
ParseATReply(str, HFA21_WMODE_EXPRESSION, work_mode);
if(work_mode[0]=='S'){
if (ATOrderSend(agent, REPLY_TIME_OUT, reply, "AT+WANN\r") < 0)
goto __exit;
UserTaskDelay(2500);
result_buf = GetReplyText(reply);
if(!result_buf){
printf("send_dhcp_at_cmd AT+ result_buf = NULL");
result = -ERROR;
goto __exit;
}
str = strstr(result_buf, "+ok=");
printf("str is:%s\n",str);
/* parse the third line of response data, get the network connection information */
ParseATReply(str, HFA21_WANN_EXPRESSION, ip_mode, local_ipaddr, netmask, gateway);
}else{
if (ATOrderSend(agent, REPLY_TIME_OUT, reply, "AT+LANN\r") < 0)
goto __exit;
UserTaskDelay(2500);
result_buf = GetReplyText(reply);
if(!result_buf){
printf("send_dhcp_at_cmd AT+ result_buf = NULL");
result = -ERROR;
goto __exit;
}
str = strstr(result_buf, "+ok=");
printf("str is:%s\n",str);
/* parse the third line of response data, get the network connection information */
ParseATReply(str, HFA21_LANN_EXPRESSION, local_ipaddr, netmask);
}
ATOrderSend(adapterAT->agent, REPLY_TIME_OUT, NULL, "AT+Z\r");
UserTaskDelay(2500);
printf("work mode: %s\n", work_mode);
if(work_mode[0]=='S')
printf("ip mode: %s\nlocal ip: %s\nnetmask: %s\ngateway: %s\n", ip_mode, local_ipaddr, netmask, gateway);
else
printf("local ip: %s\nnetmask: %s\n", local_ipaddr, netmask);
return EOK;
__exit:
if (reply)
DeleteATReply(reply);
if (local_ipaddr)
UserFree(local_ipaddr);
if (netmask)
UserFree(netmask);
if (gateway)
UserFree(gateway);
if (work_mode)
UserFree(work_mode);
}

70
Ubiquitous/XiUOS/framework/connection/Adapter/ethernet/xs_adapterAT_ethernet_register.c

@ -1,70 +0,0 @@
/*
* 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 xs_AdapterAT_ethernet_register.c
* @brief Structure and function declarations of the ethernet register
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#include <xs_adapter_at_ethernet.h>
#include <xs_adapter_manager.h>
#include <xs_adapter_at_agent.h>
#include <user_api.h>
#include <stdlib.h>
const struct AdapterDone EthernetAdapterDone =
{
EthernetClose,
EthernetOpen,
NULL,
EthernetSend,
EthernetReceive,
NULL,
};
const struct ATDone EthernetATDone =
{
EthernetSetUp,
NULL,
NULL,
NULL,
EthernetDHCP,
EthernetPing,
EthernetNetstat,
NULL,
};
int RegisterAdapterEthernet(void)
{
struct AdapterEthernet *ethernet_adapter = malloc(sizeof(struct AdapterEthernet));
if (ethernet_adapter == NULL){
printf("out of memory\n");
return ERROR;
}
struct AdapterAT *ethernetAT_adapter = (struct AdapterAT *)ethernet_adapter;
struct Adapter *adapter = (struct Adapter *)ethernet_adapter;
ethernet_adapter->parent.atdone = EthernetATDone;
ethernet_adapter->parent.parent.done = EthernetAdapterDone;
ethernetAT_adapter->at_adapter_id = ETHERNET_ADAPTER_ID;
ATAdapterInit();
ATAdapterRegister(ethernetAT_adapter);
return EOK;
}

72
Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter.h

@ -1,72 +0,0 @@
/*
* 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 xs_adapter.h
* @brief Adapter interface
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#ifndef XS_ADAPTER_N
#define XS_ADAPTER_N
#include <stdbool.h>
#include <xs_klist.h>
#include <xs_adapter_def.h>
enum AdapterType {
ADAPTER_LORA = 0, /* Lora */
ADAPTER_4G , /* 4G */
ADAPTER_NBIOT , /* NBIot */
ADAPTER_WIFI , /* WIFI */
ADAPTER_ETHERNET , /* ETHERNET */
ADAPTER_BLUETOOTH , /* BLUETOOTH */
ADAPTER_ZIGBEE , /* ZIGBEE */
ADAPTER_5G , /* 5G */
};
enum MeshType{
NET_P2P = 0,
NET_ADHOC_SINGLE_GROUP,
NET_ADHOC_MULTI_GROUP,
};
enum NetRoleType{
ROLE_TYPE_SLAVE = 1,
ROLE_TYPE_MASTER,
ROLE_TYPE_NONE,
};
struct Adapter;
struct AdapterDone {
void (*NetAiitClose)(struct Adapter *padapter);
int (*NetAiitOpen)(struct Adapter *padapter);
int (*NetAiitJoin)(struct Adapter *padapter, int dev_type, char* net_id);
int (*NetAiitSend)(struct Adapter *padapter, const char* data, int len, bool block, int time_out, int delay, send_success cb, void* param, void* reserved);
int (*NetAiitReceive)(struct Adapter *padapter, char* rev_buffer, int buffer_len,int time_out, bool block, void* reserved);
int (*NetAiitIoctl)(struct Adapter *padapter, int cmd, void *arg);
};
struct Adapter
{
enum AdapterType type; /* type of adapter, such as lora adapter */
enum NetRoleType net_role_type;
enum MeshType mesh_type;
struct AdapterDone done; /* socket-like APIs for data transferring */
struct SysDoubleLinklistNode link; /* link list node */
};
typedef struct Adapter *adapter_t;
#endif

94
Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_at.h

@ -1,94 +0,0 @@
/*
* 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 xs_adapter_at.h
* @brief AdapterAT interface
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#ifndef XS_ADAPTER_AT_H
#define XS_ADAPTER_AT_H
#include "xs_adapter.h"
#include <xs_adapter_at_agent.h>
#define SOCKET_STATUS_UNUSED (0)
#define SOCKET_STATUS_INIT (1)
#define SOCKET_STATUS_CONNECT (2)
#define SOCKET_TYPE_DGRAM (0)
#define SOCKET_TYPE_STREAM (1)
#define SOCKET_PROTOCOL_TCP (6)
#define SOCKET_PROTOCOL_UDP (17)
#define NET_TYPE_AF_INET (0)
#define NET_TYPE_AF_INET6 (1)
#define SOCKET_MAX 8
struct Socket
{
uint8_t fd;
uint8_t status ;
struct AddressIpv4 src_ip;
uint16_t src_port;
struct AddressIpv4 dst_ip;
uint16_t dst_port;
uint8_t type;
uint8_t af_type;
uint8_t protocal;
uint8 is_client;
};
struct AdapterAT;
struct ATDone
{
int (*ATOperateUp)(struct AdapterAT *adapterAT);
int (*ATOperateDown)(struct AdapterAT *adapterAT);
int (*ATOperateAddr)(struct AdapterAT *adapterAT, uint ip, uint gateway, uint netmask);
int (*ATOperateDns)(struct AdapterAT *adapterAT, struct AddressIpv4 *dns_addr, uint8 dns_count);
int (*ATOperateDHCP)(struct AdapterAT *adapterAT, bool enable);
int (*ATPing)(struct AdapterAT *adapterAT, const char *destination, struct PingResult *ping_resp);
int (*ATNetstat)(struct AdapterAT *adapterAT);
int (*ATOperateDefault)(struct AdapterAT *adapterAT);
int (*ATSocketCreate)(struct AdapterAT *adapterAT , uint8_t socket_fd , uint8_t type , uint8_t af_type );
int (*ATSocketConnect)(struct AdapterAT *adapterAT , uint8_t socket_fd , struct AddressIpv4 dst_ip , uint16_t dst_port, uint8 is_client);
int (*ATSocketClose)(struct AdapterAT *adapterAT , uint8_t socket_fd );
};
struct AdapterAT {
struct Adapter parent;
struct ATAgent *agent;
struct AddressIpv4 ip;
struct AddressIpv4 netmask;
struct AddressIpv4 gateway;
struct AddressIpv4 dns[DNS_COUNT];
uint32 at_adapter_id;
struct Socket socket[SOCKET_MAX];
uint8 hardware_address_len;
uint8 hardware_address[HW_MAX];
uint16 flags;
uint16 mtu;
void (*change_cb )(struct AdapterAT *adapterAT, enum CbType type, enum ChangeType ch_type_);
struct ATDone atdone;
struct SysDoubleLinklistNode link;
};
#endif

81
Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_at_agent.h

@ -1,81 +0,0 @@
/*
* 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 xs_adapter_at_agent.h
* @brief AT proxy, auto receive AT reply and transparency data
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#ifndef XS_ADAPTER_AT_CLIENT_H
#define XS_ADAPTER_AT_CLIENT_H
#include <stdarg.h>
#include <stddef.h>
#include <bus_serial.h>
enum ReceiveMode
{
ENTM_MODE = 1,
AT_MODE = 2,
};
struct ATReply
{
char *reply_buffer;
uint32 reply_max_len;
uint32 reply_len;
};
typedef struct ATReply *ATReplyType;
struct ATAgent
{
char agent_name[NAME_NUM_MAX];
int fd;
char *maintain_buffer;
uint32 maintain_len;
uint32 maintain_max;
int32 lock;
ATReplyType reply;
int rsp_sem;
int32 at_handler;
#define ENTM_RECV_MAX 256
char entm_recv_buf[ENTM_RECV_MAX];
uint32 entm_recv_len;
enum ReceiveMode receive_mode;
int entm_rx_notice;
};
typedef struct ATAgent *ATAgentType;
int EntmSend(ATAgentType agent, const char *data, int len);
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int time_out);
char *GetReplyText(ATReplyType reply);
ATReplyType CreateATReply(uint32 reply_max_len);
uint IpTint(char *ipstr);
void SwapStr(char *str, int begin, int end);
char* IpTstr(uint ipint);
ATAgentType GetATAgent(const char *agent_name);
int InitATAgent(const char *agent_name, const char *device_name, uint32 maintain_max, struct SerialCfgParam* pserial_cfg);
int ParseATReply(char* str, const char *format, ...);
void DeleteATReply(ATReplyType reply);
int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char *cmd_expr, ...);
#define REPLY_TIME_OUT 3000
#endif

48
Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_at_ethernet.h

@ -1,48 +0,0 @@
/*
* 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 xs_adapter_at_ethernet.h
* @brief Structure and function declarations of the connection ethernet
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#ifndef XS_ADAPTER_AT_ETHERNET_H
#define XS_ADAPTER_AT_ETHERNET_H
#include "xs_adapter.h"
#include "xs_adapter_at.h"
#include "xs_adapter_def.h"
#include "xs_klist.h"
struct AdapterEthernet {
struct AdapterAT parent; /* inherit from Adapter */
char vendor_name[NAME_LEN_MAX];
char product_ID_ethernet[NAME_LEN_MAX];
struct SingleLinklistNode link;
};
void EthernetClose(struct Adapter *padapter);
int EthernetOpen(struct Adapter *padapter);
int EthernetSend(struct Adapter *padapter, const char *data, int len, bool block, int time_out, int delay, send_success cb, void *param, void *p);
int EthernetReceive(struct Adapter *padapter, char *rev_buffer, int buffer_len, int time_out, bool block, void *p);
int EthernetSetUp(struct AdapterAT *adapterAT);
int EthernetDHCP(struct AdapterAT *adapterAT, bool enable);
int EthernetPing(struct AdapterAT *adapterAT, const char *destination, struct PingResult *ping_resp);
int EthernetNetstat(struct AdapterAT *adapterAT);
#endif

57
Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_at_nbiot.h

@ -1,57 +0,0 @@
/*
* 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 xs_adapter_at_nbiot.h
* @brief Structure and function declarations of the connection NBIoT
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#ifndef XS_ADAPTER_AT_NBIOT_H
#define XS_ADAPTER_AT_NBIOT_H
#include "xs_adapter.h"
#include "xs_adapter_at.h"
#include "xs_adapter_at_agent.h"
#include "xs_adapter_def.h"
#include <stdio.h>
#include <string.h>
#include <user_api.h>
#define MAX_SOCKET_NUM 8
#define SOCKET_STATUS_UNUSED (0)
#define SOCKET_STATUS_INIT (1)
#define SOCKET_STATUS_CONNECT (2)
struct AdapterNBIoT {
struct AdapterAT parent; /* inherit from Adapter */
char vendor_name[NAME_LEN_MAX];
char product_ID_ethernet[NAME_LEN_MAX];
struct SingleLinklistNode link;
};
int NbiotOpen(struct Adapter *padapter);
int NbiotSend(struct Adapter *padapter, const char* data, int len, bool block, int time_out, int delay, send_success cb, void* param, void* reserved);
int NBIotRecv(struct Adapter *padapter, char *rev_buffer, int buffer_len, int time_out, bool block);
int NBIoTSocketConnect(struct AdapterAT *adapterAT , uint8_t socket_fd , struct AddressIpv4 dst_ip , uint16_t dst_port, uint8 is_client);
int NBIoTSocketCreate(struct AdapterAT *adapterAT, uint8_t socket_fd, uint8_t type, uint8_t af_type );
int NBIoTSocketClose(struct AdapterAT *adapterAT, uint8_t socket_fd );
#endif

50
Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_at_wifi.h

@ -1,50 +0,0 @@
/*
* 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 xs_adapter_at_wifi.h
* @brief Structure and function declarations of the connection wifi
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#ifndef XS_ADAPTER_AT_WIFI_H
#define XS_ADAPTER_AT_WIFI_H
#include "xs_adapter.h"
#include "xs_adapter_at.h"
#include "xs_adapter_def.h"
#include "xs_klist.h"
struct Adapterwifi {
struct AdapterAT parent; /* inherit from Adapter */
char vendor_name[NAME_LEN_MAX];
char product_id_wifi[NAME_LEN_MAX];
struct SingleLinklistNode link;
};
void WifiClose(struct Adapter *padapter);
int WifiOpen(struct Adapter *padapter);
int WifiSend(struct Adapter *padapter, const char *data, int len, bool block, int time_out, int delay, send_success cb, void *param, void *p);
int WifiReceive(struct Adapter *padapter, char *rev_buffer, int buffer_len, int time_out, bool block, void *p);
int WifiSetUp(struct AdapterAT *adapter_at);
int WifiSetDown(struct AdapterAT *adapter_at);
int WifiSetAddr(struct AdapterAT *adapter_at, uint ip, uint gateway, uint netmask);
int WifiDHCP(struct AdapterAT *adapter_at, bool enable);
int WifiPing(struct AdapterAT *adapter_at, const char *destination,struct PingResult *ping_resp);
int WifiNetstat(struct AdapterAT *adapter_at);
#endif

41
Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_bluetooth.h

@ -1,41 +0,0 @@
/*
* 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: xs_adapter_bluetooth.h
* @brief: head file
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021/4/25
*
*/
#ifndef XS_ADAPTER_BLUETOOTH_H
#define XS_ADAPTER_BLUETOOTH_H
#include "xs_adapter.h"
struct AdapterBluetooth {
struct Adapter parent; /* inherit from Adapter */
const char * name; /* name of the adapter instance */
const char * device_type; /* type of the adapter instance */
};
typedef struct AdapterBluetooth *AdapterBluetooth_t;
int BluetoothOpen(struct Adapter *padapter);
int BluetoothSend(struct Adapter *padapter, const char* data, int len, bool block, int time_out, int delay, send_success cb, void* param, void* reserved);
int BluetoothReceive(struct Adapter *padapter, char* rev_buffer, int buffer_len,int time_out, bool block, void* reserved);
void BluetoothClose(struct Adapter *padapter);
#endif

77
Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_def.h

@ -1,77 +0,0 @@
/*
* 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 xs_adapter_def.h
* @brief defines about adapter
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#ifndef __XS_ADAPTER_DEF_H__
#define __XS_ADAPTER_DEF_H__
#include "stdbool.h"
typedef void(*send_success)(void* param);
#define NAME_LEN_MAX 32
#define IPV6__ADDRESS_COUNT 3U
#define DNS_COUNT 2U
#define HW_MAX 8U
enum CbType
{
CB_ADDR_IP, /* IP address */
CB_ADDR_NETMASK, /* subnet mask */
CB_ADDR_GATEWAY, /* netmask */
CB_ADDR_DNS_SERVER, /* dns server */
CB_STATUS_UP, /* changed to 'up' */
CB_STATUS_DOWN, /* changed to 'down' */
CB_STATUS_LINK_UP, /* changed to 'link up' */
CB_STATUS_LINK_DOWN, /* changed to 'link down' */
CB_STATUS_INTERNET_UP, /* changed to 'internet up' */
CB_STATUS_INTERNET_DOWN, /* changed to 'internet down' */
CB_STATUS_DHCP_ENABLE, /* enable DHCP capability */
CB_STATUS_DHCP_DISABLE, /* disable DHCP capability */
};
enum ChangeType
{
ADDR_CHANGE,
STATUS_CHANGE,
};
struct AddressIpv4
{
uint32 ipv4;
};
struct PingResult
{
struct AddressIpv4 ip_addr; /* response IP address */
uint16 data_len; /* response data length */
uint16 ttl; /* time to live */
uint32 ticks; /* response time, unit tick */
void *user_data; /* user-specific data */
};
#define NBIOT_ADAPTER_ID 0x02U
#define ETHERNET_ADAPTER_ID 0x03U
#define WIFI_ADAPTER_ID 0x04U
#define fourG_ADAPTER_ID 0x05U
#endif

184
Ubiquitous/XiUOS/framework/connection/Adapter/include/xs_adapter_lora.h

@ -1,184 +0,0 @@
/*
* 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 xs_adapterLora.h
* @brief lora adhoc logic
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#ifndef XS_ADAPTER_LORA_H
#define XS_ADAPTER_LORA_H
#include "xs_adapter.h"
#define DEVNAME_LEN_MAX 32
#define NETNAME_LEN_MAX 32
#define CONNECTED_CLIENTS_MAX 512
#define CLIENT_SEND_CELL_LEN 120
struct AdapterLora {
struct Adapter parent; /* inherit from Adapter */
const char * name; /* name of the adapter instance */
const char *deve_ui; /* Lora specific value */
const char *app_key; /* Lora specific value */