mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Device: Add ExtendedCommand::GetAllMACAddresses
This commit is contained in:
committed by
Kyle Schwarz
parent
49e578a657
commit
3ab06199c3
@@ -64,6 +64,7 @@ enum class ExtendedCommand : uint16_t {
|
||||
RequestTC10Wake = 0x003D,
|
||||
RequestTC10Sleep = 0x003E,
|
||||
GetTC10Status = 0x003F,
|
||||
GetAllMACAddresses = 0x0040,
|
||||
ProtobufAPI = 0x0041,
|
||||
TransmitMessage = 0x0042,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef __ALLMACADDRESSESMESSAGE_H_
|
||||
#define __ALLMACADDRESSESMESSAGE_H_
|
||||
|
||||
#define ICSNEO_MAC_ADDRESS_LEN 6
|
||||
#define ICSNEO_MAX_MAC_COUNT 32
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/message.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <array>
|
||||
namespace icsneo {
|
||||
|
||||
static constexpr uint16_t MaxMACAddressCount = ICSNEO_MAX_MAC_COUNT;
|
||||
static constexpr uint8_t MACAddressLength = ICSNEO_MAC_ADDRESS_LEN;
|
||||
|
||||
using MACAddress = std::array<uint8_t, MACAddressLength>;
|
||||
|
||||
class AllMACAddressesMessage : public Message {
|
||||
public:
|
||||
static std::shared_ptr<AllMACAddressesMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
|
||||
AllMACAddressesMessage() : Message(Type::AllMACAddresses) {}
|
||||
|
||||
std::unordered_map<Network::NetID, MACAddress> addresses;
|
||||
};
|
||||
|
||||
} // namespace icsneo
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __ALLMACADDRESSESMESSAGE_H_
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
LogData = 0x8015,
|
||||
NetworkMutex = 0x8016,
|
||||
ClientId = 0x8017,
|
||||
AllMACAddresses = 0x8018,
|
||||
};
|
||||
|
||||
Message(Type t) : type(t) {}
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "icsneo/communication/message/versionmessage.h"
|
||||
#include "icsneo/communication/message/gptpstatusmessage.h"
|
||||
#include "icsneo/communication/message/networkmutexmessage.h"
|
||||
#include "icsneo/communication/message/allmacaddressesmessage.h"
|
||||
|
||||
#define ICSNEO_FINDABLE_DEVICE_BASE(className, type) \
|
||||
static constexpr DeviceType::Enum DEVICE_TYPE = type; \
|
||||
@@ -183,7 +184,7 @@ public:
|
||||
std::string getSerial() const { return data.serial; }
|
||||
uint32_t getSerialNumber() const { return Device::SerialStringToNum(getSerial()); }
|
||||
std::optional<std::vector<uint8_t>> getPCBSerial();
|
||||
std::optional<std::vector<uint8_t>> getMACAddress();
|
||||
std::unordered_map<Network::NetID, MACAddress> getMACAddresses();
|
||||
const neodevice_t& getNeoDevice() const { return data; }
|
||||
virtual std::string getProductName() const { return getType().getGenericProductName(); }
|
||||
std::string describe() const;
|
||||
@@ -858,7 +859,7 @@ public:
|
||||
}
|
||||
|
||||
virtual bool supportsTC10() const { return false; }
|
||||
|
||||
|
||||
virtual bool supportsGPTP() const { return false; }
|
||||
|
||||
bool requestTC10Wake(Network::NetID network);
|
||||
@@ -998,6 +999,8 @@ protected:
|
||||
|
||||
bool supportsNetworkMutex = false;
|
||||
|
||||
virtual bool supportsGetAllMACAddresses() const { return true; }
|
||||
|
||||
private:
|
||||
neodevice_t data;
|
||||
std::shared_ptr<ResetStatusMessage> latestResetStatus;
|
||||
|
||||
@@ -62,6 +62,9 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@ public:
|
||||
return ProductID::neoOBD2Pro;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
NeoOBD2PRO(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize(makeDriver);
|
||||
|
||||
@@ -25,6 +25,12 @@ public:
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoOBD2Sim;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
NeoOBD2SIM(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize(makeDriver);
|
||||
|
||||
@@ -93,7 +93,6 @@ protected:
|
||||
}
|
||||
|
||||
bool supportsGPTP() const override { return true; }
|
||||
|
||||
size_t getDiskCount() const override {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,12 @@ public:
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoVIFIRE;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
NeoVIFIRE(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIFIRESettings>(makeDriver);
|
||||
|
||||
@@ -109,7 +109,7 @@ protected:
|
||||
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||
|
||||
bool supportsWiVI() const override { return true; }
|
||||
|
||||
|
||||
bool supportsLiveData() const override { return true; }
|
||||
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressFlash() const override {
|
||||
|
||||
@@ -92,6 +92,10 @@ protected:
|
||||
}
|
||||
|
||||
bool supportsWiVI() const override { return true; }
|
||||
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -79,6 +79,10 @@ protected:
|
||||
size_t getDiskCount() const override {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -85,6 +85,10 @@ protected:
|
||||
size_t getDiskCount() const override {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}; // namespace icsneo
|
||||
|
||||
@@ -80,6 +80,10 @@ protected:
|
||||
bool supportsEraseMemory() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -60,6 +60,10 @@ protected:
|
||||
bool supportsEraseMemory() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -71,6 +71,10 @@ protected:
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,11 @@ public:
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::ValueCAN3;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
ValueCAN3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<ValueCAN3Settings>(makeDriver);
|
||||
|
||||
@@ -28,6 +28,10 @@ protected:
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -68,6 +68,10 @@ protected:
|
||||
bool supportsEraseMemory() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool supportsGetAllMACAddresses() const override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -343,15 +343,52 @@ icsneoc2_error_t icsneoc2_device_serial_get(const icsneoc2_device_t* device, cha
|
||||
icsneoc2_error_t icsneoc2_device_pcb_serial_get(const icsneoc2_device_t* device, uint8_t* value, size_t* value_length);
|
||||
|
||||
/**
|
||||
* Get the MAC address of a device.
|
||||
* Enumerate MAC addresses from a device.
|
||||
*
|
||||
* @param[in] device The device to get the MAC address of.
|
||||
* @param[out] value Pointer to a buffer to copy the MAC address into. If NULL, only value_length is written.
|
||||
* @param[in,out] value_length Size of the value buffer in bytes. Modified with the length of the MAC address.
|
||||
* @param[in] device The device to query.
|
||||
* @param[out] mac_entries Pointer to receive the head of the MAC addresses linked list.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_type if the device does not have a MAC address.
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters on failure.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_device_mac_address_get(const icsneoc2_device_t* device, uint8_t* value, size_t* value_length);
|
||||
icsneoc2_error_t icsneoc2_device_mac_addresses_enumerate(const icsneoc2_device_t* device, icsneoc2_mac_addr_entry_t** mac_entries);
|
||||
|
||||
/**
|
||||
* Get the network ID of a MAC address.
|
||||
*
|
||||
* @param[in] mac_address The MAC address object to get the network ID of.
|
||||
* @param[out] network_id Pointer to an icsneoc2_netid_t to copy the network ID into.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error success if successful, icsneoc2_error_invalid_parameters on failure.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_mac_network_id_get(const icsneoc2_mac_addr_entry_t* mac_address, _icsneoc2_netid_t* network_id);
|
||||
|
||||
/**
|
||||
* Get the MAC Address bytes of a MAC address.
|
||||
*
|
||||
* @param[in] mac_address The MAC address object to get the MAC address bytes of.
|
||||
* @param[out] value Pointer to a buffer to copy the MAC address into. If NULL, only value_length is written.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters on failure.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_mac_address_get(const icsneoc2_mac_addr_entry_t* mac_address, uint8_t* value, size_t* value_length);
|
||||
|
||||
/**
|
||||
* Advance to the next MAC address in an enumeration list.
|
||||
*
|
||||
* @param[in] mac_address The current MAC address node.
|
||||
*
|
||||
* @return icsneoc2_mac_addr_entry_t The next MAC address node.
|
||||
*/
|
||||
icsneoc2_mac_addr_entry_t* icsneoc2_mac_addresses_next(const icsneoc2_mac_addr_entry_t* mac_address);
|
||||
|
||||
/**
|
||||
* Free all MAC addresses in enumeration handle returned by icsneoc2_device_mac_addresses_enumerate().
|
||||
*
|
||||
* @param[in] mac_address The head of the MAC address enumeration to free. May be NULL.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_mac_addresses_free(icsneoc2_mac_addr_entry_t* mac_address);
|
||||
|
||||
/**
|
||||
* Set the online state of a device.
|
||||
|
||||
@@ -583,6 +583,8 @@ typedef enum _icsneoc2_chip_id_t {
|
||||
|
||||
typedef uint8_t icsneoc2_chip_id_t;
|
||||
|
||||
typedef struct icsneoc2_mac_addr_entry_t icsneoc2_mac_addr_entry_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user