Ver código fonte

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

Mathias Gottschlag 5 anos atrás
pai
commit
9c1a9bf784
1 arquivos alterados com 6 adições e 4 exclusões
  1. 6
    4
      display/firmware/src/radio.rs

+ 6
- 4
display/firmware/src/radio.rs Ver arquivo

@@ -108,9 +108,9 @@ impl<'a> EnabledRadio<'a> {
108 108
         let mut get_values = GetValues {
109 109
             count: value_types.len() as u8,
110 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 114
         self.send_packet(Packet::GetValues(get_values));
115 115
 
116 116
         // Receive the response.
@@ -172,11 +172,13 @@ impl<'a> EnabledRadio<'a> {
172 172
         let mut tx = self.nrf24.take().unwrap().tx().unwrap();
173 173
         while !tx.can_send().unwrap() {}
174 174
         let mut payload = [0u8; 32];
175
-        packet.encode_and_encrypt(
175
+        if !packet.encode_and_encrypt(
176 176
             &KEY,
177 177
             self.radio.salt.unwrap_or(DEVICE_ID as u64),
178 178
             &mut payload,
179
-        );
179
+        ) {
180
+            return false;
181
+        }
180 182
         tx.send(&payload).unwrap();
181 183
         // TODO: Check whether the packet arrived.
182 184
 

Carregando…
Cancelar
Salvar