Browse Source

modify the configuration of app frame

pull/3/head
Wang_Weigen 1 year ago
parent
commit
0e496a791f
  1. 6
      Ubiquitous/XiUOS/Kconfig
  2. 99
      Ubiquitous/XiUOS/applications/Kconfig
  3. 62
      Ubiquitous/XiUOS/applications/Makefile
  4. 18
      Ubiquitous/XiUOS/applications/app_test/Kconfig
  5. 15
      Ubiquitous/XiUOS/applications/app_test/Makefile
  6. 20
      Ubiquitous/XiUOS/applications/app_test/test_adhoc_lora.c
  7. 175
      Ubiquitous/XiUOS/applications/app_test/test_spi_flash.c
  8. 3
      Ubiquitous/XiUOS/applications/connection_demo/adhoc_lora_demo/Makefile
  9. 108
      Ubiquitous/XiUOS/applications/connection_demo/adhoc_lora_demo/client.c
  10. 63
      Ubiquitous/XiUOS/applications/connection_demo/adhoc_lora_demo/gateway.c
  11. 3
      Ubiquitous/XiUOS/applications/connection_demo/bluetooth_demo/Makefile
  12. 88
      Ubiquitous/XiUOS/applications/connection_demo/bluetooth_demo/bluetooth_receive_demo.c
  13. 65
      Ubiquitous/XiUOS/applications/connection_demo/bluetooth_demo/bluetooth_send_demo.c
  14. 3
      Ubiquitous/XiUOS/applications/connection_demo/ethernet_demo/Makefile
  15. 197
      Ubiquitous/XiUOS/applications/connection_demo/ethernet_demo/ethernet_demo.c
  16. 3
      Ubiquitous/XiUOS/applications/connection_demo/nbiot_demo/Makefile
  17. 56
      Ubiquitous/XiUOS/applications/connection_demo/nbiot_demo/nbiot_demo.c
  18. 3
      Ubiquitous/XiUOS/applications/connection_demo/wifi_demo/Makefile
  19. 179
      Ubiquitous/XiUOS/applications/connection_demo/wifi_demo/wifi_demo.c
  20. 3
      Ubiquitous/XiUOS/applications/connection_demo/zigbee_demo/Makefile
  21. 88
      Ubiquitous/XiUOS/applications/connection_demo/zigbee_demo/zigbee_receive_demo.c
  22. 65
      Ubiquitous/XiUOS/applications/connection_demo/zigbee_demo/zigbee_send_demo.c
  23. 116
      Ubiquitous/XiUOS/applications/cppmain.cpp
  24. 162
      Ubiquitous/XiUOS/applications/framework_init.c
  25. 36
      Ubiquitous/XiUOS/applications/main.c
  26. 41
      Ubiquitous/XiUOS/applications/sd_card_mount.c
  27. 23
      Ubiquitous/XiUOS/applications/sensor_app/Makefile
  28. 34
      Ubiquitous/XiUOS/applications/sensor_app/co2_zg09.c
  29. 35
      Ubiquitous/XiUOS/applications/sensor_app/humidity_hs300x.c
  30. 35
      Ubiquitous/XiUOS/applications/sensor_app/pm1_0_ps5308.c
  31. 38
      Ubiquitous/XiUOS/applications/sensor_app/temperature_hs300x.c
  32. 36
      Ubiquitous/XiUOS/applications/sensor_app/voice_d124.c
  33. 46
      Ubiquitous/XiUOS/applications/spi_sd_card_mount.c
  34. 2
      Ubiquitous/XiUOS/applications/tflite_mnist/.gitignore
  35. 4
      Ubiquitous/XiUOS/applications/tflite_mnist/Kconfig
  36. 8
      Ubiquitous/XiUOS/applications/tflite_mnist/Makefile
  37. 19
      Ubiquitous/XiUOS/applications/tflite_mnist/README.md
  38. 51
      Ubiquitous/XiUOS/applications/tflite_mnist/digit.h
  39. 112
      Ubiquitous/XiUOS/applications/tflite_mnist/mnistapp.cpp
  40. 30
      Ubiquitous/XiUOS/applications/tflite_mnist/mnistmain.c
  41. 31429
      Ubiquitous/XiUOS/applications/tflite_mnist/model.h
  42. 54
      Ubiquitous/XiUOS/applications/tflite_mnist/tools/mnist-c-digit.py
  43. 41
      Ubiquitous/XiUOS/applications/tflite_mnist/tools/mnist-c-model.py
  44. 58
      Ubiquitous/XiUOS/applications/tflite_mnist/tools/mnist-inference.py
  45. 127
      Ubiquitous/XiUOS/applications/tflite_mnist/tools/mnist-train.py
  46. 4
      Ubiquitous/XiUOS/applications/tflite_sin/Kconfig
  47. 11
      Ubiquitous/XiUOS/applications/tflite_sin/Makefile
  48. 19
      Ubiquitous/XiUOS/applications/tflite_sin/constants.cc
  49. 32
      Ubiquitous/XiUOS/applications/tflite_sin/constants.h
  50. 119
      Ubiquitous/XiUOS/applications/tflite_sin/main_functions.cc
  51. 37
      Ubiquitous/XiUOS/applications/tflite_sin/main_functions.h
  52. 237
      Ubiquitous/XiUOS/applications/tflite_sin/model.cc
  53. 31
      Ubiquitous/XiUOS/applications/tflite_sin/model.h
  54. 24
      Ubiquitous/XiUOS/applications/tflite_sin/output_handler.cc
  55. 26
      Ubiquitous/XiUOS/applications/tflite_sin/output_handler.h
  56. 33
      Ubiquitous/XiUOS/applications/tflite_sin/sinmain.c
  57. 43
      Ubiquitous/XiUOS/applications/userspace.c

