Skip to content

Commit

Permalink
Bring back boardtype string
Browse files Browse the repository at this point in the history
  • Loading branch information
loucass003 committed Nov 5, 2023
1 parent 53d201e commit a39f0b1
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 40 deletions.
36 changes: 26 additions & 10 deletions protocol/cpp/include/solarxr_protocol/generated/all_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -2492,7 +2492,8 @@ struct HardwareInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VT_FIRMWARE_VERSION = 14,
VT_HARDWARE_ADDRESS = 16,
VT_IP_ADDRESS = 18,
VT_BOARD_TYPE_ID = 22,
VT_BOARD_TYPE = 20,
VT_OFFICIAL_BOARD_TYPE = 22,
VT_HARDWARE_IDENTIFIER = 24
};
solarxr_protocol::datatypes::hardware_info::McuType mcu_id() const {
Expand Down Expand Up @@ -2524,8 +2525,13 @@ struct HardwareInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
const solarxr_protocol::datatypes::Ipv4Address *ip_address() const {
return GetStruct<const solarxr_protocol::datatypes::Ipv4Address *>(VT_IP_ADDRESS);
}
solarxr_protocol::datatypes::hardware_info::BoardType board_type_id() const {
return static_cast<solarxr_protocol::datatypes::hardware_info::BoardType>(GetField<uint16_t>(VT_BOARD_TYPE_ID, 0));
/// A board type string that can be used to name a board. if possible you should use official board type
const flatbuffers::String *board_type() const {
return GetPointer<const flatbuffers::String *>(VT_BOARD_TYPE);
}
/// An enum listing all the board types supported by the firmware
solarxr_protocol::datatypes::hardware_info::BoardType official_board_type() const {
return static_cast<solarxr_protocol::datatypes::hardware_info::BoardType>(GetField<uint16_t>(VT_OFFICIAL_BOARD_TYPE, 0));
}
/// A unique identifier for the device. Depending on the type of device it can be the MAC address,
/// the IP address, or some other unique identifier like what USB device it is.
Expand All @@ -2547,7 +2553,9 @@ struct HardwareInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
verifier.VerifyString(firmware_version()) &&
VerifyField<solarxr_protocol::datatypes::hardware_info::HardwareAddress>(verifier, VT_HARDWARE_ADDRESS, 8) &&
VerifyField<solarxr_protocol::datatypes::Ipv4Address>(verifier, VT_IP_ADDRESS, 4) &&
VerifyField<uint16_t>(verifier, VT_BOARD_TYPE_ID, 2) &&
VerifyOffset(verifier, VT_BOARD_TYPE) &&
verifier.VerifyString(board_type()) &&
VerifyField<uint16_t>(verifier, VT_OFFICIAL_BOARD_TYPE, 2) &&
VerifyOffset(verifier, VT_HARDWARE_IDENTIFIER) &&
verifier.VerifyString(hardware_identifier()) &&
verifier.EndTable();
Expand Down Expand Up @@ -2582,8 +2590,11 @@ struct HardwareInfoBuilder {
void add_ip_address(const solarxr_protocol::datatypes::Ipv4Address *ip_address) {
fbb_.AddStruct(HardwareInfo::VT_IP_ADDRESS, ip_address);
}
void add_board_type_id(solarxr_protocol::datatypes::hardware_info::BoardType board_type_id) {
fbb_.AddElement<uint16_t>(HardwareInfo::VT_BOARD_TYPE_ID, static_cast<uint16_t>(board_type_id), 0);
void add_board_type(flatbuffers::Offset<flatbuffers::String> board_type) {
fbb_.AddOffset(HardwareInfo::VT_BOARD_TYPE, board_type);
}
void add_official_board_type(solarxr_protocol::datatypes::hardware_info::BoardType official_board_type) {
fbb_.AddElement<uint16_t>(HardwareInfo::VT_OFFICIAL_BOARD_TYPE, static_cast<uint16_t>(official_board_type), 0);
}
void add_hardware_identifier(flatbuffers::Offset<flatbuffers::String> hardware_identifier) {
fbb_.AddOffset(HardwareInfo::VT_HARDWARE_IDENTIFIER, hardware_identifier);
Expand All @@ -2609,18 +2620,20 @@ inline flatbuffers::Offset<HardwareInfo> CreateHardwareInfo(
flatbuffers::Offset<flatbuffers::String> firmware_version = 0,
const solarxr_protocol::datatypes::hardware_info::HardwareAddress *hardware_address = nullptr,
const solarxr_protocol::datatypes::Ipv4Address *ip_address = nullptr,
solarxr_protocol::datatypes::hardware_info::BoardType board_type_id = solarxr_protocol::datatypes::hardware_info::BoardType::UNKNOWN,
flatbuffers::Offset<flatbuffers::String> board_type = 0,
solarxr_protocol::datatypes::hardware_info::BoardType official_board_type = solarxr_protocol::datatypes::hardware_info::BoardType::UNKNOWN,
flatbuffers::Offset<flatbuffers::String> hardware_identifier = 0) {
HardwareInfoBuilder builder_(_fbb);
builder_.add_hardware_identifier(hardware_identifier);
builder_.add_board_type(board_type);
builder_.add_ip_address(ip_address);
builder_.add_hardware_address(hardware_address);
builder_.add_firmware_version(firmware_version);
builder_.add_hardware_revision(hardware_revision);
builder_.add_manufacturer(manufacturer);
builder_.add_model(model);
builder_.add_display_name(display_name);
builder_.add_board_type_id(board_type_id);
builder_.add_official_board_type(official_board_type);
builder_.add_mcu_id(mcu_id);
return builder_.Finish();
}
Expand All @@ -2635,13 +2648,15 @@ inline flatbuffers::Offset<HardwareInfo> CreateHardwareInfoDirect(
const char *firmware_version = nullptr,
const solarxr_protocol::datatypes::hardware_info::HardwareAddress *hardware_address = nullptr,
const solarxr_protocol::datatypes::Ipv4Address *ip_address = nullptr,
solarxr_protocol::datatypes::hardware_info::BoardType board_type_id = solarxr_protocol::datatypes::hardware_info::BoardType::UNKNOWN,
const char *board_type = nullptr,
solarxr_protocol::datatypes::hardware_info::BoardType official_board_type = solarxr_protocol::datatypes::hardware_info::BoardType::UNKNOWN,
const char *hardware_identifier = nullptr) {
auto display_name__ = display_name ? _fbb.CreateString(display_name) : 0;
auto model__ = model ? _fbb.CreateString(model) : 0;
auto manufacturer__ = manufacturer ? _fbb.CreateString(manufacturer) : 0;
auto hardware_revision__ = hardware_revision ? _fbb.CreateString(hardware_revision) : 0;
auto firmware_version__ = firmware_version ? _fbb.CreateString(firmware_version) : 0;
auto board_type__ = board_type ? _fbb.CreateString(board_type) : 0;
auto hardware_identifier__ = hardware_identifier ? _fbb.CreateString(hardware_identifier) : 0;
return solarxr_protocol::datatypes::hardware_info::CreateHardwareInfo(
_fbb,
Expand All @@ -2653,7 +2668,8 @@ inline flatbuffers::Offset<HardwareInfo> CreateHardwareInfoDirect(
firmware_version__,
hardware_address,
ip_address,
board_type_id,
board_type__,
official_board_type,
hardware_identifier__);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ public final class HardwareInfo extends Table {
public solarxr_protocol.datatypes.hardware_info.HardwareAddress hardwareAddress(solarxr_protocol.datatypes.hardware_info.HardwareAddress obj) { int o = __offset(16); return o != 0 ? obj.__assign(o + bb_pos, bb) : null; }
public solarxr_protocol.datatypes.Ipv4Address ipAddress() { return ipAddress(new solarxr_protocol.datatypes.Ipv4Address()); }
public solarxr_protocol.datatypes.Ipv4Address ipAddress(solarxr_protocol.datatypes.Ipv4Address obj) { int o = __offset(18); return o != 0 ? obj.__assign(o + bb_pos, bb) : null; }
public int boardTypeId() { int o = __offset(22); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
/**
* A board type string that can be used to name a board. if possible you should use official board type
*/
public String boardType() { int o = __offset(20); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer boardTypeAsByteBuffer() { return __vector_as_bytebuffer(20, 1); }
public ByteBuffer boardTypeInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 20, 1); }
/**
* An enum listing all the board types supported by the firmware
*/
public int officialBoardType() { int o = __offset(22); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
/**
* A unique identifier for the device. Depending on the type of device it can be the MAC address,
* the IP address, or some other unique identifier like what USB device it is.
Expand All @@ -71,7 +80,8 @@ public final class HardwareInfo extends Table {
public static void addFirmwareVersion(FlatBufferBuilder builder, int firmwareVersionOffset) { builder.addOffset(5, firmwareVersionOffset, 0); }
public static void addHardwareAddress(FlatBufferBuilder builder, int hardwareAddressOffset) { builder.addStruct(6, hardwareAddressOffset, 0); }
public static void addIpAddress(FlatBufferBuilder builder, int ipAddressOffset) { builder.addStruct(7, ipAddressOffset, 0); }
public static void addBoardTypeId(FlatBufferBuilder builder, int boardTypeId) { builder.addShort(9, (short) boardTypeId, (short) 0); }
public static void addBoardType(FlatBufferBuilder builder, int boardTypeOffset) { builder.addOffset(8, boardTypeOffset, 0); }
public static void addOfficialBoardType(FlatBufferBuilder builder, int officialBoardType) { builder.addShort(9, (short) officialBoardType, (short) 0); }
public static void addHardwareIdentifier(FlatBufferBuilder builder, int hardwareIdentifierOffset) { builder.addOffset(10, hardwareIdentifierOffset, 0); }
public static int endHardwareInfo(FlatBufferBuilder builder) {
int o = builder.endTable();
Expand Down Expand Up @@ -106,8 +116,10 @@ public void unpackTo(HardwareInfoT _o) {
else _o.setHardwareAddress(null);
if (ipAddress() != null) ipAddress().unpackTo(_o.getIpAddress());
else _o.setIpAddress(null);
int _oBoardTypeId = boardTypeId();
_o.setBoardTypeId(_oBoardTypeId);
String _oBoardType = boardType();
_o.setBoardType(_oBoardType);
int _oOfficialBoardType = officialBoardType();
_o.setOfficialBoardType(_oOfficialBoardType);
String _oHardwareIdentifier = hardwareIdentifier();
_o.setHardwareIdentifier(_oHardwareIdentifier);
}
Expand All @@ -118,6 +130,7 @@ public static int pack(FlatBufferBuilder builder, HardwareInfoT _o) {
int _manufacturer = _o.getManufacturer() == null ? 0 : builder.createString(_o.getManufacturer());
int _hardwareRevision = _o.getHardwareRevision() == null ? 0 : builder.createString(_o.getHardwareRevision());
int _firmwareVersion = _o.getFirmwareVersion() == null ? 0 : builder.createString(_o.getFirmwareVersion());
int _boardType = _o.getBoardType() == null ? 0 : builder.createString(_o.getBoardType());
int _hardwareIdentifier = _o.getHardwareIdentifier() == null ? 0 : builder.createString(_o.getHardwareIdentifier());
startHardwareInfo(builder);
addMcuId(builder, _o.getMcuId());
Expand All @@ -128,7 +141,8 @@ public static int pack(FlatBufferBuilder builder, HardwareInfoT _o) {
addFirmwareVersion(builder, _firmwareVersion);
addHardwareAddress(builder, solarxr_protocol.datatypes.hardware_info.HardwareAddress.pack(builder, _o.getHardwareAddress()));
addIpAddress(builder, solarxr_protocol.datatypes.Ipv4Address.pack(builder, _o.getIpAddress()));
addBoardTypeId(builder, _o.getBoardTypeId());
addBoardType(builder, _boardType);
addOfficialBoardType(builder, _o.getOfficialBoardType());
addHardwareIdentifier(builder, _hardwareIdentifier);
return endHardwareInfo(builder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class HardwareInfoT {
private String firmwareVersion;
private solarxr_protocol.datatypes.hardware_info.HardwareAddressT hardwareAddress;
private solarxr_protocol.datatypes.Ipv4AddressT ipAddress;
private int boardTypeId;
private String boardType;
private int officialBoardType;
private String hardwareIdentifier;

public int getMcuId() { return mcuId; }
Expand Down Expand Up @@ -51,9 +52,13 @@ public class HardwareInfoT {

public void setIpAddress(solarxr_protocol.datatypes.Ipv4AddressT ipAddress) { this.ipAddress = ipAddress; }

public int getBoardTypeId() { return boardTypeId; }
public String getBoardType() { return boardType; }

public void setBoardTypeId(int boardTypeId) { this.boardTypeId = boardTypeId; }
public void setBoardType(String boardType) { this.boardType = boardType; }

public int getOfficialBoardType() { return officialBoardType; }

public void setOfficialBoardType(int officialBoardType) { this.officialBoardType = officialBoardType; }

public String getHardwareIdentifier() { return hardwareIdentifier; }

Expand All @@ -69,7 +74,8 @@ public HardwareInfoT() {
this.firmwareVersion = null;
this.hardwareAddress = new solarxr_protocol.datatypes.hardware_info.HardwareAddressT();
this.ipAddress = new solarxr_protocol.datatypes.Ipv4AddressT();
this.boardTypeId = 0;
this.boardType = null;
this.officialBoardType = 0;
this.hardwareIdentifier = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,20 @@ class HardwareInfo : Table() {
null
}
}
val boardTypeId : UShort
/**
* A board type string that can be used to name a board. if possible you should use official board type
*/
val boardType : String?
get() {
val o = __offset(20)
return if (o != 0) __string(o + bb_pos) else null
}
val boardTypeAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(20, 1)
fun boardTypeInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 20, 1)
/**
* An enum listing all the board types supported by the firmware
*/
val officialBoardType : UShort
get() {
val o = __offset(22)
return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
Expand Down Expand Up @@ -137,7 +150,9 @@ class HardwareInfo : Table() {
@JvmStatic
fun addIpAddress(builder: FlatBufferBuilder, ipAddress: Int) = builder.addStruct(7, ipAddress, 0)
@JvmStatic
fun addBoardTypeId(builder: FlatBufferBuilder, boardTypeId: UShort) = builder.addShort(9, boardTypeId.toShort(), 0)
fun addBoardType(builder: FlatBufferBuilder, boardType: Int) = builder.addOffset(8, boardType, 0)
@JvmStatic
fun addOfficialBoardType(builder: FlatBufferBuilder, officialBoardType: UShort) = builder.addShort(9, officialBoardType.toShort(), 0)
@JvmStatic
fun addHardwareIdentifier(builder: FlatBufferBuilder, hardwareIdentifier: Int) = builder.addOffset(10, hardwareIdentifier, 0)
@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ impl<'a> HardwareInfo<'a> {
pub const VT_FIRMWARE_VERSION: flatbuffers::VOffsetT = 14;
pub const VT_HARDWARE_ADDRESS: flatbuffers::VOffsetT = 16;
pub const VT_IP_ADDRESS: flatbuffers::VOffsetT = 18;
pub const VT_BOARD_TYPE_ID: flatbuffers::VOffsetT = 22;
pub const VT_BOARD_TYPE: flatbuffers::VOffsetT = 20;
pub const VT_OFFICIAL_BOARD_TYPE: flatbuffers::VOffsetT = 22;
pub const VT_HARDWARE_IDENTIFIER: flatbuffers::VOffsetT = 24;

#[inline]
Expand All @@ -48,14 +49,15 @@ impl<'a> HardwareInfo<'a> {
) -> flatbuffers::WIPOffset<HardwareInfo<'bldr>> {
let mut builder = HardwareInfoBuilder::new(_fbb);
if let Some(x) = args.hardware_identifier { builder.add_hardware_identifier(x); }
if let Some(x) = args.board_type { builder.add_board_type(x); }
if let Some(x) = args.ip_address { builder.add_ip_address(x); }
if let Some(x) = args.hardware_address { builder.add_hardware_address(x); }
if let Some(x) = args.firmware_version { builder.add_firmware_version(x); }
if let Some(x) = args.hardware_revision { builder.add_hardware_revision(x); }
if let Some(x) = args.manufacturer { builder.add_manufacturer(x); }
if let Some(x) = args.model { builder.add_model(x); }
if let Some(x) = args.display_name { builder.add_display_name(x); }
builder.add_board_type_id(args.board_type_id);
builder.add_official_board_type(args.official_board_type);
builder.add_mcu_id(args.mcu_id);
builder.finish()
}
Expand Down Expand Up @@ -122,12 +124,21 @@ impl<'a> HardwareInfo<'a> {
// which contains a valid value in this slot
unsafe { self._tab.get::<super::Ipv4Address>(HardwareInfo::VT_IP_ADDRESS, None)}
}
/// A board type string that can be used to name a board. if possible you should use official board type
#[inline]
pub fn board_type_id(&self) -> BoardType {
pub fn board_type(&self) -> Option<&'a str> {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe { self._tab.get::<BoardType>(HardwareInfo::VT_BOARD_TYPE_ID, Some(BoardType::UNKNOWN)).unwrap()}
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(HardwareInfo::VT_BOARD_TYPE, None)}
}
/// An enum listing all the board types supported by the firmware
#[inline]
pub fn official_board_type(&self) -> BoardType {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe { self._tab.get::<BoardType>(HardwareInfo::VT_OFFICIAL_BOARD_TYPE, Some(BoardType::UNKNOWN)).unwrap()}
}
/// A unique identifier for the device. Depending on the type of device it can be the MAC address,
/// the IP address, or some other unique identifier like what USB device it is.
Expand Down Expand Up @@ -155,7 +166,8 @@ impl flatbuffers::Verifiable for HardwareInfo<'_> {
.visit_field::<flatbuffers::ForwardsUOffset<&str>>("firmware_version", Self::VT_FIRMWARE_VERSION, false)?
.visit_field::<HardwareAddress>("hardware_address", Self::VT_HARDWARE_ADDRESS, false)?
.visit_field::<super::Ipv4Address>("ip_address", Self::VT_IP_ADDRESS, false)?
.visit_field::<BoardType>("board_type_id", Self::VT_BOARD_TYPE_ID, false)?
.visit_field::<flatbuffers::ForwardsUOffset<&str>>("board_type", Self::VT_BOARD_TYPE, false)?
.visit_field::<BoardType>("official_board_type", Self::VT_OFFICIAL_BOARD_TYPE, false)?
.visit_field::<flatbuffers::ForwardsUOffset<&str>>("hardware_identifier", Self::VT_HARDWARE_IDENTIFIER, false)?
.finish();
Ok(())
Expand All @@ -170,7 +182,8 @@ pub struct HardwareInfoArgs<'a> {
pub firmware_version: Option<flatbuffers::WIPOffset<&'a str>>,
pub hardware_address: Option<&'a HardwareAddress>,
pub ip_address: Option<&'a super::Ipv4Address>,
pub board_type_id: BoardType,
pub board_type: Option<flatbuffers::WIPOffset<&'a str>>,
pub official_board_type: BoardType,
pub hardware_identifier: Option<flatbuffers::WIPOffset<&'a str>>,
}
impl<'a> Default for HardwareInfoArgs<'a> {
Expand All @@ -185,7 +198,8 @@ impl<'a> Default for HardwareInfoArgs<'a> {
firmware_version: None,
hardware_address: None,
ip_address: None,
board_type_id: BoardType::UNKNOWN,
board_type: None,
official_board_type: BoardType::UNKNOWN,
hardware_identifier: None,
}
}
Expand Down Expand Up @@ -229,8 +243,12 @@ impl<'a: 'b, 'b> HardwareInfoBuilder<'a, 'b> {
self.fbb_.push_slot_always::<&super::Ipv4Address>(HardwareInfo::VT_IP_ADDRESS, ip_address);
}
#[inline]
pub fn add_board_type_id(&mut self, board_type_id: BoardType) {
self.fbb_.push_slot::<BoardType>(HardwareInfo::VT_BOARD_TYPE_ID, board_type_id, BoardType::UNKNOWN);
pub fn add_board_type(&mut self, board_type: flatbuffers::WIPOffset<&'b str>) {
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(HardwareInfo::VT_BOARD_TYPE, board_type);
}
#[inline]
pub fn add_official_board_type(&mut self, official_board_type: BoardType) {
self.fbb_.push_slot::<BoardType>(HardwareInfo::VT_OFFICIAL_BOARD_TYPE, official_board_type, BoardType::UNKNOWN);
}
#[inline]
pub fn add_hardware_identifier(&mut self, hardware_identifier: flatbuffers::WIPOffset<&'b str>) {
Expand Down Expand Up @@ -262,7 +280,8 @@ impl core::fmt::Debug for HardwareInfo<'_> {
ds.field("firmware_version", &self.firmware_version());
ds.field("hardware_address", &self.hardware_address());
ds.field("ip_address", &self.ip_address());
ds.field("board_type_id", &self.board_type_id());
ds.field("board_type", &self.board_type());
ds.field("official_board_type", &self.official_board_type());
ds.field("hardware_identifier", &self.hardware_identifier());
ds.finish()
}
Expand Down
Loading

0 comments on commit a39f0b1

Please sign in to comment.