pub fn new_sensor_listener(
    sensor_key:     &'static Strn,
    sensor_type:    sensor_type_t, 
    listener_func:  SensorValueFunc
) -> MynewtResult<sensor_listener> {
    assert!(!sensor_key.is_empty(), "missing sensor key");
    //  Find an unused `sensor_listener_info`
    let mut arg = MAX_SENSOR_LISTENERS + 1;
    for i in 0 .. MAX_SENSOR_LISTENERS {
        let info = unsafe { SENSOR_LISTENERS[i] };
        if info.sensor_key.is_empty() {
            arg = i;
            break;
        }
    }
    assert!(arg < MAX_SENSOR_LISTENERS, "increase MAX_SENSOR_LISTENERS");  //  Too many listeners registered. Increase MAX_SENSOR_LISTENERS
    //  Create a Mynewt `sensor_listener` that wraps the allocated `sensor_listener_info`
    let listener = sensor_listener {
        sl_sensor_type: sensor_type,
        sl_func:        Some(wrap_sensor_listener),
        sl_arg:         arg as *mut c_void,
        ..fill_zero!(sensor_listener)
    };
    //  Allocate the `sensor_listener_info`
    unsafe { SENSOR_LISTENERS[arg] = sensor_listener_info {
        sensor_key,
        sensor_type,
        listener_func,
        listener,
    } };
    //  Return the Mynewt `sensor_listener`
    Ok(listener)
}
///  Return a new `sensor_listener` with the sensor type and sensor value function. Called by Visual Embedded Rust.
Return a new `sensor_listener` with the sensor type and sensor value function. Called by Visual Embedded Rust.
Return a new ` sensor_listener ` with the sensor type and sensor value function . Called by Visual Embedded Rust .
pub fn new_sensor_listener(
    sensor_key:     &'static Strn,
    sensor_type:    sensor_type_t, 
    listener_func:  SensorValueFunc
) -> MynewtResult<sensor_listener> {
    assert!(!sensor_key.is_empty(), "missing sensor key");
    //  Find an unused `sensor_listener_info`
    let mut arg = MAX_SENSOR_LISTENERS + 1;
    for i in 0 .. MAX_SENSOR_LISTENERS {
        let info = unsafe { SENSOR_LISTENERS[i] };
        if info.sensor_key.is_empty() {
            arg = i;
            break;
        }
    }
    assert!(arg < MAX_SENSOR_LISTENERS, "increase MAX_SENSOR_LISTENERS");  //  Too many listeners registered. Increase MAX_SENSOR_LISTENERS
    //  Create a Mynewt `sensor_listener` that wraps the allocated `sensor_listener_info`
    let listener = sensor_listener {
        sl_sensor_type: sensor_type,
        sl_func:        Some(wrap_sensor_listener),
        sl_arg:         arg as *mut c_void,
        ..fill_zero!(sensor_listener)
    };
    //  Allocate the `sensor_listener_info`
    unsafe { SENSOR_LISTENERS[arg] = sensor_listener_info {
        sensor_key,
        sensor_type,
        listener_func,
        listener,
    } };
    //  Return the Mynewt `sensor_listener`
    Ok(listener)
}
pub fn new_sensor_listener ( sensor_key : & ' static Strn , sensor_type : sensor_type_t , listener_func : SensorValueFunc ) -> MynewtResult < sensor_listener > { assert ! ( sensor_key is_empty ( ) " " ) ; //  Find an unused `sensor_listener_info` let mut arg = MAX_SENSOR_LISTENERS + 1 ; for i in 0 .. MAX_SENSOR_LISTENERS { let info = unsafe { SENSOR_LISTENERS [ i ] } ; if info . sensor_key . is_empty ( ) { arg = i ; break ; } } assert ! ( arg MAX_SENSOR_LISTENERS " " ) ; //  Too many listeners registered. Increase MAX_SENSOR_LISTENERS //  Create a Mynewt `sensor_listener` that wraps the allocated `sensor_listener_info` let listener = sensor_listener { sl_sensor_type : sensor_type , sl_func : Some ( wrap_sensor_listener ) , sl_arg : arg as * mut c_void , .. fill_zero ! ( sensor_listener ) } ; //  Allocate the `sensor_listener_info` unsafe { SENSOR_LISTENERS [ arg ] = sensor_listener_info { sensor_key , sensor_type , listener_func , listener , } } ; //  Return the Mynewt `sensor_listener` Ok ( listener ) }
Return a new `sensor_listener` with the sensor type and sensor value function.
Return a new ` sensor_listener ` with the sensor type and sensor value function .
sensor_key
&'static Strn
sensor_type
sensor_type_t
listener_func
SensorValueFunc
sensor_key
&'static Strn
sensor_type
sensor_type_t
listener_func
SensorValueFunc