6
Ubiquitous/XiUOS/Kconfig

@ -1,12 +1,8 @@
source "$KERNEL_DIR/kernel/Kconfig"
source "$KERNEL_DIR/lib/Kconfig"
source "$KERNEL_DIR/fs/Kconfig"
source "$KERNEL_DIR/framework/Kconfig"
source "$KERNEL_DIR/applications/Kconfig"
source "$KERNEL_DIR/../../APP_Framework/Kconfig"

99
Ubiquitous/XiUOS/applications/Kconfig

@ -1,99 +0,0 @@
menu "Applications"
menu "config stack size and priority of main task"
config MAIN_KTASK_STACK_SIZE
int "Set main task stack size"
default 1024
config MAIN_KTASK_PRIORITY
int
default 4 if KTASK_PRIORITY_8
default 10 if KTASK_PRIORITY_32
default 85 if KTASK_PRIORITY_256
endmenu
menuconfig APPLICATION_SENSOR
bool "Using sensor apps"
default n
select PERCEPTION_SENSORDEVICE
if APPLICATION_SENSOR
menuconfig APPLICATION_SENSOR_CO2
bool "Using sensor CO2 apps"
default n
select PERCEPTION_CO2
if APPLICATION_SENSOR_CO2
config APPLICATION_SENSOR_CO2_ZG09
bool "Using sensor ZG09 apps"
default n
select PERCEPTION_ZG09
endif
menuconfig APPLICATION_SENSOR_PM1_0
bool "Using sensor PM1.0 apps"
default n
select PERCEPTION_PM
if APPLICATION_SENSOR_PM1_0
config APPLICATION_SENSOR_PM1_0_PS5308
bool "Using sensor PS5308 apps"
default n
select PERCEPTION_PS5308
endif
menuconfig APPLICATION_SENSOR_VOICE
bool "Using sensor voice apps"
default n
select PERCEPTION_VOICE
if APPLICATION_SENSOR_VOICE
config APPLICATION_SENSOR_VOICE_D124
bool "Using sensor D124 apps"
default n
select PERCEPTION_D124
endif
menuconfig APPLICATION_SENSOR_HUMIDITY
bool "Using sensor humidity apps"
default n
select PERCEPTION_HUMIDITY
if APPLICATION_SENSOR_HUMIDITY
config APPLICATION_SENSOR_HUMIDITY_HS300X
bool "Using sensor HS300x apps"
default n
select PERCEPTION_HS300X
endif
menuconfig APPLICATION_SENSOR_TEMPERATURE
bool "Using sensor temperature apps"
default n
select PERCEPTION_TEMPERATURE
if APPLICATION_SENSOR_TEMPERATURE
config APPLICATION_SENSOR_TEMPERATURE_HS300X
bool "Using sensor HS300x apps"
default n
select PERCEPTION_HS300X
endif
endif
menuconfig CONNECTION_COMMUNICATION_ZIGBEE
bool "enable zigbee demo"
default n
select CONFIG_CONNECTION_COMMUNICATION_ZIGBEE
if CONNECTION_COMMUNICATION_ZIGBEE
source "$KERNEL_DIR/framework/connection/Adapter/zigbee/Kconfig"
endif
source "$KERNEL_DIR/applications/tflite_sin/Kconfig"
source "$KERNEL_DIR/applications/tflite_mnist/Kconfig"
source "$KERNEL_DIR/applications/app_test/Kconfig"
endmenu

62
Ubiquitous/XiUOS/applications/Makefile

@ -1,62 +0,0 @@
SRC_DIR := tflite_sin tflite_mnist
ifeq ($(CONFIG_USER_APPLICATION),y)
SRC_FILES := main.c framework_init.c
SRC_DIR += user_api
ifeq ($(CONFIG_SEPARATE_COMPILE),y)
SRC_DIR += app_newlib
SRC_FILES += userspace.c
else
SRC_FILES += cppmain.cpp
endif
ifeq ($(CONFIG_USER_TEST),y)
SRC_DIR += app_test
endif
endif
ifeq ($(CONFIG_RESOURCES_SDIO), y)
SRC_FILES += sd_card_mount.c
endif
ifeq ($(CONFIG_RESOURCES_SPI_SD), y)
SRC_FILES += spi_sd_card_mount.c
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_BOOTSTART_LORA_NET_SAMPLE), y)
SRC_DIR += connection_demo/adhoc_lora_demo
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_ZIGBEE), y)
SRC_DIR += connection_demo/zigbee_demo
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_ETHERNET), y)
SRC_DIR += connection_demo/ethernet_demo
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_WIFI), y)
SRC_DIR += connection_demo/wifi_demo
endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_NB_IOT), y)
SRC_DIR += connection_demo/nbiot_demo
endif
# ifeq ($(CONFIG_CONNECTION_COMMUNICATION_4G), y)
# SRC_DIR += connection_demo/4G_demo
# endif
ifeq ($(CONFIG_CONNECTION_COMMUNICATION_BLUETOOTH), y)
SRC_DIR += connection_demo/bluetooth_demo
endif
ifeq ($(CONFIG_APPLICATION_SENSOR),y)
SRC_DIR += sensor_app
endif
include $(KERNEL_ROOT)/compiler.mk

18
Ubiquitous/XiUOS/applications/app_test/Kconfig

