system/uorb: add missing metadata for velocity and ambient_temp

SENSOR_TYPE_VELOCITY and SENSOR_TYPE_AMBIENT_TEMPERATURE have an
entry in the kernel g_sensor_meta[] table but no ORB_DECLARE/ORB_DEFINE
in user space, so ORB_ID() fails to link, callers must fall back to
orb_open() by name and lose the o_size check, and uorb_listener cannot
monitor them.
Add the missing metadata and register both in g_sensor_list[];
ambient_temp reuses struct sensor_temp the same way sensor_light_uncal
already reuses struct sensor_light.

Signed-off-by: likun17 <likun17@xiaomi.com>
This commit is contained in:
likun17 2026-09-09 19:34:11 +08:00 • committed by Xiang Xiao
parent 8404450fb8
commit 00d9af873d
5 changed files with 83 additions and 0 deletions

View file

@ -40,3 +40,4 @@ static const char sensor_temp_format[] =
****************************************************************************/
ORB_DEFINE(sensor_temp, struct sensor_temp, sensor_temp_format);
ORB_DEFINE(sensor_ambient_temp, struct sensor_temp, sensor_temp_format);

View file

@ -36,5 +36,6 @@
/* register this as object request broker structure */
ORB_DECLARE(sensor_temp);
ORB_DECLARE(sensor_ambient_temp);
#endif

View file

@ -70,6 +70,7 @@
#include <sensor/temp.h>
#include <sensor/tvoc.h>
#include <sensor/uv.h>
#include <sensor/velocity.h>
#include <uORB/uORB.h>
@ -81,6 +82,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
{
ORB_ID(sensor_accel),
ORB_ID(sensor_accel_uncal),
ORB_ID(sensor_ambient_temp),
ORB_ID(sensor_hinge_angle),
ORB_ID(sensor_baro),
ORB_ID(sensor_cap),
@ -139,6 +141,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
ORB_ID(sensor_tilt_detector_uncal),
ORB_ID(sensor_tvoc),
ORB_ID(sensor_uv),
ORB_ID(sensor_velocity),
ORB_ID(sensor_wake_gesture),
ORB_ID(sensor_wake_gesture_uncal),
ORB_ID(sensor_wrist_tilt),

View file

@ -0,0 +1,40 @@
/****************************************************************************
* apps/system/uorb/sensor/velocity.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/velocity.h>
/****************************************************************************
* Private Functions
****************************************************************************/
#ifdef CONFIG_UORB_FORMAT
static const char sensor_velocity_format[] =
"timestamp:%" PRIu64 ",velocity:%hf";
#endif
/****************************************************************************
* Public Data
****************************************************************************/
ORB_DEFINE(sensor_velocity, struct sensor_velocity, sensor_velocity_format);

View file

@ -0,0 +1,38 @@
/****************************************************************************
* apps/system/uorb/sensor/velocity.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_VELOCITY_H
#define __APPS_SYSTEM_UORB_SENSOR_VELOCITY_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <uORB/uORB.h>
/****************************************************************************
* Public Data
****************************************************************************/
/* register this as object request broker structure */
ORB_DECLARE(sensor_velocity);
#endif