Skip to content

Commit

Permalink
Minor LittleFS implementation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehaenger committed Oct 12, 2024
1 parent 7899164 commit 4f11010
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Firmware/LowLevel/include/config_defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
#define SOUND_VOLUME 80 // Volume (0-100%)
#define LANGUAGE 'e', 'n' // ISO 639-1 (2-char) language code (en, de, ...)

#define CONFIG_FILENAME "/openmower.cfg" // Where our llhl_config get saved in LittleFS (flash)

This comment has been minimized.

Copy link
@rovo89

rovo89 Oct 14, 2024

Contributor

Since you're removing the include in the next commit, does it still compile? Didn't test...

This comment has been minimized.

Copy link
@Apehaenger

Apehaenger Oct 14, 2024

Author Contributor

Yip. Compiled the last time immediately before the latest commit.

This comment has been minimized.

Copy link
@rovo89

rovo89 Oct 14, 2024

Contributor

Did you remove debug.h and config_defaults.h from your disk as well? They're gone from the PR, but still referenced in main.cpp in your branch, so I assume you still have them locally.

This comment has been minimized.

Copy link
@rovo89

rovo89 Oct 14, 2024

Contributor

And if I remove the includes, various errors are shown.
See https://github.com/Apehaenger/OpenMower/compare/feature/config-packet-trailer...rovo89:OpenMower:no_defaults_include?expand=1, although it doesn't merge cleanly anymore.

This comment has been minimized.

Copy link
@Apehaenger

Apehaenger Oct 14, 2024

Author Contributor

Yes, just looked directly @ github, you're right 😕 ... whats up there...
Damn... and sorry! Forgot to commit main somehow.

This comment has been minimized.

Copy link
@rovo89

rovo89 Oct 14, 2024

Contributor

Much better now 👍


#endif // _CONFIG_H
16 changes: 9 additions & 7 deletions Firmware/LowLevel/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
// SOFTWARE.
//
//
#include <NeoPixelConnect.h>
#include <Arduino.h>
#include <FastCRC.h>
#include <LittleFS.h>
#include <NeoPixelConnect.h>
#include <PacketSerial.h>
#include "datatypes.h"

#include "config_defaults.h"
#include "datatypes.h"
#include "debug.h"
#include "imu.h"
#include "pins.h"
#include "ui_board.h"
#include "imu.h"
#include "debug.h"
#include <LittleFS.h>

#ifdef ENABLE_SOUND_MODULE
#include <soundsystem.h>
Expand Down Expand Up @@ -119,7 +120,6 @@ uint8_t ui_topic_bitmask = Topic_set_leds; // UI subscription, default to Set_LE
uint16_t ui_interval = 1000; // UI send msg (LED/State) interval (ms)

struct ll_high_level_config llhl_config; // LL/HL configuration (is initialized with YF-C500 defaults)
const String CONFIG_FILENAME = "/openmower.cfg";
uint16_t config_crc_in_flash = 0;

void sendMessage(void *message, size_t size);
Expand Down Expand Up @@ -550,7 +550,7 @@ void sendConfigMessage(uint8_t pkt_type) {
size_t msg_size = sizeof(struct ll_high_level_config) + 3; // + 1 type + 2 crc
uint8_t *msg = (uint8_t *)malloc(msg_size);
if (msg == NULL)
return; // malloc() failed
return;
*msg = pkt_type;
memcpy(msg + 1, &llhl_config, sizeof(struct ll_high_level_config)); // Copy our live config into the message, behind type
sendMessage(msg, msg_size);
Expand Down Expand Up @@ -833,6 +833,8 @@ void readConfigFromFlash() {
// read config
uint8_t *buffer = (uint8_t *)malloc(f.size());
f.read(buffer, size);
if (buffer == NULL)

This comment has been minimized.

Copy link
@rovo89

rovo89 Oct 14, 2024

Contributor

Good catch with the NULL check, but I think you want to move this up by one line. 😉

This comment has been minimized.

Copy link
@Apehaenger

Apehaenger Oct 14, 2024

Author Contributor

Unbelievable, it's fully useless there 😳 . Thanks!!

return;
f.close();

// check the CRC
Expand Down

0 comments on commit 4f11010

Please sign in to comment.