Browse Source

modify connection framework function and dir

pull/3/head
Liu_Weichao 1 year ago
parent
commit
2c9f3f8113
  1. 40
      APP_Framework/Framework/connection/4G/EC200T/Kconfig
  2. 3
      APP_Framework/Framework/connection/4G/EC200T/Makefile
  3. 273
      APP_Framework/Framework/connection/4G/EC200T/ec200t.c
  4. 14
      APP_Framework/Framework/connection/4G/Kconfig
  5. 4
      APP_Framework/Framework/connection/4G/Makefile
  6. 70
      APP_Framework/Framework/connection/4G/adapter_4G.c
  7. 36
      APP_Framework/Framework/connection/Kconfig
  8. 16
      APP_Framework/Framework/connection/adapter.c
  9. 48
      APP_Framework/Framework/connection/adapter.h
  10. 22
      APP_Framework/Framework/sensor/co2/Kconfig
  11. 16
      APP_Framework/Framework/sensor/humidity/Kconfig
  12. 22
      APP_Framework/Framework/sensor/pm/Kconfig
  13. 8
      APP_Framework/Framework/sensor/sensor.h
  14. 16
      APP_Framework/Framework/sensor/temperature/Kconfig
  15. 22
      APP_Framework/Framework/sensor/voice/Kconfig
  16. 30
      APP_Framework/Framework/transform_layer/xiuos/transform.c
  17. 43
      APP_Framework/Framework/transform_layer/xiuos/transform.h

40
APP_Framework/Framework/connection/4G/EC200T/Kconfig

@ -0,0 +1,40 @@
config ADAPTER_4G_EC200T
string "EC200T adapter name"
default "ec200t"
if ADD_XIUOS_FETURES
config ADAPTER_EC200T_PWRKEY
int "EC200T PWRKEY pin number"
default "97"
config ADAPTER_EC200T_PIN_DRIVER
string "EC200T device pin driver path"
default "/dev/pin"
config ADAPTER_EC200T_DRIVER_EXTUART
bool "Using extra uart to support 4G"
default n
config ADAPTER_EC200T_DRIVER
string "EC200T device uart driver path"
default "/dev/uart2_dev2"
depends on !ADAPTER_EC200T_DRIVER_EXTUART
if ADAPTER_EC200T_DRIVER_EXTUART
config ADAPTER_EC200T_DRIVER
string "EC200T device extra uart driver path"
default "/dev/extuart_dev5"
config ADAPTER_EC200T_DRIVER_EXT_PORT
int "if EC200T device using extuart, choose port"
default "5"
endif
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif

3
APP_Framework/Framework/connection/4G/EC200T/Makefile

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

273
APP_Framework/Framework/connection/4G/EC200T/ec200t.c

