This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit b93c94760861a3bf4c113d64eb2edae6732c70cd
Author: likun17 <[email protected]>
AuthorDate: Wed Sep 9 19:58:03 2026 +0800

    system/uorb: add voltage, current and power topics
    
    Declare and define the uORB metadata for the voltage, current and power
    types, and register them in g_sensor_list[] so that orb_get_meta() and
    uorb_listener can resolve them by name.
    
    Signed-off-by: likun17 <[email protected]>
---
 system/uorb/sensor/current.c | 41 +++++++++++++++++++++++++++++++++++++++++
 system/uorb/sensor/current.h | 38 ++++++++++++++++++++++++++++++++++++++
 system/uorb/sensor/power.c   | 41 +++++++++++++++++++++++++++++++++++++++++
 system/uorb/sensor/power.h   | 38 ++++++++++++++++++++++++++++++++++++++
 system/uorb/sensor/topics.c  |  6 ++++++
 system/uorb/sensor/voltage.c | 41 +++++++++++++++++++++++++++++++++++++++++
 system/uorb/sensor/voltage.h | 38 ++++++++++++++++++++++++++++++++++++++
 7 files changed, 243 insertions(+)

diff --git a/system/uorb/sensor/current.c b/system/uorb/sensor/current.c
new file mode 100644
index 000000000..0043f3551
--- /dev/null
+++ b/system/uorb/sensor/current.c
@@ -0,0 +1,41 @@
+/****************************************************************************
+ * apps/system/uorb/sensor/current.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <sensor/current.h>
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_UORB_FORMAT
+static const char sensor_current_format[] =
+  "timestamp:%" PRIu64 ",current:%hf";
+#endif
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+ORB_DEFINE(sensor_current, struct sensor_current,
+           sensor_current_format);
diff --git a/system/uorb/sensor/current.h b/system/uorb/sensor/current.h
new file mode 100644
index 000000000..054e4a73f
--- /dev/null
+++ b/system/uorb/sensor/current.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+ * apps/system/uorb/sensor/current.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __APPS_SYSTEM_UORB_SENSOR_CURRENT_H
+#define __APPS_SYSTEM_UORB_SENSOR_CURRENT_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/* register this as object request broker structure */
+
+ORB_DECLARE(sensor_current);
+
+#endif
diff --git a/system/uorb/sensor/power.c b/system/uorb/sensor/power.c
new file mode 100644
index 000000000..02295697d
--- /dev/null
+++ b/system/uorb/sensor/power.c
@@ -0,0 +1,41 @@
+/****************************************************************************
+ * apps/system/uorb/sensor/power.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <sensor/power.h>
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_UORB_FORMAT
+static const char sensor_power_format[] =
+  "timestamp:%" PRIu64 ",power:%hf";
+#endif
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+ORB_DEFINE(sensor_power, struct sensor_power,
+           sensor_power_format);
diff --git a/system/uorb/sensor/power.h b/system/uorb/sensor/power.h
new file mode 100644
index 000000000..38490ec8f
--- /dev/null
+++ b/system/uorb/sensor/power.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+ * apps/system/uorb/sensor/power.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __APPS_SYSTEM_UORB_SENSOR_POWER_H
+#define __APPS_SYSTEM_UORB_SENSOR_POWER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/* register this as object request broker structure */
+
+ORB_DECLARE(sensor_power);
+
+#endif
diff --git a/system/uorb/sensor/topics.c b/system/uorb/sensor/topics.c
index 2eec67dec..e41268ada 100644
--- a/system/uorb/sensor/topics.c
+++ b/system/uorb/sensor/topics.c
@@ -36,6 +36,7 @@
 #include <sensor/baro.h>
 #include <sensor/cap.h>
 #include <sensor/co2.h>
+#include <sensor/current.h>
 #include <sensor/dust.h>
 #include <sensor/ecg.h>
 #include <sensor/eng.h>
@@ -61,6 +62,7 @@
 #include <sensor/pm1p0.h>
 #include <sensor/pm10.h>
 #include <sensor/pose_6dof.h>
+#include <sensor/power.h>
 #include <sensor/ppgd.h>
 #include <sensor/ppgq.h>
 #include <sensor/prox.h>
@@ -71,6 +73,7 @@
 #include <sensor/tvoc.h>
 #include <sensor/uv.h>
 #include <sensor/velocity.h>
+#include <sensor/voltage.h>
 
 #include <uORB/uORB.h>
 
@@ -87,6 +90,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
   ORB_ID(sensor_baro),
   ORB_ID(sensor_cap),
   ORB_ID(sensor_co2),
+  ORB_ID(sensor_current),
   ORB_ID(sensor_device_orientation),
   ORB_ID(sensor_dust),
   ORB_ID(sensor_ecg),
@@ -128,6 +132,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
   ORB_ID(sensor_pm1p0),
   ORB_ID(sensor_pm25),
   ORB_ID(sensor_pose_6dof),
+  ORB_ID(sensor_power),
   ORB_ID(sensor_ppgd),
   ORB_ID(sensor_ppgq),
   ORB_ID(sensor_prox),
@@ -142,6 +147,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
   ORB_ID(sensor_tvoc),
   ORB_ID(sensor_uv),
   ORB_ID(sensor_velocity),
+  ORB_ID(sensor_voltage),
   ORB_ID(sensor_wake_gesture),
   ORB_ID(sensor_wake_gesture_uncal),
   ORB_ID(sensor_wrist_tilt),
diff --git a/system/uorb/sensor/voltage.c b/system/uorb/sensor/voltage.c
new file mode 100644
index 000000000..a76fafc11
--- /dev/null
+++ b/system/uorb/sensor/voltage.c
@@ -0,0 +1,41 @@
+/****************************************************************************
+ * apps/system/uorb/sensor/voltage.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <sensor/voltage.h>
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_UORB_FORMAT
+static const char sensor_voltage_format[] =
+  "timestamp:%" PRIu64 ",voltage:%hf";
+#endif
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+ORB_DEFINE(sensor_voltage, struct sensor_voltage,
+           sensor_voltage_format);
diff --git a/system/uorb/sensor/voltage.h b/system/uorb/sensor/voltage.h
new file mode 100644
index 000000000..c75c760c5
--- /dev/null
+++ b/system/uorb/sensor/voltage.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+ * apps/system/uorb/sensor/voltage.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __APPS_SYSTEM_UORB_SENSOR_VOLTAGE_H
+#define __APPS_SYSTEM_UORB_SENSOR_VOLTAGE_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/* register this as object request broker structure */
+
+ORB_DECLARE(sensor_voltage);
+
+#endif

Reply via email to