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::BlackBoxBlackBox()GetHardwareInfoNvsNamespaceName()SetHardwareInfoNvsNamespaceName()GetGeneralConfigurationNvsNamespaceName()SetGeneralConfigurationNvsNamespaceName()GetHardwareInfo()GetFirmwareInfo()GetDeviceName()SetDeviceName()Restart()GetRestartedFlag()ClearRestartedFlag()AddConfiguration()AddHardwareInterfaceConfiguration()AddServerConfiguration()GetAllConfigurations()GetHardwareInterfaceConfigurations()GetServerConfigurations()LoadAllConfigurations()SaveAllConfigurations()EraseAllConfigurations()ApplyHardwareInterfaceConfigurations()ApplyServerConfigurations()defaultHardwareInfoNvsNamespaceNamedefaultGeneralConfigurationNvsNamespaceNamehardwareInfoNameNvsKeyhardwareInfoMajorVersionNvsKeyhardwareInfoMinorVersionNvsKeyhardwareInfoPatchVersionNvsKeyhardwareInfoUidNvsKeygeneralConfigurationDeviceNameNvsKey
 - PL::BlackBoxConfiguration class
 - PL::BlackBoxConfigurationParameter class
 - PL::BlackBoxHardwareInterfaceConfiguration class
 - PL::BlackBoxUartConfiguration class
 - PL::BlackBoxNetworkInterfaceConfiguration class
PL::BlackBoxNetworkInterfaceConfigurationBlackBoxNetworkInterfaceConfiguration()Load()Save()Apply()GetHardwareInterface()Lock()Unlock()Erase()ipV4AddressipV4NetmaskipV4GatewayipV6GlobalAddressipV4DhcpClientEnabledipV6DhcpClientEnabledenabledipV4AddressNvsKeyipV4NetmaskNvsKeyipV4GatewayNvsKeyipV6GlobalAddressNvsKeyipV4DhcpClientEnabledNvsKeyipV6DhcpClientEnabledNvsKeyenabledNvsKey
 - PL::BlackBoxEthernetConfiguration class
PL::BlackBoxEthernetConfigurationBlackBoxEthernetConfiguration()Load()Save()Apply()GetHardwareInterface()Lock()Unlock()Erase()ipV4AddressipV4NetmaskipV4GatewayipV6GlobalAddressipV4DhcpClientEnabledipV6DhcpClientEnabledenabledipV4AddressNvsKeyipV4NetmaskNvsKeyipV4GatewayNvsKeyipV6GlobalAddressNvsKeyipV4DhcpClientEnabledNvsKeyipV6DhcpClientEnabledNvsKeyenabledNvsKey
 - PL::BlackBoxWiFiStationConfiguration class
PL::BlackBoxWiFiStationConfigurationBlackBoxWiFiStationConfiguration()Load()Save()Apply()GetHardwareInterface()Lock()Unlock()Erase()ssidpasswordipV4AddressipV4NetmaskipV4GatewayipV6GlobalAddressipV4DhcpClientEnabledipV6DhcpClientEnabledenabledssidNvsKeypasswordNvsKeyipV4AddressNvsKeyipV4NetmaskNvsKeyipV4GatewayNvsKeyipV6GlobalAddressNvsKeyipV4DhcpClientEnabledNvsKeyipV6DhcpClientEnabledNvsKeyenabledNvsKey
 - PL::BlackBoxUsbDeviceCdcConfiguration class
 - PL::BlackBoxServerConfiguration class
 - PL::BlackBoxStreamServerConfiguration class
 - PL::BlackBoxNetworkInterfaceConfiguration class
PL::BlackBoxNetworkInterfaceConfigurationBlackBoxNetworkInterfaceConfiguration()Load()Save()Apply()GetHardwareInterface()Lock()Unlock()Erase()ipV4AddressipV4NetmaskipV4GatewayipV6GlobalAddressipV4DhcpClientEnabledipV6DhcpClientEnabledenabledipV4AddressNvsKeyipV4NetmaskNvsKeyipV4GatewayNvsKeyipV6GlobalAddressNvsKeyipV4DhcpClientEnabledNvsKeyipV6DhcpClientEnabledNvsKeyenabledNvsKey
 - PL::BlackBoxModbusServerConfiguration class
 - PL::BlackBoxHttpServerConfiguration class
 - PL::BlackBoxMdnsServerConfiguration class
 - PL::BlackBoxModbusServer class
PL::BlackBoxModbusServerBlackBoxModbusServer()BlackBoxModbusServer()BlackBoxModbusServer()BlackBoxModbusServer()Lock()Unlock()Enable()Disable()AddMemoryArea()AddMemoryArea()IsEnabled()GetStationAddress()SetStationAddress()SetTaskParameters()GetBaseServer()GetProtocol()SetProtocol()GetReadTimeout()SetReadTimeout()GetDelayAfterRead()SetDelayAfterRead()GetName()SetName()enabledEventdisabledEventregisterMemoryAreaSizecoilMemoryAreaSizegeneralConfigurationMemoryAddresshardwareInterfaceConfigurationMemoryAddressserverConfigurationMemoryAddressplbbSignaturememoryMapVersionmaxNameSizemaxWiFiSsidSizemaxWiFiPasswordSizedefaultNamedefaultReadTimeoutdefaultBufferSizedefaultNetworkProtocoldefaultNetworkStationAddressmaxNumberOfModbusBitsToReadmaxNumberOfModbusBitsToWritemaxNumberOfModbusRegistersToReadmaxNumberOfModbusRegistersToWriteReadRtuData()HandleRequest()WriteExceptionFrame()ReadFrame()WriteFrame()GetDataBuffer()