@ -0,0 +1,273 @@
/*
* 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 ec200t.c
* @brief Implement the connection 4G adapter function, using EC200T device
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.07.08
*/
#include <adapter.h>
static void Ec200tPowerSet(void)
{
int pin_fd;
pin_fd = PrivOpen(ADAPTER_EC200T_PIN_DRIVER, O_RDWR);
struct PinParam pin_param;
pin_param.cmd = GPIO_CONFIG_MODE;
pin_param.mode = GPIO_CFG_INPUT_PULLUP;
pin_param.pin = ADAPTER_EC200T_PWRKEY;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
ioctl_cfg.args = &pin_param;
PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg);
struct PinStat pin_stat;
pin_stat.pin = ADAPTER_EC200T_PWRKEY;
pin_stat.val = GPIO_HIGH;
PrivWrite(pin_fd, &pin_stat, 1);
PrivTaskDelay(600);//at least 500ms
pin_stat.val = GPIO_LOW;
PrivWrite(pin_fd, &pin_stat, 1);
PrivClose(pin_fd);
}
static int Ec200tOpen(struct Adapter *adapter)
{
uint8_t ec200t_cmd[64];
/*step1: open ec200t serial port*/
adapter->fd = PrivOpen(ADAPTER_EC200T_DRIVER, O_RDWR);
if (adapter->fd < 0) {
printf("Ec200tOpen get serial %s fd error\n", ADAPTER_EC200T_DRIVER);
return -1;
}
/*step2: serial write "+++", quit transparent mode*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "+++");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
/*step3: serial write "AT+CCID", get SIM ID*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+CCID\r\n");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
PrivTaskDelay(2500);
/*step4: serial write "AT+CPIN?", check SIM status*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+CPIN?\r\n");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
PrivTaskDelay(2500);
/*step5: serial write "AT+CREG?", check whether registered to GSM net*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+CREG?\r\n");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
PrivTaskDelay(2500);
/*step6: serial write "AT+QICLOSE", close socket connect before open socket*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+QICLOSE=0\r\n");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
PrivTaskDelay(2500);
/*step7: serial write "AT+QIDEACT", close TCP net before open socket*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+QIDEACT=1\r\n");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
PrivTaskDelay(2500);
ADAPTER_DEBUG("Ec200t open done\n");
return 0;
}
static int Ec200tClose(struct Adapter *adapter)
{
uint8_t ec200t_cmd[64];
/*step1: serial write "+++", quit transparent mode*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "+++");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
/*step2: serial write "AT+QICLOSE", close socket connect before open socket*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+QICLOSE=0\r\n");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
PrivTaskDelay(2500);
/*step3: serial write "AT+QIDEACT", close TCP net before open socket*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+QIDEACT=1\r\n");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
PrivTaskDelay(2500);
/*step4: close ec200t serial port*/
PrivClose(adapter->fd);
/*step5: power down ec200t*/
Ec200tPowerSet();
return 0;
}
static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
{
if (OPE_INT != cmd) {
printf("Ec200tIoctl only support OPE_INT, do not support %d\n", cmd);
return -1;
}
uint32_t baud_rate = *((uint32_t *)args);
struct SerialDataCfg serial_cfg;
memset(&serial_cfg, 0 ,sizeof(struct SerialDataCfg));
serial_cfg.serial_baud_rate = baud_rate;
serial_cfg.serial_data_bits = DATA_BITS_8;
serial_cfg.serial_stop_bits = STOP_BITS_1;
serial_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
serial_cfg.serial_parity_mode = PARITY_NONE;
serial_cfg.serial_bit_order = STOP_BITS_1;
serial_cfg.serial_invert_mode = NRZ_NORMAL;
#ifdef ADAPTER_EC200T_DRIVER_EXT_PORT
serial_cfg.ext_uart_no = ADAPTER_EC200T_DRIVER_EXT_PORT;
serial_cfg.port_configure = PORT_CFG_INIT;
#endif
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &serial_cfg;
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
return 0;
}
static int Ec200tConnect(struct Adapter *adapter, const char *ip, const char *port, enum IpType ip_type)
{
uint8_t ec200t_cmd[64];
/*step1: serial write "AT+QICSGP", connect to China Mobile using ipv4 or ipv6*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
if (IPV4 == ip_type) {
strcpy(ec200t_cmd, "AT+QICSGP=1,1,\"CMNET\",\"\",\"\",1\r\n");
} else if (IPV6 == ip_type) {
strcpy(ec200t_cmd, "AT+QICSGP=1,2,\"CMNET\",\"\",\"\",1\r\n");
}
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
PrivTaskDelay(2500);
/*step2: serial write "AT+QIACT", open TCP net*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+QIACT=1\r\n");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
PrivTaskDelay(2500);
/*step3: serial write "AT+QIOPEN", connect socket using TCP*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+QIOPEN=1,0,\"TCP\",\"");
strcat(ec200t_cmd, ip);
strcat(ec200t_cmd, "\",");
strcat(ec200t_cmd, port);
strcat(ec200t_cmd, ",0,2\r\n");
ADAPTER_DEBUG("Ec200t connect AT CMD :%s\n", ec200t_cmd);
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
ADAPTER_DEBUG("Ec200t connect TCP done\n");
return 0;
}
static int Ec200tSend(struct Adapter *adapter, const void *buf, size_t len)
{
PrivWrite(adapter->fd, buf, len);
return 0;
}
static int Ec200tRecv(struct Adapter *adapter, void *buf, size_t len)
{
PrivRead(adapter->fd, buf, len);
return 0;
}
static int Ec200tDisconnect(struct Adapter *adapter)
{
uint8_t ec200t_cmd[64];
/*step1: serial write "+++", quit transparent mode*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "+++");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
/*step2: serial write "AT+QICLOSE", close socket connect before open socket*/
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
strcpy(ec200t_cmd, "AT+QICLOSE=0\r\n");
PrivWrite(adapter->fd, ec200t_cmd, strlen(ec200t_cmd));
PrivTaskDelay(2500);
ADAPTER_DEBUG("Ec200t disconnect TCP done\n");
return 0;
}
static const struct IpProtocolDone ec200t_done =
{
.open = Ec200tOpen,
.close = Ec200tClose,
.ioctl = Ec200tIoctl,
.connect = Ec200tConnect,
.send = Ec200tSend,
.recv = Ec200tRecv,
.disconnect = Ec200tDisconnect,
};
AdapterProductInfoType Ec200tAttach(struct Adapter *adapter)
{
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
if (!product_info) {
printf("Ec200tAttach malloc product_info error\n");
free(product_info);
return NULL;
}
product_info->model_name = ADAPTER_4G_EC200T;
product_info->model_done = (void *)&ec200t_done;
Ec200tPowerSet();
return product_info;
}

