diff --git a/APP_Framework/Applications/sensor_app/iaq_tb600b_iaq10.c b/APP_Framework/Applications/sensor_app/iaq_tb600b_iaq10.c index a3466f165..87f1b9179 100644 --- a/APP_Framework/Applications/sensor_app/iaq_tb600b_iaq10.c +++ b/APP_Framework/Applications/sensor_app/iaq_tb600b_iaq10.c @@ -18,7 +18,9 @@ * @date 2021.12.14 */ -#include +#ifdef ADD_XIUOS_FETURES +# include +#endif #include // struct iaq_data { diff --git a/APP_Framework/Framework/sensor/iaq/Kconfig b/APP_Framework/Framework/sensor/iaq/Kconfig index 8d258f05b..e45d4bcb0 100644 --- a/APP_Framework/Framework/sensor/iaq/Kconfig +++ b/APP_Framework/Framework/sensor/iaq/Kconfig @@ -34,6 +34,11 @@ config SENSOR_TB600B_IAQ10 endif if ADD_NUTTX_FETURES + config SENSOR_DEVICE_TB600B_IAQ10_DEV + string "tb600b iaq10 device uart path" + default "/dev/ttyS1" + ---help--- + If USART1 is selected, then fill in /dev/ttyS1 here. endif diff --git a/APP_Framework/Framework/sensor/iaq/Make.defs b/APP_Framework/Framework/sensor/iaq/Make.defs new file mode 100644 index 000000000..96a7b8959 --- /dev/null +++ b/APP_Framework/Framework/sensor/iaq/Make.defs @@ -0,0 +1,4 @@ +############################################################################ +# APP_Framework/Framework/sensor/iaq/Make.defs +############################################################################ +include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/iaq/*/Make.defs) diff --git a/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Make.defs b/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Make.defs new file mode 100644 index 000000000..217e2993c --- /dev/null +++ b/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Make.defs @@ -0,0 +1,6 @@ +############################################################################ +# APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Make.defs +############################################################################ +ifneq ($(CONFIG_SENSOR_TB600B_IAQ10),) +CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/iaq/tb600b_iaq10 +endif diff --git a/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Makefile b/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Makefile index dff84d47a..f602f6940 100644 --- a/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Makefile +++ b/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Makefile @@ -1,3 +1,12 @@ -SRC_FILES := tb600b_iaq10.c +include $(KERNEL_ROOT)/.config +ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) + include $(APPDIR)/Make.defs + CSRCS += tb600b_iaq10.c + include $(APPDIR)/Application.mk +endif -include $(KERNEL_ROOT)/compiler.mk + +ifeq ($(CONFIG_ADD_XIUOS_FETURES),y) + SRC_FILES := tb600b_iaq10.c + include $(KERNEL_ROOT)/compiler.mk +endif diff --git a/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/tb600b_iaq10.c b/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/tb600b_iaq10.c index 2760efe28..14e2e13bd 100644 --- a/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/tb600b_iaq10.c +++ b/APP_Framework/Framework/sensor/iaq/tb600b_iaq10/tb600b_iaq10.c @@ -43,6 +43,17 @@ static struct SensorProductInfo info = * @param sdev - sensor device pointer * @return success: 1 , failure: other */ +#ifdef ADD_NUTTX_FETURES +static int SensorDeviceOpen(struct SensorDevice *sdev) +{ + sdev->fd = PrivOpen(SENSOR_DEVICE_TB600B_IAQ10_DEV, O_RDWR); + if (sdev->fd < 0) { + printf("open %s error\n", SENSOR_DEVICE_TB600B_IAQ10_DEV); + } + + return sdev->fd; +} +#else static int SensorDeviceOpen(struct SensorDevice *sdev) { int result = 0; @@ -73,6 +84,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev) return result; } +#endif /** * @description: Read sensor device diff --git a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/Kconfig b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/Kconfig index dc70aaeed..a276c81fd 100644 --- a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/Kconfig +++ b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/Kconfig @@ -588,6 +588,10 @@ config NSH_DISABLE_XD default y if DEFAULT_SMALL default n if !DEFAULT_SMALL +config NSH_DISABLE_TB600B_IAQ10 + bool "Disable the air quality function of the sensor TB600B-IAQ-10" + default n + config NSH_DISABLE_CO2ZG09 bool "Disable the co2 function of the sensor zg09" default n diff --git a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh.h b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh.h index 25cd1e0fe..8440db0a7 100644 --- a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh.h +++ b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh.h @@ -1403,6 +1403,10 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb, FAR void *arg); #endif +#if defined(CONFIG_APPLICATION_SENSOR_IAQ) && !defined(CONFIG_NSH_DISABLE_TB600B_IAQ10) + int cmd_Iaq10(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif + #if defined(CONFIG_APPLICATION_SENSOR_CO2_ZG09) && !defined(CONFIG_NSH_DISABLE_CO2ZG09) int cmd_Co2Zg09(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif diff --git a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c index 4fb5e7715..5622d4c4d 100644 --- a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c +++ b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c @@ -52,6 +52,21 @@ extern int FrameworkInit(void); +/**************************************************************************** + * Name: cmd_Iaq10 + ****************************************************************************/ + +#if defined(CONFIG_APPLICATION_SENSOR_IAQ) && !defined(CONFIG_NSH_DISABLE_TB600B_IAQ10) +extern void IaqTb600bIaq10(void); +int cmd_Iaq10(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + printf("Hello, world!\n"); + FrameworkInit(); + IaqTb600bIaq10(); + return 0; +} +#endif + /**************************************************************************** * Name: cmd_Co2Zg09 ****************************************************************************/ diff --git a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_command.c b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_command.c index be53a52a0..ddbf02020 100644 --- a/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_command.c +++ b/Ubiquitous/Nuttx/app_match_nuttx/apps/nshlib/nsh_command.c @@ -580,6 +580,10 @@ static const struct cmdmap_s g_cmdmap[] = { "xd", cmd_xd, 3, 3, " " }, #endif +#if defined(CONFIG_APPLICATION_SENSOR_IAQ) && !defined(CONFIG_NSH_DISABLE_TB600B_IAQ10) + { "iaq10", cmd_Iaq10, 1, 1, "[get air quality data with sensor Tb600bIaq10.]" }, +#endif + #if defined(CONFIG_APPLICATION_SENSOR_CO2_ZG09) && !defined(CONFIG_NSH_DISABLE_CO2ZG09) { "zg09", cmd_Co2Zg09, 1, 1, "[get co2 concentration with sensor ZG09.]" }, #endif