@ -1,18 +0,0 @@
menuconfig USER_TEST
bool "Enable application test function "
default n
if USER_TEST
config USER_TEST_LORA_ADHOC
bool "Config test lora adhoc"
default n
config USER_TEST_SPI_LORA
bool "Config test spi lora"
default n
config USER_TEST_SPI_FLASH
bool "Config test spi flash"
default n
endif

15
Ubiquitous/XiUOS/applications/app_test/Makefile

@ -1,15 +0,0 @@
SRC_FILES :=
ifeq ($(CONFIG_USER_TEST_LORA_ADHOC),y)
SRC_FILES += test_adhoc_lora.c
endif
ifeq ($(CONFIG_USER_TEST_SPI_LORA),y)
SRC_FILES += test_spi_lora.c
endif
ifeq ($(CONFIG_USER_TEST_SPI_FLASH),y)
SRC_FILES += test_spi_flash.c
endif
include $(KERNEL_ROOT)/compiler.mk

20
Ubiquitous/XiUOS/applications/app_test/test_adhoc_lora.c

@ -1,20 +0,0 @@
#include <xiuos.h>
extern void net_lora_client(int argc, char *argv[]);
extern void net_lora_gateway(int argc, char *argv[]);
void demo_lora_adhoc()
{
#ifdef CONNECTION_COMMUNICATION_SET_AS_LORA_CLIENT
char pgk_count[32];
char* param[3];
param[0] = "xxx";
param[1] = CONNECTION_COMMUNICATION_LORA_CLIENT_NAME;
itoa(CONNECTION_COMMUNICATION_LORA_CLIENT_PKG_COUNT, pgk_count, 10);
param[2] = pgk_count;
net_lora_client(2, param);
#endif
#ifdef CONNECTION_COMMUNICATION_SET_AS_LORA_GATEWAY
net_lora_gateway(0, 0);
#endif
}

175
Ubiquitous/XiUOS/applications/app_test/test_spi_flash.c

@ -1,175 +0,0 @@
/*
* File : spi_flash_sfud.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2016, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2016-09-28 armink first version.
*/
/**
* @file test_spi_flash.c
* @brief support to test spi flash function
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-05-17
*/
/*************************************************
File name: test_spi_flash.c
Description: support spi flash function test
Others: add spi flash test cmd from SFUD/blob/master/demo/stm32f2xx_rtt/RT-Thread-2.1.0/components/drivers/spi/spi_flash_sfud.c
https://github.com/armink/SFUD/
History:
1. Date: 2021-05-17
Author: AIIT XUOS Lab
Modification:
1. support spi flash open, read and write function
*************************************************/
#include <xiuos.h>
#include <device.h>
#include <flash_spi.h>
#include <user_api.h>
#define SPI_FLASH_PATH "/dev/spi1_W25Q64"
#define FlashDataPrint(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
static int spi_flash_fd;
void FlashOpen(void)
{
x_err_t ret = EOK;
spi_flash_fd = open(SPI_FLASH_PATH, O_RDWR);
if (spi_flash_fd < 0) {
KPrintf("open spi flash fd error %d\n", spi_flash_fd);
}
KPrintf("Spi Flash init succeed\n");
return;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
FlashOpen, FlashOpen, open spi flash device);
void FlashRead(int argc, char *argv[])
{
x_size_t i, j = 0;
uint32 addr;
uint32 size;
uint8 data[16];
struct BusBlockReadParam read_param;
memset(&read_param, 0, sizeof(struct BusBlockReadParam));
memset(data, 0, 16);
if (3 != argc) {
KPrintf("FlashRead cmd format: FlashRead addr size.\n");
return;
} else {
addr = strtol(argv[1], NULL, 0);
size = strtol(argv[2], NULL, 0);
read_param.buffer = data;
read_param.pos = addr;
read_param.size = size;
if (read_param.buffer) {
read(spi_flash_fd, &read_param, size);
if (size == read_param.read_length) {
KPrintf("Read the %s flash data success. Start from 0x%08X, size is %ld. The data is:\n",
SPI_FLASH_PATH, addr, size);
KPrintf("Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n");
for (i = 0; i < size; i += 16) {
KPrintf("[%08X] ", addr + i);
/* dump hex */
for (j = 0; j < 16; j++) {
if (i + j < size) {
KPrintf("%02X ", data[i + j]);
} else {
KPrintf(" ");
}
}
/* dump char for hex */
for (j = 0; j < 16; j++) {
if (i + j < size) {
KPrintf("%c", FlashDataPrint(data[i + j]) ? data[i + j] : '.');
}
}
KPrintf("\n");
}
KPrintf("\n");
}
} else {
KPrintf("SpiFlashRead alloc read buffer failed!\n");
}
}
return;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
FlashRead, FlashRead, read data from spi flash device);
void FlashWrite(int argc, char *argv[])
{
x_err_t ret = EOK;
x_size_t i, j = 0;
uint32 addr;
uint32 size;
uint8 data[16];
struct BusBlockWriteParam write_param;
memset(&write_param, 0, sizeof(struct BusBlockWriteParam));
memset(data, 0, 16);
if (argc < 3) {
KPrintf("FlashWrite cmd format: FlashWrite addr data.\n");
return;
} else {
addr = strtol(argv[1], NULL, 0);
size = argc - 2;
write_param.buffer = data;
write_param.pos = addr;
write_param.size = size;
if (data) {
for (i = 0; i < size; i++) {
data[i] = strtol(argv[2 + i], NULL, 0);
}
ret = write(spi_flash_fd, &write_param, size);
if (EOK == ret) {
KPrintf("Write the %s flash data success. Start from 0x%08X, size is %ld.\n",
SPI_FLASH_PATH, addr, size);
KPrintf("Write data: ");
for (i = 0; i < size; i++) {
KPrintf("%d ", data[i]);
}
KPrintf(".\n");
}
} else {
KPrintf("SpiFlashWrite alloc write buffer failed!\n");
}
}
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
FlashWrite, FlashWrite, write data to spi flash device);

