-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55f8397
commit ef957e5
Showing
23 changed files
with
357 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <etl/array.h> | ||
|
||
namespace shrapnel::presets { | ||
using id_t = etl::array<uint8_t, 16>; | ||
using id_t = std::array<uint8_t, 16>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
firmware/components/presets/include/selected_preset_json_builder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
// Disable warning inside rapidjson | ||
// https://github.com/Tencent/rapidjson/issues/1700 | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wclass-memaccess" | ||
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" | ||
#pragma GCC diagnostic ignored "-Wsign-conversion" | ||
#pragma GCC diagnostic ignored "-Wswitch-enum" | ||
#include "rapidjson/document.h" | ||
#include "rapidjson/writer.h" | ||
#pragma GCC diagnostic pop | ||
|
||
#include "selected_preset_api.h" | ||
|
||
namespace shrapnel::selected_preset { | ||
|
||
/** Convert \p object to a JSON value | ||
* | ||
* \note The \p document must not by modified by this function. It is only | ||
* passed in so that its allocator member can be accessed. | ||
*/ | ||
template <typename T> | ||
rapidjson::Value to_json(rapidjson::Document &document, const T &object); | ||
|
||
template <> | ||
rapidjson::Value to_json(rapidjson::Document &document, | ||
const Read &object); | ||
|
||
template <> | ||
rapidjson::Value to_json(rapidjson::Document &document, | ||
const Notify &object); | ||
|
||
template <> | ||
rapidjson::Value to_json(rapidjson::Document &document, | ||
const Write &object); | ||
|
||
} // namespace shrapnel::selected_preset |
22 changes: 22 additions & 0 deletions
22
firmware/components/presets/src/selected_preset_json_builder.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "selected_preset_json_builder.h" | ||
|
||
namespace shrapnel::selected_preset { | ||
|
||
template <> | ||
rapidjson::Value to_json(rapidjson::Document &document, const Notify &object) | ||
{ | ||
rapidjson::Value json; | ||
json.SetObject(); | ||
|
||
json.AddMember("messageType", | ||
rapidjson::StringRef("SelectedPreset::notify"), | ||
document.GetAllocator()); | ||
|
||
json.AddMember("selectedPreset", | ||
uuid::to_json(document, object.selectedPresetId), | ||
document.GetAllocator()); | ||
|
||
return json; | ||
} | ||
|
||
} // namespace shrapnel::selected_preset |
Oops, something went wrong.