BlackBox Component
Installation
The component requires ESP-IDF 5.3 and higher and is installed using IDF Component Manager.
Add this to the idf_component.yml
in the project main
directory or in the component directory:
dependencies:
plasmapper/pl_blackbox: "^2.0.2"
Add this to the source code:
#include "pl_blackbox.h"
Add extern "C"
to the app_main
function:
extern "C" void app_main(void) {...}
Add this to the sdkconfig.defaults
in the project directory or configure the values using Project Configuration:
CONFIG_COMPILER_CXX_RTTI=y
CONFIG_LWIP_SO_RCVBUF=y
Features
This is an implementation of this specification for ESP-IDF.
PL::BlackBox
is a base class for a BlackBox device.
The descendant class should override PL::BlackBox::GetFirmwareInfo()
.
Configuration
PL::BlackBoxConfiguration
is a base class for configurations that can be saved, loaded and erased from NVS.
PL::BlackBoxConfigurationParameter
objects can be used to provide configuration parameter validation.
PL::BlackBox::AddConfiguration()
adds a device configuration. A number of Add methods add hardware interface and server configurations.
By default all added hardware interfaces and servers are enabled and their parameters are fixed.
To make parameters configurable PL::BlackBoxConfigurationParameter::SetValueValidator()
, PL::BlackBoxConfigurationParameter::SetValidValues()
or PL::BlackBoxConfigurationParameter::DisableValueValidation()
should be used.
PL::BlackBox::LoadAllConfigurations()
loads all configurations from NVS.
PL::BlackBox::SaveAllConfigurations()
saves all configurations to NVS.
PL::BlackBox::EraseAllConfigurations()
erases all configurations from NVS.
PL::BlackBox::ApplyHardwareInterfaceConfigurations()
and PL::BlackBox::ApplyServerConfigurations()
apply the correspondent configurations to the hardware interfaces and servers.
Modbus Server
PL::BlackBoxModbusServer
is a PL::ModbusServer
class extension that contains memory areas specified
in BlackBox Modbus description.
Thread safety
Class method thread safety is implemented by having the PL::Lockable
as a base class and creating the class object lock guard at the beginning of the methods.
Examples
API reference
- Types
- PL::BlackBox class
PL::BlackBox
BlackBox()
GetHardwareInfoNvsNamespaceName()
SetHardwareInfoNvsNamespaceName()
GetGeneralConfigurationNvsNamespaceName()
SetGeneralConfigurationNvsNamespaceName()
GetHardwareInfo()
GetFirmwareInfo()
GetDeviceName()
SetDeviceName()
Restart()
GetRestartedFlag()
ClearRestartedFlag()
AddConfiguration()
AddHardwareInterfaceConfiguration()
AddServerConfiguration()
GetAllConfigurations()
GetHardwareInterfaceConfigurations()
GetServerConfigurations()
LoadAllConfigurations()
SaveAllConfigurations()
EraseAllConfigurations()
ApplyHardwareInterfaceConfigurations()
ApplyServerConfigurations()
defaultHardwareInfoNvsNamespaceName
defaultGeneralConfigurationNvsNamespaceName
hardwareInfoNameNvsKey
hardwareInfoMajorVersionNvsKey
hardwareInfoMinorVersionNvsKey
hardwareInfoPatchVersionNvsKey
hardwareInfoUidNvsKey
generalConfigurationDeviceNameNvsKey
- PL::BlackBoxConfiguration class
- PL::BlackBoxConfigurationParameter class
- PL::BlackBoxHardwareInterfaceConfiguration class
- PL::BlackBoxUartConfiguration class
- PL::BlackBoxNetworkInterfaceConfiguration class
PL::BlackBoxNetworkInterfaceConfiguration
BlackBoxNetworkInterfaceConfiguration()
Load()
Save()
Apply()
GetHardwareInterface()
Lock()
Unlock()
Erase()
ipV4Address
ipV4Netmask
ipV4Gateway
ipV6GlobalAddress
ipV4DhcpClientEnabled
ipV6DhcpClientEnabled
enabled
ipV4AddressNvsKey
ipV4NetmaskNvsKey
ipV4GatewayNvsKey
ipV6GlobalAddressNvsKey
ipV4DhcpClientEnabledNvsKey
ipV6DhcpClientEnabledNvsKey
enabledNvsKey
- PL::BlackBoxEthernetConfiguration class
PL::BlackBoxEthernetConfiguration
BlackBoxEthernetConfiguration()
Load()
Save()
Apply()
GetHardwareInterface()
Lock()
Unlock()
Erase()
ipV4Address
ipV4Netmask
ipV4Gateway
ipV6GlobalAddress
ipV4DhcpClientEnabled
ipV6DhcpClientEnabled
enabled
ipV4AddressNvsKey
ipV4NetmaskNvsKey
ipV4GatewayNvsKey
ipV6GlobalAddressNvsKey
ipV4DhcpClientEnabledNvsKey
ipV6DhcpClientEnabledNvsKey
enabledNvsKey
- PL::BlackBoxWiFiStationConfiguration class
PL::BlackBoxWiFiStationConfiguration
BlackBoxWiFiStationConfiguration()
Load()
Save()
Apply()
GetHardwareInterface()
Lock()
Unlock()
Erase()
ssid
password
ipV4Address
ipV4Netmask
ipV4Gateway
ipV6GlobalAddress
ipV4DhcpClientEnabled
ipV6DhcpClientEnabled
enabled
ssidNvsKey
passwordNvsKey
ipV4AddressNvsKey
ipV4NetmaskNvsKey
ipV4GatewayNvsKey
ipV6GlobalAddressNvsKey
ipV4DhcpClientEnabledNvsKey
ipV6DhcpClientEnabledNvsKey
enabledNvsKey
- PL::BlackBoxUsbDeviceCdcConfiguration class
- PL::BlackBoxServerConfiguration class
- PL::BlackBoxStreamServerConfiguration class
- PL::BlackBoxNetworkInterfaceConfiguration class
PL::BlackBoxNetworkInterfaceConfiguration
BlackBoxNetworkInterfaceConfiguration()
Load()
Save()
Apply()
GetHardwareInterface()
Lock()
Unlock()
Erase()
ipV4Address
ipV4Netmask
ipV4Gateway
ipV6GlobalAddress
ipV4DhcpClientEnabled
ipV6DhcpClientEnabled
enabled
ipV4AddressNvsKey
ipV4NetmaskNvsKey
ipV4GatewayNvsKey
ipV6GlobalAddressNvsKey
ipV4DhcpClientEnabledNvsKey
ipV6DhcpClientEnabledNvsKey
enabledNvsKey
- PL::BlackBoxModbusServerConfiguration class
- PL::BlackBoxHttpServerConfiguration class
- PL::BlackBoxMdnsServerConfiguration class
- PL::BlackBoxModbusServer class
PL::BlackBoxModbusServer
BlackBoxModbusServer()
BlackBoxModbusServer()
BlackBoxModbusServer()
BlackBoxModbusServer()
Lock()
Unlock()
Enable()
Disable()
AddMemoryArea()
AddMemoryArea()
IsEnabled()
GetStationAddress()
SetStationAddress()
SetTaskParameters()
GetBaseServer()
GetProtocol()
SetProtocol()
GetReadTimeout()
SetReadTimeout()
GetDelayAfterRead()
SetDelayAfterRead()
GetName()
SetName()
enabledEvent
disabledEvent
registerMemoryAreaSize
coilMemoryAreaSize
generalConfigurationMemoryAddress
hardwareInterfaceConfigurationMemoryAddress
serverConfigurationMemoryAddress
plbbSignature
memoryMapVersion
maxNameSize
maxWiFiSsidSize
maxWiFiPasswordSize
defaultName
defaultReadTimeout
defaultBufferSize
defaultNetworkProtocol
defaultNetworkStationAddress
maxNumberOfModbusBitsToRead
maxNumberOfModbusBitsToWrite
maxNumberOfModbusRegistersToRead
maxNumberOfModbusRegistersToWrite
ReadRtuData()
HandleRequest()
WriteExceptionFrame()
ReadFrame()
WriteFrame()
GetDataBuffer()