14
APP_Framework/Framework/connection/4G/Kconfig

@ -0,0 +1,14 @@
config ADAPTER_4G
bool "Using 4G adapter function"
default y
if ADAPTER_4G
config ADAPTER_EC200T
bool "Using 4G adapter device EC200T"
default y
if ADAPTER_EC200T
source "$APP_DIR/Framework/connection/4G/EC200T/Kconfig"
endif
endif

4
APP_Framework/Framework/connection/4G/Makefile

@ -1,3 +1,7 @@
SRC_FILES := adapter_4G.c
ifeq ($(CONFIG_ADAPTER_EC200T),y)
SRC_DIR += EC200T
endif
include $(KERNEL_ROOT)/compiler.mk

70
APP_Framework/Framework/connection/4G/adapter_4G.c

@ -18,3 +18,73 @@
* @date 2021.06.25
*/
#include <adapter.h>
#ifdef ADAPTER_EC200T
extern AdapterProductInfoType Ec200tAttach(struct Adapter *adapter);
#endif
#define ADAPTER_4G_NAME "4G"
static int Adapter4GRegister(struct Adapter *adapter)
{
int ret = 0;
strncpy(adapter->name, ADAPTER_4G_NAME, NAME_NUM_MAX);
adapter->net_protocol = IP_PROTOCOL;
adapter->net_role = CLIENT;
adapter->adapter_status = UNREGISTERED;
ret = AdapterDeviceRegister(adapter);
if (ret < 0) {
printf("Adapter4G register error\n");
return -1;
}
return ret;
}
int Adapter4GInit(void)
{
int ret = 0;
struct Adapter *adapter = malloc(sizeof(struct Adapter));
if (!adapter) {
printf("Adapter4GInit malloc error\n");
free(adapter);
return -1;
}
ret = Adapter4GRegister(adapter);
if (ret < 0) {
printf("Adapter4GInit register 4G adapter error\n");
free(adapter);
return -1;
}
#ifdef ADAPTER_EC200T
AdapterProductInfoType product_info = Ec200tAttach(adapter);
if (!product_info) {
printf("Adapter4GInit ec200t attach error\n");
free(adapter);
return -1;
}
adapter->product_info_flag = 1;
adapter->info = product_info;
adapter->done = product_info->model_done;
#endif
return ret;
}
/******************TEST*********************/
static int Adapter4GTest(void)
{
int ret = 0;
return ret;
}

36
APP_Framework/Framework/connection/Kconfig