3
Ubiquitous/XiUOS/applications/connection_demo/adhoc_lora_demo/Makefile

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

108
Ubiquitous/XiUOS/applications/connection_demo/adhoc_lora_demo/client.c

@ -1,108 +0,0 @@
#include <user_api.h>
#include <string.h>
#include <xs_adapter_lora.h>
#include <xs_adapter_manager.h>
#include <stdio.h>
#include <stdlib.h>
char client_name[DEVNAME_LEN_MAX] = "lora_dev_123";
void success_cb(void *param)
{
printf("success_cb, param = %s\n", param);
}
void invert_param(void *param)
{
printf("success_cb02 invoke, invert bool param.\n");
bool *bparam = (bool *)param;
if (*bparam)
{
*bparam = false;
}
else
{
*bparam = true;
}
}
void net_lora_client(int argc, char *argv[])
{
int pkg_count = 10;
if (argc >= 1)
{
memset(client_name, 0, DEVNAME_LEN_MAX);
strncpy(client_name, argv[1], strlen(argv[1]));
printf("lora client set clientName(%s).\n", client_name);
}
if (argc >= 2)
{
pkg_count = atoi(argv[2]);
printf("lora client set pkg_count(%d).\n", pkg_count);
}
// 1.Create an adapter for a specific agreement (LORA)
static struct AdapterLora lora_adapter;
memset(&lora_adapter, 0, sizeof(lora_adapter));
struct AdapterDone lora_example_done = {
.NetAiitOpen = LoraAdapterOpen,
.NetAiitClose = LoraAdapterCose,
.NetAiitSend = LoraAdapterSendc2g,
.NetAiitReceive = NULL,
.NetAiitJoin = LoraAdapterJoin,
.NetAiitIoctl = NULL,
};
lora_adapter.parent.done = lora_example_done; // Bind adapter operation
lora_adapter.name = client_name; // Set adapter name
lora_adapter.spi_lora_fd = -1; // Set adapter information
lora_adapter.deve_ui = "xxx";
lora_adapter.app_key = "yyy";
// 2.Register the adapter in the list
LoraAdapterInit();
LoraAdapterRegister((adapter_t)&lora_adapter);
// 3.Find from the list of registered adapters
adapter_t padapter = LoraAdapterFind(client_name);
if (NONE == padapter)
{
printf("adapter find failed!\n");
return;
}
// 4.Open adapter
if (0 != padapter->done.NetAiitOpen(padapter))
{
printf("adapter open failed!\n");
return;
}
// 5.Join the specified network segment as client
printf("NetAiitJoin start. \n");
padapter->done.NetAiitJoin(padapter, ROLE_TYPE_SLAVE, CONNECTION_COMMUNICATION_LORA_NET_ID);
printf("NetAiitJoin end. \n");
// 6.Point to point sending data to gateway
int i = 0;
while (i < pkg_count)
{
char data[120] = {0};
sprintf(data, "***** I am %s, data_num = %d ******" ,client_name, i);
bool v = false;
padapter->done.NetAiitSend(padapter, data, strlen(data) + 1, true, 10000, 0, invert_param, &v, NULL);
while (!v) // Asynchronous analog synchronization
{
UserTaskDelay(100);
}
printf("send success(main thread)... %s\n" ,data);
i++;
UserTaskDelay(800); // Contract interval
}
printf("all pkg send success(main thread), quit.\n");
padapter->done.NetAiitClose(padapter);
printf("client quit.\n");
}

63
Ubiquitous/XiUOS/applications/connection_demo/adhoc_lora_demo/gateway.c

@ -1,63 +0,0 @@
#include <user_api.h>
#include <string.h>
#include <xs_klist.h>
#include <xs_adapter_lora.h>
#include <xs_adapter_manager.h>
extern DoubleLinklistType online_user_head;
void net_lora_gateway(int argc, char *argv[])
{
// 1.New specific agreement (LORA) adapter
static struct AdapterLora lora_adapter;
memset(&lora_adapter, 0, sizeof(lora_adapter));
struct AdapterDone lora_example_done = {
.NetAiitOpen = LoraAdapterOpen,
.NetAiitClose = NULL,
.NetAiitSend = NULL,
.NetAiitReceive = LoraAdapterReceive,
.NetAiitJoin = LoraAdapterJoin,
.NetAiitIoctl = NULL,
};
lora_adapter.parent.done = lora_example_done; // Bind adapter operation
lora_adapter.name = "lora_dev_456"; // Set adapter name
lora_adapter.spi_lora_fd = -1; // Set adapter information
lora_adapter.deve_ui = "xxx";
lora_adapter.app_key = "yyy";
// 2.Register the adapter in the list
LoraAdapterInit();
LoraAdapterRegister((adapter_t)&lora_adapter);
// 3.Find from the list of registered adapters
adapter_t padapter = LoraAdapterFind("lora_dev_456");
if (NONE == padapter)
{
printf("adapter find failed!\n");
return;
}
// 4.Open adapter
if (0 != padapter->done.NetAiitOpen(padapter))
{
printf("adapter open failed!\n");
return;
}
// 5.Join the specified network segment as gateway
padapter->done.NetAiitJoin(padapter, ROLE_TYPE_MASTER, CONNECTION_COMMUNICATION_LORA_NET_ID);
}
static void net_lora_connectedlist(int argc, char *argv[])
{
DoubleLinklistType* pNode;
printf("******** connected users *********\n");
DOUBLE_LINKLIST_FOR_EACH(pNode, &online_user_head)
{
OnlineUser* pUser =CONTAINER_OF(pNode, OnlineUser, link);
printf("%s\n", pUser->user_name);
}
printf("*********************************\n");
}

