Browse Source

display: Do not set zero-filled packets if a packet cannot be encoded.

Mathias Gottschlag 5 years ago
parent
commit
9c1a9bf784
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      display/firmware/src/radio.rs

+ 6
- 4
display/firmware/src/radio.rs View File

108
         let mut get_values = GetValues {
108
         let mut get_values = GetValues {
109
             count: value_types.len() as u8,
109
             count: value_types.len() as u8,
110
             location,
110
             location,
111
-            types_: [ValueType::Time; 8],
111
+            types: [ValueType::Time; 8],
112
         };
112
         };
113
-        get_values.types_[0..value_types.len()].copy_from_slice(value_types);
113
+        get_values.types[0..value_types.len()].copy_from_slice(value_types);
114
         self.send_packet(Packet::GetValues(get_values));
114
         self.send_packet(Packet::GetValues(get_values));
115
 
115
 
116
         // Receive the response.
116
         // Receive the response.
172
         let mut tx = self.nrf24.take().unwrap().tx().unwrap();
172
         let mut tx = self.nrf24.take().unwrap().tx().unwrap();
173
         while !tx.can_send().unwrap() {}
173
         while !tx.can_send().unwrap() {}
174
         let mut payload = [0u8; 32];
174
         let mut payload = [0u8; 32];
175
-        packet.encode_and_encrypt(
175
+        if !packet.encode_and_encrypt(
176
             &KEY,
176
             &KEY,
177
             self.radio.salt.unwrap_or(DEVICE_ID as u64),
177
             self.radio.salt.unwrap_or(DEVICE_ID as u64),
178
             &mut payload,
178
             &mut payload,
179
-        );
179
+        ) {
180
+            return false;
181
+        }
180
         tx.send(&payload).unwrap();
182
         tx.send(&payload).unwrap();
181
         // TODO: Check whether the packet arrived.
183
         // TODO: Check whether the packet arrived.
182
 
184
 

Loading…
Cancel
Save