@ -3,59 +3,63 @@ menuconfig SUPPORT_CONNECTION_FRAMEWORK
default n
if SUPPORT_CONNECTION_FRAMEWORK
menuconfig ADAPTER_LORA
config CONNECTION_FRAMEWORK_DEBUG
bool "Using connection framework debug log function"
default y
menuconfig CONNECTION_ADAPTER_LORA
bool "Using lora adapter device"
default n
if ADAPTER_LORA
if CONNECTION_ADAPTER_LORA
source "$APP_DIR/Framework/connection/lora/Kconfig"
endif
menuconfig ADAPTER_4G
menuconfig CONNECTION_ADAPTER_4G
bool "Using 4G adapter device"
default n
if ADAPTER_4G
if CONNECTION_ADAPTER_4G
source "$APP_DIR/Framework/connection/4G/Kconfig"
endif
menuconfig ADAPTER_NB
menuconfig CONNECTION_ADAPTER_NB
bool "Using nbiot adapter device"
default n
if ADAPTER_NB
if CONNECTION_ADAPTER_NB
source "$APP_DIR/Framework/connection/nbiot/Kconfig"
endif
menuconfig ADAPTER_WIFI
menuconfig CONNECTION_ADAPTER_WIFI
bool "Using wifi adapter device"
default n
if ADAPTER_WIFI
if CONNECTION_ADAPTER_WIFI
source "$APP_DIR/Framework/connection/wifi/Kconfig"
endif
menuconfig ADAPTER_ETHERNET
menuconfig CONNECTION_ADAPTER_ETHERNET
bool "Using ethernet adapter device"
default n
if ADAPTER_ETHERNET
if CONNECTION_ADAPTER_ETHERNET
source "$APP_DIR/Framework/connection/ethernet/Kconfig"
endif
menuconfig ADAPTER_BLUETOOTH
menuconfig CONNECTION_ADAPTER_BLUETOOTH
bool "Using bluetooth adapter device"
default n
if ADAPTER_BLUETOOTH
if CONNECTION_ADAPTER_BLUETOOTH
source "$APP_DIR/Framework/connection/bluetooth/Kconfig"
endif
menuconfig ADAPTER_ZIGBEE
menuconfig CONNECTION_ADAPTER_ZIGBEE
bool "Using zigbee adapter device"
default n
if ADAPTER_ZIGBEE
if CONNECTION_ADAPTER_ZIGBEE
source "$APP_DIR/Framework/connection/zigbee/Kconfig"
endif
menuconfig ADAPTER_5G
menuconfig CONNECTION_ADAPTER_5G
bool "Using 5G adapter device"
default n
if ADAPTER_5G
if CONNECTION_ADAPTER_5G
source "$APP_DIR/Framework/connection/5G/Kconfig"
endif
endif

16
APP_Framework/Framework/connection/adapter.c