3
Ubiquitous/XiUOS/applications/connection_demo/bluetooth_demo/Makefile

@ -1,3 +0,0 @@
SRC_FILES := bluetooth_receive_demo.c bluetooth_send_demo.c
# zigbee_send_demo.c zigbee_receive_demo.c
include $(KERNEL_ROOT)/compiler.mk

88
Ubiquitous/XiUOS/applications/connection_demo/bluetooth_demo/bluetooth_receive_demo.c

@ -1,88 +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: bluetooth_receive_demo.c
* @brief: using bluetooth to receive message
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021/4/30
*
*/
#include <xs_adapter_bluetooth.h>
#include <string.h>
#include <xs_klist.h>
#include <xs_adapter_manager.h>
#include <user_api.h>
#include <string.h>
static int re_sem;
static int buff_sem;
/*Critical zone protection function for*/
void BluetoothWait(char *rev_buffer)
{
while(1){
if (strlen(rev_buffer)>1){
UserSemaphoreAbandon(re_sem);
break;
}
}
}
/* receive message from another bluetooth device*/
void BluetoothReceiveDemo(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;
}
char rev_buffer[NAME_NUM_MAX];
/* Initialize semaphore */
re_sem = UserSemaphoreCreate(0);
/* receive buffer from serial port */
padapter->done.NetAiitReceive(padapter,rev_buffer,strlen(rev_buffer),10000,false,NULL);
BluetoothWait(rev_buffer);
UserSemaphoreObtain(re_sem,-1);
printf("\n");
for (int i=0;i<strlen(rev_buffer);i++)
{
if(rev_buffer[i] != 0Xff)
printf("%c",rev_buffer[i]);
}
printf("\n");
}
#ifndef SEPARATE_COMPILE
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
BluetoothReceiveDemo, BluetoothReceiveDemo, bluetooth receive function );
#endif

65
Ubiquitous/XiUOS/applications/connection_demo/bluetooth_demo/bluetooth_send_demo.c

@ -1,65 +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: bluetooth_send_demo.c
* @brief: using bluetooth to send message
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021/4/30
*
*/
#include <xs_adapter_bluetooth.h>
#include <string.h>
#include <xs_klist.h>
#include <xs_adapter_manager.h>
#include <string.h>
#include <user_api.h>
adapter_t padapter;
/* a demo function to send message through command line using bluetooth*/
/* first open bluetooth to start demo*/
void BluetoothOpenDemo()
{
/*Find from the list of registered adapters*/
// adapter_t padapter = BluetoothAdapterFind("Bluetoot");
padapter = BluetoothAdapterFind("Bluetooth");
if (NONE == padapter){
printf("adapter find failed!\n");
return;
}
/*Open adapter*/
if (0 != padapter->done.NetAiitOpen(padapter)){
printf("adapter open failed!\n");
return;
}
}
#ifndef SEPARATE_COMPILE
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
BluetoothOpenDemo, BluetoothOpenDemo, bluetooth send function );
#endif
void BluetoothSendDemo(int argc, char *argv[])
{
/*Find from the list of registered adapters*/
bool v = false;
padapter->done.NetAiitSend(padapter, argv[1], strlen(argv[1]) ,true,10000,0, NULL,&v,NULL);
}
#ifndef SEPARATE_COMPILE
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
BluetoothSendDemo, BluetoothSendDemo, bluetooth send function );
#endif

3
Ubiquitous/XiUOS/applications/connection_demo/ethernet_demo/Makefile

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

197
Ubiquitous/XiUOS/applications/connection_demo/ethernet_demo/ethernet_demo.c

