Skip to content

Commit

Permalink
Support recording device uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
jpieper committed Jun 5, 2021
1 parent 7aa78eb commit 08034e9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions fw/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ mbed_binary(
"power_dist.cc",
"power_dist_hw.h",
"stm32g4_flash.h",
"uuid.h",
],
deps = [
":git_info",
Expand Down
2 changes: 2 additions & 0 deletions fw/power_dist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "fw/millisecond_timer.h"
#include "fw/power_dist_hw.h"
#include "fw/stm32g4_flash.h"
#include "fw/uuid.h"

namespace base = mjlib::base;
namespace micro = mjlib::micro;
Expand Down Expand Up @@ -916,6 +917,7 @@ class PowerDist : public mjlib::multiplex::MicroServer::Server {
fw::Stm32G4Flash flash_interface_;
micro::PersistentConfig persistent_config_{
pool_, command_manager_, flash_interface_};
fw::Uuid uuid_{persistent_config_};
fw::GitInfo git_info_;
fw::FirmwareInfo firmware_info_{pool_, telemetry_manager_, 0, 0};

Expand Down
39 changes: 39 additions & 0 deletions fw/uuid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2021 Josh Pieper, [email protected].
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <array>

namespace fw {

class Uuid {
public:
Uuid(mjlib::micro::PersistentConfig& config) {
config.Register("uuid", &data_, [](){});
}

struct Data {
std::array<uint8_t, 16> uuid = {};

template <typename Archive>
void Serialize(Archive* a) {
a->Visit(MJ_NVP(uuid));
}
};

Data data_;
};

}

0 comments on commit 08034e9

Please sign in to comment.