Skip to content

Commit 66eaa51

Browse files
committed
Renamed val to value
1 parent b302c97 commit 66eaa51

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

rust/app/src/app_sensor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ extern fn handle_sensor_data(sensor: sensor_ptr, _arg: sensor_arg,
9393

9494
// Get the temperature sensor value. It could be raw or computed.
9595
let sensor_value = convert_sensor_data(sensor_data, sensor_type);
96-
if let SensorValueType::None = sensor_value.val { assert!(false, "bad type"); }
96+
if let SensorValueType::None = sensor_value.value { assert!(false, "bad type"); }
9797

9898
// Compose a CoAP message with the temperature sensor data and send to the
9999
// CoAP server. The message will be enqueued for transmission by the OIC
@@ -122,7 +122,7 @@ fn convert_sensor_data(sensor_data: sensor_data_ptr, sensor_type: sensor_type_t)
122122
SensorValue {
123123
key: &TEMP_SENSOR_KEY, // Sensor data key is `t`
124124
geo: SensorValueType::None, // No location
125-
val: match sensor_type {
125+
value: match sensor_type {
126126
SENSOR_TYPE_AMBIENT_TEMPERATURE_RAW => { // If this is raw temperature...
127127
// Interpret the sensor data as a `sensor_temp_raw_data` struct that contains raw temp.
128128
let mut rawtempdata = fill_zero!(sensor_temp_raw_data);

rust/app/src/gps_sensor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ extern fn handle_gps_data(sensor: sensor_ptr, _arg: sensor_arg,
8181

8282
// Convert the GPS geolocation for transmission.
8383
let sensor_value = convert_gps_data(sensor_data, sensor_type);
84-
if let SensorValueType::None = sensor_value.val {
84+
if let SensorValueType::None = sensor_value.value {
8585
console::print("Warn: GPS not ready\n");
8686
return MynewtError::SYS_EINVAL; // Exit if GPS is not ready
8787
}
8888

8989
// Show the GPS geolocation.
90-
if let SensorValueType::Geolocation { latitude, longitude, altitude } = sensor_value.val {
90+
if let SensorValueType::Geolocation { latitude, longitude, altitude } = sensor_value.value {
9191
console::print("Info: GPS lat: "); console::printdouble(latitude);
9292
console::print(", lng: "); console::printdouble(longitude);
9393
console::print(", alt: "); console::printfloat(altitude as f32);
@@ -110,7 +110,7 @@ fn convert_gps_data(sensor_data: sensor_data_ptr, sensor_type: sensor_type_t) ->
110110
SensorValue {
111111
key: &GPS_SENSOR_KEY, // Sensor data key is `geolocation`
112112
geo: SensorValueType::None,
113-
val: match sensor_type {
113+
value: match sensor_type {
114114
SENSOR_TYPE_GEOLOCATION => { // If sensor data is GPS geolocation...
115115
// Interpret the sensor data as a `sensor_geolocation_data` struct that contains GPS geolocation.
116116
let mut geolocation = fill_zero!(sensor_geolocation_data);
@@ -141,9 +141,9 @@ static mut current_geolocation: SensorValueType = SensorValueType::None;
141141

142142
/// Aggregate the sensor value with other sensor data before transmitting to server.
143143
fn aggregate_sensor_data(sensor_value: SensorValue) {
144-
if let SensorValueType::Geolocation {..} = sensor_value.val {
144+
if let SensorValueType::Geolocation {..} = sensor_value.value {
145145
// Save the geolocation for later transmission.
146-
unsafe { current_geolocation = sensor_value.val };
146+
unsafe { current_geolocation = sensor_value.value };
147147
} else {
148148
// Attach the current geolocation to the sensor data for transmission.
149149
sensor_value.geo = current_geolocation;

rust/mynewt/src/hw/sensor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ extern "C" fn wrap_sensor_listener(
123123

124124
// Convert the sensor data to sensor value
125125
let sensor_value = convert_sensor_data(sensor_data, info.sensor_key, sensor_type);
126-
if let SensorValueType::None = sensor_value.val { assert!(false, "bad type"); }
126+
if let SensorValueType::None = sensor_value.value { assert!(false, "bad type"); }
127127

128128
// Call the unwrapped function
129129
(info.listener_func)(&sensor_value)
@@ -157,8 +157,8 @@ fn convert_sensor_data(sensor_data: sensor_data_ptr, sensor_key: &'static Strn,
157157
// Construct and return a new `SensorValue` (without semicolon)
158158
SensorValue {
159159
key: sensor_key,
160-
loc: SensorValueType::None,
161-
val: match sensor_type {
160+
geo: SensorValueType::None,
161+
value: match sensor_type {
162162
SENSOR_TYPE_AMBIENT_TEMPERATURE_RAW => { // If this is raw temperature...
163163
// Interpret the sensor data as a `sensor_temp_raw_data` struct that contains raw temp.
164164
let mut rawtempdata = fill_zero!(sensor_temp_raw_data);
@@ -246,7 +246,7 @@ pub struct SensorValue {
246246
/// Null-terminated string for the key. `t` for raw temp, `tmp` for computed. When transmitted to CoAP Server or Collector Node, the key (field name) to be used.
247247
pub key: &'static Strn,
248248
/// The type of the sensor value and the value.
249-
pub val: SensorValueType,
249+
pub value: SensorValueType,
250250
/// Geolocation associated with the sensor value.
251251
pub geo: SensorValueType,
252252
}
@@ -257,7 +257,7 @@ impl Default for SensorValue {
257257
fn default() -> SensorValue {
258258
SensorValue {
259259
key: &init_strn!(""),
260-
val: SensorValueType::None,
260+
value: SensorValueType::None,
261261
geo: SensorValueType::None,
262262
}
263263
}

0 commit comments

Comments
 (0)