@ -1,197 +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 ethernet_demo.c
* @brief Demo for ethernet function
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#include <string.h>
#include <user_api.h>
#include <xs_adapter_manager.h>
#include <xs_adapter_at_ethernet.h>
static bool opened = false;
void OpenEthernetMsg()
{
struct AdapterAT *at_adapter = ATAdapterFind(ETHERNET_ADAPTER_ID);
if (!at_adapter)
printf("ATAdapterFind failed .\n");
if (!opened){
opened = true;
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
}
}
void SendEthernetMsg(int argc, char *argv[])
{
char ethernet_msg[128];
if (argc >= 1){
memset(ethernet_msg, 0, 128);
strncpy(ethernet_msg, argv[1], strlen(argv[1]));
printf("SendEthernetMsg(%s).\n", ethernet_msg);
}
struct AdapterAT *at_adapter = ATAdapterFind(ETHERNET_ADAPTER_ID);
if (!at_adapter)
printf("ATAdapterFind failed .\n");
if (!opened){
opened = true;
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
}
at_adapter->parent.done.NetAiitSend(&at_adapter->parent, ethernet_msg, strlen(ethernet_msg), true, 1000, 0, NULL, NULL, NULL);
}
void RecvEthernetMsg()
{
char ethernet_recv_msg[128];
memset(ethernet_recv_msg, 0, sizeof(ethernet_recv_msg));
struct AdapterAT *at_adapter = ATAdapterFind(ETHERNET_ADAPTER_ID);
if (!at_adapter)
printf("ATAdapterFind failed .\n");
if (!opened){
opened = true;
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
}
while (1){
memset(ethernet_recv_msg, 0, sizeof(ethernet_recv_msg));
if (EOK == at_adapter->parent.done.NetAiitReceive(&at_adapter->parent, ethernet_recv_msg, 128, 40000, true, NULL))
printf("ethernet_recv_msg (%s)\n", ethernet_recv_msg);
else
printf("ethernet_recv_msg failed .\n");
}
}
void DhcpEthernet()
{
struct AdapterAT *at_adapter = ATAdapterFind(ETHERNET_ADAPTER_ID);
if (!at_adapter)
printf("ATAdapterFind failed .\n");
printf("Waiting for msg...\n");
if (!opened){
opened = true;
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
}
if (EOK != at_adapter->atdone.ATOperateDHCP(at_adapter, 1))
printf("EthernetNetstat failed \n");
}
void PingEthernet()
{
char ethernet_recv_msg[128];
memset(ethernet_recv_msg, 0, sizeof(ethernet_recv_msg));
struct AdapterAT *at_adapter = ATAdapterFind(ETHERNET_ADAPTER_ID);
if (!at_adapter)
printf("ATAdapterFind failed .\n");
printf("Waiting for msg...\n");
struct PingResult result;
char *ip_str = "192.168.250.250";
if (!opened){
opened = true;
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
}
if (EOK == at_adapter->atdone.ATPing(at_adapter, ip_str, &result))
printf("EthernetPing success (%s)\n", result.ip_addr.ipv4);
else
printf("EthernetPing failed \n");
}
void SetUpEthernet()
{
char ethernet_recv_msg[128];
memset(ethernet_recv_msg, 0, sizeof(ethernet_recv_msg));
struct AdapterAT *at_adapter = ATAdapterFind(ETHERNET_ADAPTER_ID);
if (!at_adapter)
printf("ATAdapterFind failed .\n");
printf("Waiting for msg...\n");
struct PingResult result;
if (!opened){
opened = true;
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
}
if (EOK == at_adapter->atdone.ATOperateUp(at_adapter))
printf("EthernetSetUp success (%s)\n", result.ip_addr.ipv4);
else
printf("EthernetSetUp failed \n");
}
void NetstatEthernet()
{
struct AdapterAT *at_adapter = ATAdapterFind(ETHERNET_ADAPTER_ID);
if (!at_adapter)
printf("ATAdapterFind failed .\n");
printf("Waiting for msg...\n");
if (!opened){
opened = true;
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
}
if (EOK != at_adapter->atdone.ATNetstat(at_adapter))
printf("EthernetNetstat failed \n");
}
void AtTestCmdEthernet(int argc, char *argv[])
{
char cmd[64];
if (argc >= 1){
memset(cmd, 0, sizeof(cmd));
strncpy(cmd, argv[1], strlen(argv[1]));
printf("AT cmd send(%s).\n", cmd);
}
strcat(cmd,"\r");
struct AdapterAT* at_adapter = ATAdapterFind(ETHERNET_ADAPTER_ID);
if (!opened){
opened = true;
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
}
printf("Waiting for msg...\n");
// Send hfa21 handshake, start cmd mode.
ATOrderSend(at_adapter->agent, REPLY_TIME_OUT, NULL, "+++");
UserTaskDelay(100);
ATOrderSend(at_adapter->agent, REPLY_TIME_OUT, NULL, "a");
UserTaskDelay(2500);
ATOrderSend(at_adapter->agent,REPLY_TIME_OUT, NULL,cmd);
UserTaskDelay(2500);
ATOrderSend(at_adapter->agent,REPLY_TIME_OUT, NULL,"AT+Z\r");
UserTaskDelay(5000);
}

3
Ubiquitous/XiUOS/applications/connection_demo/nbiot_demo/Makefile

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

56
Ubiquitous/XiUOS/applications/connection_demo/nbiot_demo/nbiot_demo.c

@ -1,56 +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 nbiot_demo.c
* @brief Demo for NBIoT function
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#include <string.h>
#include <user_api.h>
#include <xs_adapter_at_agent.h>
#include <xs_adapter_manager.h>
#include <xs_adapter_at_nbiot.h>
extern void RegisterAdapterNBIoT(void);
void NbiotEnable(void)
{
struct AdapterAT* at_adapter = ATAdapterFind(NBIOT_ADAPTER_ID);
UserTaskDelay(5000);
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
printf("Waiting for msg...\n");
at_adapter->atdone.ATSocketCreate(at_adapter, 1, SOCKET_TYPE_STREAM, NET_TYPE_AF_INET);
UserTaskDelay(1000);
struct AddressIpv4 addr;
addr.ipv4 = IpTint("115.236.53.226");
at_adapter->atdone.ATSocketConnect(at_adapter, 1, addr, 8989, 0);
int socket_fd = 1;
int count = 0;
while (1) {
UserTaskDelay(1000);
at_adapter->parent.done.NetAiitSend((struct Adapter *)at_adapter, "AB30313233", 5, 0, 0, 0, 0, 0, &socket_fd);
count++;
if (count == 10)
break;
}
}

3
Ubiquitous/XiUOS/applications/connection_demo/wifi_demo/Makefile

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

179
Ubiquitous/XiUOS/applications/connection_demo/wifi_demo/wifi_demo.c