@ -112,11 +112,13 @@ int AdapterDeviceUnregister(struct Adapter *adapter)
/**
* @description: Open adapter device
* @param adapter - adapter device pointer
* @param name - adapter device name
* @return success: 0 , failure: other
*/
int AdapterDeviceOpen(struct Adapter *adapter)
int AdapterDeviceOpen(const char *name)
{
struct Adapter *adapter = AdapterDeviceFindByName(name);
if (!adapter)
return -1;
@ -258,7 +260,7 @@ ssize_t AdapterDeviceRecv(struct Adapter *adapter, void *dst, size_t len)
if (NULL == ip_done->recv)
return -1;
return ip_done->recv(adapter->socket, dst, len);
return ip_done->recv(adapter, dst, len);
} else {
printf("AdapterDeviceRecv net_protocol %d not support\n", adapter->net_protocol);
return -1;
@ -290,7 +292,7 @@ ssize_t AdapterDeviceSend(struct Adapter *adapter, const void *src, size_t len)
if (NULL == ip_done->send)
return -1;
return ip_done->send(adapter->socket, src, len);
return ip_done->send(adapter, src, len);
} else {
printf("AdapterDeviceSend net_protocol %d not support\n", adapter->net_protocol);
return -1;
@ -398,17 +400,17 @@ int AdapterDeviceDisconnect(struct Adapter *adapter)
if (PRIVATE_PROTOCOL == adapter->net_protocol) {
struct PrivProtocolDone *priv_done = (struct PrivProtocolDone *)adapter->done;
if (NULL == priv_done->disconnect)
if (NULL == priv_done->quit)
return -1;
return priv_done->disconnect(adapter);
return priv_done->quit(adapter);
} else if (IP_PROTOCOL == adapter->net_protocol) {
struct IpProtocolDone *ip_done = (struct IpProtocolDone *)adapter->done;
if (NULL == ip_done->disconnect)
return -1;
return ip_done->disconnect(adapter->socket);
return ip_done->disconnect(adapter);
} else {
printf("AdapterDeviceDisconnect net_protocol %d not support\n", adapter->net_protocol);
return -1;

48
APP_Framework/Framework/connection/adapter.h

@ -28,6 +28,10 @@
#include <stdint.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ADAPTER_BUFFSIZE 64
#define ADAPTER_AT_OPERATION 1
@ -43,8 +47,16 @@
#define ADAPTER_ZIGBEE_FUNC ((uint32_t)(1 << ADAPTER_ZIGBEE))
#define ADAPTER_5G_FUNC ((uint32_t)(1 << ADAPTER_5G))
#ifdef CONNECTION_FRAMEWORK_DEBUG
#define ADAPTER_DEBUG printf
#else
#define ADAPTER_DEBUF
#endif
struct Adapter;
struct AdapterProductInfo;
typedef struct Adapter *AdapterType;
typedef struct AdapterProductInfo *AdapterProductInfoType;
struct Socket
{
@ -54,14 +66,14 @@ struct Socket
enum AdapterType
{
ADAPTER_LORA = 0,
ADAPTER_4G ,
ADAPTER_NBIOT ,
ADAPTER_WIFI ,
ADAPTER_ETHERNET ,
ADAPTER_BLUETOOTH ,
ADAPTER_ZIGBEE ,
ADAPTER_5G ,
ADAPTER_TYPE_LORA = 0,
ADAPTER_TYPE_4G ,
ADAPTER_TYPE_NBIOT ,
ADAPTER_TYPE_WIFI ,
ADAPTER_TYPE_ETHERNET ,
ADAPTER_TYPE_BLUETOOTH ,
ADAPTER_TYPE_ZIGBEE ,
ADAPTER_TYPE_5G ,
};
enum NetProtocolType
@ -97,6 +109,8 @@ struct AdapterProductInfo
uint32_t functions;
const char *vendor_name;
const char *model_name;
void *model_done;
};
struct IpProtocolDone
@ -105,9 +119,9 @@ struct IpProtocolDone
int (*close)(struct Adapter *adapter);
int (*ioctl)(struct Adapter *adapter, int cmd, void *args);
int (*connect)(struct Adapter *adapter, const char *ip, const char *port, enum IpType ip_type);
int (*send)(struct Socket *socket, const void *buf, size_t len);
int (*recv)(struct Socket *socket, void *buf, size_t len);
int (*disconnect)(struct Socket *socket);
int (*send)(struct Adapter *adapter, const void *buf, size_t len);
int (*recv)(struct Adapter *adapter, void *buf, size_t len);
int (*disconnect)(struct Adapter *adapter);
};
struct PrivProtocolDone
@ -118,7 +132,7 @@ struct PrivProtocolDone
int (*join)(struct Adapter *adapter, const char *priv_net_group);
int (*send)(struct Adapter *adapter, const void *buf, size_t len);
int (*recv)(struct Adapter *adapter, void *buf, size_t len);
int (*disconnect)(struct Adapter *adapter);
int (*quit)(struct Adapter *adapter);
};
struct Adapter
@ -126,8 +140,10 @@ struct Adapter
char *name;
int fd;
int product_info_flag;
struct AdapterProductInfo *info;
struct Socket *socket;
//struct Socket *socket;
enum NetProtocolType net_protocol;
enum NetRoleType net_role;
@ -153,7 +169,7 @@ int AdapterDeviceRegister(struct Adapter *adapter);
int AdapterDeviceUnregister(struct Adapter *adapter);
/*Open adapter device*/
int AdapterDeviceOpen(struct Adapter *adapter);
int AdapterDeviceOpen(const char *name);
/*Close adapter device*/
int AdapterDeviceClose(struct Adapter *adapter);
@ -176,4 +192,8 @@ int AdapterDeviceJoin(struct Adapter *adapter, const char *priv_net_group);
/*Adapter disconnect from ip net or private net group*/
int AdapterDeviceDisconnect(struct Adapter *adapter);
#ifdef __cplusplus
}
#endif
#endif

22
APP_Framework/Framework/sensor/co2/Kconfig

@ -12,11 +12,21 @@ config SENSOR_ZG09
string "zg09 quantity name"
default "co2_1"
config SENSOR_DEVICE_ZG09_DEV
string "zg09 device name"
default "/dev/uart2_dev2"
if ADD_XIUOS_FETURES
config SENSOR_DEVICE_ZG09_DEV
string "zg09 device name"
default "/dev/uart2_dev2"
config SENSOR_DEVICE_ZG09_DEV_EXT_PORT
int "if ZG09 device using extuart, choose port"
default "4"
config SENSOR_DEVICE_ZG09_DEV_EXT_PORT
int "if ZG09 device using extuart, choose port"
default "4"
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

