30#ifndef _N2kDeviceList_H_
31#define _N2kDeviceList_H_
38#define N2kMaxBusDevices 254
42#define N2kDL_TimeForFirstRequest 1000
45#define N2kDL_TimeBetweenPIRequest 1000
48#define N2kDL_TimeBetweenCIRequest 1000
184 unsigned short _ProductCode=0xffff,
185 const char *_ModelID=0,
186 const char *_SwCode=0,
187 const char *_ModelVersion=0,
188 unsigned char _LoadEquivalency=0xff,
189 unsigned short _N2kVersion=0xffff,
190 unsigned char _CertificationLevel=0xff
192 ProdI.
Set(_ModelSerialCode,_ProductCode,_ModelID,_SwCode,_ModelVersion,_LoadEquivalency,_N2kVersion,_CertificationLevel);
713 uint8_t
Count()
const;
#define N2kDL_TimeBetweenCIRequest
Time in ms between configuration information requests.
#define N2kMaxBusDevices
Maximum allowed number of devices on the CAN BUS bus system is 254.
#define N2kDL_TimeBetweenPIRequest
Time in ms between product information requests.
#define N2kDL_TimeForFirstRequest
Time in ms for first request after device has been noticed on the bus.
bool N2kHasElapsed(uint32_t Start, uint32_t Elapsed, uint32_t Now=N2kMillis())
Has time elapsed since start.
This file contains the class tNMEA2000, which consists the main functionality of the library.
This class represents an internal device.
char * InstallationDescription1
Pointer to the Installation Description 1.
void ClearConfigurationInformationLoaded()
Resets the Configuration Information Loaded values of the device.
unsigned short GetLoadEquivalency() const
Get the Load Equivalency (x * 50 mA) of this device.
uint16_t InstDesc1Size
Size of the Installation Description 1 (number of bytes)
unsigned long * InitReceivePGNs(uint8_t count)
Initialize an array for received PGNs This functions frees if needed old reservation and reserves new...
bool ShouldRequestProductInformation()
Should the Device Product Information be requested As long as the device Product Information is not s...
const char * GetInstallationDescription1() const
Get the Installation Description 1 of this device.
const char * GetSwCode() const
Get the Software Code of this device.
uint8_t nProdIRequested
How many times we have requested the Product information.
bool ProdILoaded
Product Information has been loaded.
const char * GetInstallationDescription2() const
Get the Installation Description 2 of this device.
const char * GetModelVersion() const
Get the Model Version of this device.
const unsigned long * GetReceivePGNs() const
Get the received PGNs of this device.
void SetDeviceInformation(uint64_t _Name)
Set the Device Information.
uint16_t InstDesc2Size
Size of the Installation Description 2 (number of bytes)
void SetConfigurationInformationRequested()
Increments the Number of how often the Configuration Information has already been requested and store...
unsigned short GetProductCode() const
Get the Product code of this device.
uint8_t nConfIRequested
How many times we have requested the Config information.
char * GetManufacturerInformation()
Get the Manufacturer Information of this device.
char * GetInstallationDescription2()
Get the Installation Description 2 of this device.
const char * GetModelSerialCode() const
Get the Model Serial Code of this device.
const char * GetManufacturerInformation() const
Get the Manufacturer Information of this device.
char * ManufacturerInformation
Pointer to the Manufacturer Information.
bool ShouldRequestName()
Should the Device Name be requested As long as the device name is not set yet and the number of reque...
unsigned long * TransmitPGNs
Transmitted PGNs.
bool HasProductInformation() const
Has the Product Information for the device already been loaded.
char * InitConfigurationInformation(size_t &_ManISize, size_t &_InstDesc1Size, size_t &_InstDesc2Size)
Initialize the Configuration Information of this device.
bool ShouldRequestPGNList()
Should the Device PGN List be requested As long as the device PGN List is not set yet and the number ...
uint8_t TransmitPGNsSize
Size of the transmitted PGN (number of bytes)
void ClearProductInformation()
Clears the Product Information the device.
unsigned long ProdIRequested
Time for last request on the Product Information.
unsigned long * InitTransmitPGNs(uint8_t count)
Initialize an array for transmitted PGNs This functions frees if needed old reservation and reserves ...
unsigned long ConfIRequested
Time for last request on the Config Information.
uint16_t ConfISize
Size of the Config Information (number of bytes)
bool ReadyForRequestProductInformation()
Ready for the next request of Device Product Information.
bool ShouldRequestConfigurationInformation()
Should the Device Configuration Information be requested As long as the device Configuration Informat...
void ClearPGNListLoaded()
Resets the PGN List Loaded values of the device.
void SetProductInformation(const char *_ModelSerialCode, unsigned short _ProductCode=0xffff, const char *_ModelID=0, const char *_SwCode=0, const char *_ModelVersion=0, unsigned char _LoadEquivalency=0xff, unsigned short _N2kVersion=0xffff, unsigned char _CertificationLevel=0xff)
Set the Product Information of the device.
uint8_t nPGNsRequested
How many times we have requested the PGN.
tInternalDevice(uint64_t _Name, uint8_t _Source=255)
Construct a new Internal Device object.
char * GetInstallationDescription1()
Get the Installation Description 1 of this device.
uint8_t ReceivePGNsSize
Size of the received PGN (number of bytes)
bool ReadyForRequestPGNList()
Ready for the next request of Device PGN List.
unsigned long LastMessageTime
Time of the last message.
const char * GetModelID() const
Get the Model ID of this device.
const unsigned long * GetTransmitPGNs() const
Get the transmitted PGNs of this device.
~tInternalDevice()
Destroy the Internal Device object Clean up all the memory.
uint8_t nNameRequested
How many times we have requested the name.
void SetProductInformationRequested()
Increments the Number of how often the Product Information has already been requested and stores the ...
void SetSource(uint8_t _Source)
Set the Source address of the device.
bool IsSameProductInformation(tNMEA2000::tProductInformation &Other)
Compares two Product Informations.
uint16_t ManISize
Size of the Manufacturer Information (number of bytes)
tNMEA2000::tProductInformation ProdI
Product Information of this device.
bool ReadyForRequestConfigurationInformation()
Ready for the next request of Device Configuration Information.
void ClearProductInformationLoaded()
Resets the Product Information Loaded values of the device.
char * ConfI
Pointer to the Config Information.
bool ConfILoaded
Product Information has been loaded.
unsigned short GetCertificationLevel() const
Get the Certification Level of this device.
bool HasConfigurationInformation() const
Has the Configuration Information for the device already been loaded.
unsigned short GetN2kVersion() const
Get the N2k version of this device.
void SetPGNListRequested()
Increments the Number of how often the PGN List has already been requested and stores the timestamp.
unsigned long * ReceivePGNs
Received PGNs.
void SetNameRequested()
Increments the Number of how often the name has already been requested.
unsigned long PGNsRequested
Time for last request on the PGN.
char * InstallationDescription2
Pointer to the Installation Description 2.
Helper class to keep track of all devices on the bus.
void HandleProductInformation(const tN2kMsg &N2kMsg)
Handle a Product Information message - PGN 126996.
void SaveDevice(tInternalDevice *pDevice, uint8_t Source)
Saves a device to Sources.
void HandleOther(const tN2kMsg &N2kMsg)
Handles all Other messages.
void HandleSupportedPGNList(const tN2kMsg &N2kMsg)
Handle a Product Information message - PGN 126464.
uint8_t MaxDevices
Number of NMEA2000 devices stored in Sources.
bool RequestIsoAddressClaim(uint8_t Source)
Request the ISO AddressClaim for a specific device on the bus.
tN2kDeviceList::tInternalDevice * LocalFindDeviceBySource(uint8_t Source) const
Find a device in Sources by the source address.
const tNMEA2000::tDevice * FindDeviceByProduct(uint16_t ManufacturerCode, uint16_t ProductCode, uint8_t Source=0xff) const
Find a device in Sources by the manufacturer and product code.
bool ReadResetIsListUpdated()
Check if device list has updated.
void HandleConfigurationInformation(const tN2kMsg &N2kMsg)
Handle a Configuration Information message - PGN 126998.
bool RequestSupportedPGNList(uint8_t Source)
Request the supported PGNs of a specific device on the bus.
const tNMEA2000::tDevice * FindDeviceByName(uint64_t NAME) const
Find a device in Sources by the NAME of the device.
bool RequestProductInformation(uint8_t Source)
Request the product information of a specific device on the bus.
tInternalDevice * Sources[N2kMaxBusDevices]
List of NMEA2000 devices found on the bus.
const tNMEA2000::tDevice * FindDeviceBySource(uint8_t Source) const
Return device by it's bus source address.
void HandleIsoAddressClaim(const tN2kMsg &N2kMsg)
Handle ISO Address Claim Message - PGN 60928.
bool RequestConfigurationInformation(uint8_t Source)
Request the configuration information of a specific device on the bus.
uint8_t Count() const
Return number of known devices in Sources.
tN2kDeviceList::tInternalDevice * LocalFindDeviceByName(uint64_t Name) const
Find a device in Sources by the name of the device.
tN2kDeviceList::tInternalDevice * LocalFindDeviceByProduct(uint16_t ManufacturerCode, uint16_t ProductCode, uint8_t Source=0xff) const
Find a device in Sources by the manufacturer and product code.
unsigned long GetDeviceLastMessageTime(uint8_t Source) const
const tNMEA2000::tDevice * FindDeviceByIDs(uint16_t ManufacturerCode, uint32_t UniqueNumber) const
Find a device in Sources by the manufacturer code and unique ID.
tN2kDeviceList(tNMEA2000 *_pNMEA2000)
Constructor for the class.
tN2kDeviceList::tInternalDevice * LocalFindDeviceByIDs(uint16_t ManufacturerCode, uint32_t UniqueNumber) const
Find a device in Sources by the manufacturer code and unique ID.
void AddDevice(uint8_t Source)
Adds a device to Sources.
void HandleMsg(const tN2kMsg &N2kMsg)
Handle NMEA2000 messages.
bool HasPendingRequests
There are still requests pending.
bool ListUpdated
The list of devices has been updated.
This class contains all the data of an NMEA2000 message.
This class represents a N2k device.
unsigned long GetCreateTime() const
Returns the Time of Creation of this device.
uint64_t GetName() const
Get the Name of this device.
uint8_t Source
Source address on bus for this device.
tDeviceInformation DevI
This object holds all necessary device informations.
tNMEA2000 device class definition.