@ -1,179 +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 wifi_demo.c
* @brief Demo for wifi function
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021.04.22
*/
#include <string.h>
#include <user_api.h>
#include <xs_adapter_manager.h>
#include <xs_adapter_at_wifi.h>
void SendWiftMsg(int argc, char *argv[])
{
char wifi_msg[128];
if (argc >= 1) {
memset(wifi_msg, 0, 128);
strncpy(wifi_msg, argv[1], strlen(argv[1]));
printf("SendWiftMsg(%s).\n", wifi_msg);
}
struct AdapterAT *at_adapter = ATAdapterFind(WIFI_ADAPTER_ID);
if (!at_adapter) {
printf("ATAdapterFind failed .\n");
}
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
at_adapter->parent.done.NetAiitSend(&at_adapter->parent, wifi_msg, strlen(wifi_msg), true, 1000, 0, NULL, NULL, NULL);
}
void RecvWifiMsg()
{
char wifi_recv_msg[128];
memset(wifi_recv_msg, 0, sizeof(wifi_recv_msg));
struct AdapterAT *at_adapter = ATAdapterFind(WIFI_ADAPTER_ID);
if (!at_adapter) {
printf("ATAdapterFind failed .\n");
}
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
while (1) {
memset(wifi_recv_msg, 0, sizeof(wifi_recv_msg));
if (EOK == at_adapter->parent.done.NetAiitReceive(&at_adapter->parent, wifi_recv_msg, 128, 40000, true, NULL)) {
printf("wifi_recv_msg (%s)\n", wifi_recv_msg);
} else {
printf("wifi_recv_msg failed .\n");
}
}
}
void SetAddrWifi()
{
struct AdapterAT* at_adapter = ATAdapterFind(WIFI_ADAPTER_ID);
if (!at_adapter) {
printf("ATAdapterFind failed .\n");
}
printf("Waiting for msg...\n");
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
if(EOK != at_adapter->atdone.ATOperateAddr(at_adapter, IpTint("10.10.100.222"), IpTint("255.255.255.0"), IpTint("255.255.255.0")))
printf("WifiSetAddr failed \n");
}
void DhcpWifi()
{
struct AdapterAT* at_adapter = ATAdapterFind(WIFI_ADAPTER_ID);
if (!at_adapter) {
printf("ATAdapterFind failed .\n");
}
printf("Waiting for msg...\n");
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
if(EOK != at_adapter->atdone.ATOperateDHCP(at_adapter,1))
printf("WifiDHCP failed \n");
}
void PingWifi()
{
char wifi_recv_msg[128];
memset(wifi_recv_msg, 0, sizeof(wifi_recv_msg));
struct AdapterAT *at_adapter = ATAdapterFind(WIFI_ADAPTER_ID);
if (!at_adapter) {
printf("ATAdapterFind failed .\n");
}
printf("Waiting for msg...\n");
struct PingResult result;
//www.baidu.com
char *ip_str = "36.152.44.95";
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
at_adapter->atdone.ATPing(at_adapter, ip_str, &result);
}
void SetUpWifi()
{
char wifi_recv_msg[128];
memset(wifi_recv_msg, 0, sizeof(wifi_recv_msg));
struct AdapterAT* at_adapter = ATAdapterFind(WIFI_ADAPTER_ID);
if (!at_adapter) {
printf("ATAdapterFind failed .\n");
}
printf("Waiting for msg...\n");
struct PingResult result;
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
if (EOK == at_adapter->atdone.ATOperateUp(at_adapter)) {
printf("WifiSetUp success (%s)\n", result.ip_addr.ipv4);
} else {
printf("WifiSetUp failed \n");
}
}
void NetstatWifi()
{
struct AdapterAT* at_adapter = ATAdapterFind(WIFI_ADAPTER_ID);
if (!at_adapter) {
printf("ATAdapterFind failed .\n");
}
printf("Waiting for msg...\n");
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
if (EOK != at_adapter->atdone.ATNetstat(at_adapter))
printf("WifiNetstat failed \n");
}
void AtTestCmdWifi(int argc, char *argv[])
{
char cmd[64];
if (argc >= 1) {
memset(cmd, 0, sizeof(cmd));
strncpy(cmd, argv[1], strlen(argv[1]));
printf("AT cmd send(%s).\n", cmd);
}
strcat(cmd,"\r");
struct AdapterAT* at_adapter = ATAdapterFind(WIFI_ADAPTER_ID);
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);
printf("Waiting for msg...\n");
ATOrderSend(at_adapter->agent, REPLY_TIME_OUT, NULL, "+++");
UserTaskDelay(100);
ATOrderSend(at_adapter->agent, REPLY_TIME_OUT, NULL, "a");
UserTaskDelay(2500);
ATOrderSend(at_adapter->agent,REPLY_TIME_OUT, NULL,cmd);
UserTaskDelay(2500);
ATOrderSend(at_adapter->agent,REPLY_TIME_OUT, NULL,"AT+Z\r");
UserTaskDelay(5000);
}

3
Ubiquitous/XiUOS/applications/connection_demo/zigbee_demo/Makefile

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

88
Ubiquitous/XiUOS/applications/connection_demo/zigbee_demo/zigbee_receive_demo.c