16
APP_Framework/Framework/sensor/humidity/Kconfig

@ -12,7 +12,17 @@ config PERCEPTION_HS300X
string "HS300x quantity name"
default "humidity_1"
config SENSOR_DEVICE_HS300X_DEV
string "HS300x device name"
default "/dev/i2c1_dev0"
if ADD_XIUOS_FETURES
config SENSOR_DEVICE_HS300X_DEV
string "HS300x device name"
default "/dev/i2c1_dev0"
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

22
APP_Framework/Framework/sensor/pm/Kconfig

@ -20,11 +20,21 @@ config SENSOR_PS5308
string "PS5308 quantity PM10 name"
default "pm10_1"
config SENSOR_DEVICE_PS5308_DEV
string "PS5308 device name"
default "/dev/uart2_dev2"
if ADD_XIUOS_FETURES
config SENSOR_DEVICE_PS5308_DEV
string "PS5308 device name"
default "/dev/uart2_dev2"
config SENSOR_DEVICE_PS5308_DEV_EXT_PORT
int "if PS5308 device using extuart, choose port"
default "4"
config SENSOR_DEVICE_PS5308_DEV_EXT_PORT
int "if PS5308 device using extuart, choose port"
default "4"
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

8
APP_Framework/Framework/sensor/sensor.h

@ -26,6 +26,10 @@
#include <string.h>
#include <transform.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SENSOR_QUANTITY_VALUE_ERROR ((uint32_t)0xffffffff)
/* Sensor quantity report mode */
@ -124,4 +128,8 @@ int SensorQuantityControl(struct SensorQuantity *quant, int cmd);
uint32_t Crc16(uint8_t * data, uint8_t length);
uint8_t GetCheckSum(uint8_t *data, uint8_t head, uint8_t length);
#ifdef __cplusplus
}
#endif
#endif

16
APP_Framework/Framework/sensor/temperature/Kconfig

@ -12,7 +12,17 @@ config SENSOR_HS300X
string "HS300x quantity name"
default "temperature_1"
config SENSOR_DEVICE_HS300X_DEV
string "HS300x device name"
default "/dev/i2c1_dev0"
if ADD_XIUOS_FETURES
config SENSOR_DEVICE_HS300X_DEV
string "HS300x device name"
default "/dev/i2c1_dev0"
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

22
APP_Framework/Framework/sensor/voice/Kconfig

@ -12,11 +12,21 @@ config SENSOR_D124
string "D124 quantity PM1.0 name"
default "voice_1"
config SENSOR_DEVICE_D124_DEV
string "D124 device name"
default "/dev/extuart_dev4"
if ADD_XIUOS_FETURES
config SENSOR_DEVICE_D124_DEV
string "D124 device name"
default "/dev/extuart_dev4"
config SENSOR_DEVICE_D124_DEV_EXT_PORT
int "if D124 device using extuart, choose port"
default "4"
config SENSOR_DEVICE_D124_DEV_EXT_PORT
int "if D124 device using extuart, choose port"
default "4"
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

30
APP_Framework/Framework/transform_layer/xiuos/transform.c

@ -21,12 +21,6 @@
#include <transform.h>
/**************************mutex***************************/
//for test
#define XIUOS_OS
#ifdef XIUOS_OS
/* private mutex API */
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr)
{
@ -49,11 +43,11 @@ int PrivMutexAbandon(pthread_mutex_t *p_mutex)
}
/**********************semaphore****************************/
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value)
{
return sem_init(sem, pshared, value);
}
int PrivSemaphoreDelete(sem_t *sem)
{
return sem_destroy(sem);
@ -68,13 +62,13 @@ int PrivSemaphoreObtainNoWait(sem_t *sem)
{
return sem_trywait(sem);
}
int PrivSemaphoreAbandon(sem_t *sem)
{
return sem_post(sem);
}
/**************************task*************************/
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg)
{
@ -104,7 +98,7 @@ int PrivTaskDelay(int32_t ms)
/*********************fs**************************/
/************************Driver Posix Transform***********************/
int PrivOpen(const char *path, int flags, ...)
int PrivOpen(const char *path, int flags)
{
return open(path, flags);
}
@ -131,18 +125,31 @@ static int PrivSerialIoctl(int fd, int cmd, void *args)
return ioctl(fd, cmd, &serial_cfg);
}
static int PrivPinIoctl(int fd, int cmd, void *args)
{
struct PinParam *pin_cfg = (struct PinParam *)args;
return ioctl(fd, cmd, &pin_cfg);
}
int PrivIoctl(int fd, int cmd, void *args)
{
int ret;
struct PrivIoctlCfg *ioctl_cfg = (struct PrivIoctlCfg *)args;
switch (ioctl_cfg->ioctl_driver_type)
{
case SERIAL_TYPE:
PrivSerialIoctl(fd, cmd, ioctl_cfg->args);
ret = PrivSerialIoctl(fd, cmd, ioctl_cfg->args);
break;
case PIN_TYPE:
ret = PrivSerialIoctl(fd, cmd, ioctl_cfg->args);
break;
default:
break;
}
return ret;
}
/********************memory api************/
@ -150,6 +157,7 @@ void *PrivMalloc(size_t size)
{
return UserMalloc(size);
}
void *PrivRealloc(void *pointer, size_t size)
{
return UserRealloc(pointer, size);
@ -159,9 +167,9 @@ void *PrivCalloc(size_t count, size_t size)
{
return UserCalloc(count, size);
}
void PrivFree(void *pointer)
{
UserFree(pointer);
}
#endif

43
APP_Framework/Framework/transform_layer/xiuos/transform.h

@ -37,6 +37,19 @@ extern "C" {
#define NAME_NUM_MAX 32
/*********************GPIO define*********************/
#define GPIO_LOW 0x00
#define GPIO_HIGH 0x01
#define GPIO_CFG_OUTPUT 0x00
#define GPIO_CFG_INPUT 0x01
#define GPIO_CFG_INPUT_PULLUP 0x02
#define GPIO_CFG_INPUT_PULLDOWN 0x03
#define GPIO_CFG_OUTPUT_OD 0x04
#define GPIO_CONFIG_MODE 0xffffffff
/********************SERIAL define*******************/
#define BAUD_RATE_2400 2400
#define BAUD_RATE_4800 4800
#define BAUD_RATE_9600 9600
@ -75,6 +88,28 @@ extern "C" {
#define SERIAL_RB_BUFSZ 128
#endif
struct PinDevIrq
{
int irq_mode;//< RISING/FALLING/HIGH/LOW
void (*hdr) (void *args);//< callback function
void *args;//< the params of callback function
};
struct PinParam
{
int cmd;//< cmd:GPIO_CONFIG_MODE/GPIO_IRQ_REGISTER/GPIO_IRQ_FREE/GPIO_IRQ_DISABLE/GPIO_IRQ_ENABLE
long pin;//< pin number
int mode;//< pin mode: input/output
struct PinDevIrq irq_set;//< pin irq set
uint64 arg;
};
struct PinStat
{
long pin;//< pin number
uint16_t val;//< pin level
};
enum ExtSerialPortConfigure
{
PORT_CFG_INIT = 0,
@ -102,6 +137,7 @@ enum IoctlDriverType
SERIAL_TYPE = 0,
SPI_TYPE,
I2C_TYPE,
PIN_TYPE,
DEFAULT_TYPE,
};
@ -135,12 +171,17 @@ int PrivTaskStartup(pthread_t *thread);
int PrivTaskDelete(pthread_t thread, int sig);
void PrivTaskQuit(void *value_ptr);
int PrivTaskDelay(int32_t ms);
int PrivOpen(const char *path, int flags, ...);
/*********************driver*************************/
int PrivOpen(const char *path, int flags);
int PrivRead(int fd, void *buf, size_t len);
int PrivWrite(int fd, const void *buf, size_t len);
int PrivClose(int fd);
int PrivIoctl(int fd, int cmd, void *args);
/*********************memory***********************/
void *PrivMalloc(size_t size);
void *PrivRealloc(void *pointer, size_t size);
void *PrivCalloc(size_t count, size_t size);

Loading…
Cancel
Save