@ -1,88 +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: zigbee_receive_demo.c
* @brief: using zigbee to receive message
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021/4/30
*
*/
#include <xs_adapter_zigbee.h>
#include <string.h>
#include <xs_klist.h>
#include <xs_adapter_manager.h>
#include <user_api.h>
#include <string.h>
static int re_sem;
static int buff_sem;
/*Critical zone protection function for*/
void ZigbeeWait(char *rev_buffer)
{
while(1){
if (strlen(rev_buffer)>1){
UserSemaphoreAbandon(re_sem);
break;
}
}
}
/* receive message from another zigbee device*/
void ZigbeeReceiveDemo(int argc, char *argv[])
{
adapter_t padapter = ZigbeeAdapterFind("zigbee");
if (NONE == padapter){
KPrintf("adapter find failed!\n");
return;
}
/*Open adapter*/
if (0 != padapter->done.NetAiitOpen(padapter)){
KPrintf("adapter open failed!\n");
return;
}
char rev_buffer[NAME_NUM_MAX];
/* Initialize semaphore */
re_sem = UserSemaphoreCreate(0);
/* receive buffer from serial port */
padapter->done.NetAiitReceive(padapter,rev_buffer,strlen(rev_buffer),10000,false,NULL);
ZigbeeWait(rev_buffer);
UserSemaphoreObtain(re_sem,-1);
printf("\n");
for (int i=0;i<strlen(rev_buffer);i++)
{
if(rev_buffer[i] != 0Xff)
printf("%c",rev_buffer[i]);
}
printf("\n");
}
#ifndef SEPARATE_COMPILE
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
ZigbeeReceiveDemo, ZigbeeReceiveDemo, zigbee receive function );
#endif

65
Ubiquitous/XiUOS/applications/connection_demo/zigbee_demo/zigbee_send_demo.c

@ -1,65 +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: zigbee_send_demo.c
* @brief: using zigbee to send message
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021/4/30
*
*/
#include <xs_adapter_zigbee.h>
#include <string.h>
#include <xs_klist.h>
#include <xs_adapter_manager.h>
#include <string.h>
#include <user_api.h>
adapter_t padapter;
/* a demo function to send message through command line using zigbee*/
/* first open zigbee to start demo*/
void ZigbeeOpenDemo()
{
/*Find from the list of registered adapters*/
// adapter_t padapter = ZigbeeAdapterFind("zigbee");
padapter = ZigbeeAdapterFind("zigbee");
if (NONE == padapter){
printf("adapter find failed!\n");
return;
}
/*Open adapter*/
if (0 != padapter->done.NetAiitOpen(padapter)){
printf("adapter open failed!\n");
return;
}
}
#ifndef SEPARATE_COMPILE
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
ZigbeeOpenDemo, ZigbeeOpenDemo, zigbee send function );
#endif
void ZigbeeSendDemo(int argc, char *argv[])
{
/*Find from the list of registered adapters*/
bool v = false;
padapter->done.NetAiitSend(padapter, argv[1], strlen(argv[1]) ,true,10000,0, NULL,&v,NULL);
}
#ifndef SEPARATE_COMPILE
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
ZigbeeSendDemo, ZigbeeSendDemo, zigbee send function );
#endif

116
Ubiquitous/XiUOS/applications/cppmain.cpp

@ -1,116 +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.
*/
#include <xiuos.h>
#include <stdio.h>
#include <cstdlib>
using namespace std;
extern "C" void KPrintf(const char *fmt, ...);
class Animal //parent class
{
public:
virtual void Eat()
{
KPrintf("eat\n");
}
void Sleep()
{
KPrintf("sleep\n");
}
};
class Fish :public Animal //subclass
{
public:
void Eat()
{
KPrintf("fish eat\n");
}
};
void Doeat(Animal& animal)
{
animal.Eat();
}
void MemTest2()
{
int i;
char *ptr = NULL; /* memory pointer */
for (i = 0; ; i++) {
/* allocate (1<<i) bytes memory every single time */
ptr = (char *)operator new(1 << i);
/* if allocate successfully */
if (ptr != NULL) {
KPrintf("get memory :%d byte\n", (1 << i));
/* release the memory */
operator delete(ptr);
KPrintf("free memory :%d byte\n", (1 << i));
ptr = NULL;
} else {
KPrintf("try to get %d byte memory failed!\n", (1 << i));
break;
//return 0;
}
}
}
void OverLoadTest(int a)
{
KPrintf("output is a int number: %d\n", a);
}
void OverLoadTestDouble(int a,int b )
{
KPrintf("output is 2 int number: %d and %d\n", a,b);
}
template<typename T>
void MySwap(T& a, T& b)
{
T temp = a;
a = b;
b = temp;
}
extern "C" int cppmain(void)
{
MemTest2();
class Fish fish;
Doeat(fish);
int a = 3;
int b = 5;
void OverLoadTestDouble(int a, int b);
OverLoadTestDouble(a, b);
MySwap(a,b);
KPrintf("with template the output is: %d and %d\n", a,b);
return 0;
}

162
Ubiquitous/XiUOS/applications/framework_init.c

@ -1,162 +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.
*/
#include <stdio.h>
#include <string.h>
#include <user_api.h>
extern int SensorFrameworkInit(void);
extern int RegisterAdapterEthernet(void);
extern int RegisterAdapterWifi(void);
extern int RegisterAdapterZigbee(void);
extern int RegisterAdapterNBIoT(void);
extern int RegisterAdapterBluetooth(void);
extern int LoraSx12xxSpiDeviceInit();
extern int D124VoiceInit(void);
extern int Hs300xTemperatureInit(void);
extern int Hs300xHumidityInit(void);
extern int Ps5308Pm1_0Init(void);
extern int Zg09Co2Init(void);
typedef int (*InitFunc)(void);
struct InitDesc
{
const char* fn_name;
const InitFunc fn;
};
static int AppInitDesc(struct InitDesc sub_desc[])
{
int i = 0;
int ret = 0;
for( i = 0; sub_desc[i].fn != NULL; i++ ) {
ret = sub_desc[i].fn();
printf("initialize %s %s\n",sub_desc[i].fn_name, ret == 0 ? "success" : "failed");
if(0 != ret) {
break;
}
}
return ret;
}
static struct InitDesc framework[] =
{
#ifdef PERCEPTION_SENSORDEVICE
{ "perception_framework", SensorFrameworkInit },
#endif