supla-device
Loading...
Searching...
No Matches
Supla::Sensor::MultiDsHandlerBase Class Referenceabstract
Inheritance diagram for Supla::Sensor::MultiDsHandlerBase:
Collaboration diagram for Supla::Sensor::MultiDsHandlerBase:

Public Member Functions

 MultiDsHandlerBase (SuplaDeviceClass *sdc, uint8_t pin)
void onRegistered (Supla::Protocol::SuplaSrpc *suplaSrpc) override
 Method called each time when device successfully registers to Supla server.
void iterateAlways () override
 Method called on each SuplaDevice iteration.
bool iterateConnected () override
 Method called on each SuplaDevice iteration when device is connected and registered to Supla server or other protocol.
void onLoadConfig (SuplaDeviceClass *sdc) override
 First method called on element in SuplaDevice.begin().
void onInit () override
 Third method called on element in SuplaDevice.begin().
bool startPairing (Supla::Protocol::SuplaSrpc *srpc, TCalCfg_SubdevicePairingResult *result) override
bool onChannelConflictReport (uint8_t *channelReport, uint8_t channelReportSize, bool hasConflictInvalidType, bool hasConflictChannelMissingOnServer, bool hasConflictChannelMissingOnDevice) override
virtual double getTemperature (const uint8_t *address)=0
void setMaxDeviceCount (uint8_t count)
 Sets the maximum number of DS18B20 devices handled by this instance.
void setChannelNumberOffset (uint8_t offset)
 Sets the offset for channel number.
void setUseSubDevices (bool useSubDevices)
 Sets the channel number offset for paired thermometers.
void setPairingTimeout (uint8_t timeout)
 Sets the timeout for the pairing process.
void disableSensorsChannelState ()
 Disables channel state in all thermometers managed by this handler.
void searchForFirstSensorDuringInitialization ()
 Sets automatic single-sensor initialization mode.
Public Member Functions inherited from Supla::Element
Element * next ()
 Returns next Element from the list.
virtual void purgeConfig ()
 Removes all configration data related to the element from Storage::Config.
virtual void onLoadState ()
 Second method called on element in SuplaDevice.begin().
virtual void onSaveState ()
 Method called periodically during SuplaDevice iteration.
virtual bool isStateStorageMigrationNeeded () const
 Method called after onInit() to check if state storage migration is needed.
virtual bool iterateConnected (void *ptr)
 deprecated
virtual void onTimer ()
 Method called on timer interupt.
virtual void onFastTimer ()
 Method called on fast timer interupt.
virtual void onSoftReset ()
 Method called when device soft restart is triggered.
virtual void onDeviceConfigChange (uint64_t fieldBit)
 Method called when device config is changed.
virtual int32_t handleNewValueFromServer (TSD_SuplaChannelNewValue *newValue)
 Handles "new value" request from server.
virtual void fillSuplaChannelNewValue (TSD_SuplaChannelNewValue *value)
 Fills TSD_SuplaChannelNewValue based on current state.
virtual void handleGetChannelState (TDSC_ChannelState *channelState)
 Handles "get channel state (i)" request from server.
virtual int handleCalcfgFromServer (TSD_DeviceCalCfgRequest *request)
 Handles CALCFG requests from server.
virtual uint8_t handleChannelConfig (TSD_ChannelConfig *newChannelConfig, bool local=false)
 Handles "set channel config" request from server.
virtual uint8_t handleWeeklySchedule (TSD_ChannelConfig *newWeeklySchedule, bool altSchedule=false, bool local=false)
 Handles "set channel config" with "weekly schedule" type request from server.
virtual void handleSetChannelConfigResult (TSDS_SetChannelConfigResult *result)
 Handles "set channel config" reply from server.
virtual void handleChannelConfigFinished ()
 Handles "channel config finished" message from server.
int getChannelNumber () const
 Returns channel number.
int getSecondaryChannelNumber () const
 Returns secondary channel number.
virtual bool isOwnerOfSubDeviceId (int subDeviceId) const
 Returns true if element is owner of subDeviceId.
virtual const ChannelgetChannel () const
 Returns pointer to main channel.
virtual ChannelgetChannel ()
virtual const ChannelgetSecondaryChannel () const
 Returns pointer to secondary channel.
virtual ChannelgetSecondaryChannel ()
virtual void generateKey (char *output, const char *key) const
 Generates key used for Config.
Element & disableChannelState ()
 Disables channel state (i) function.
bool isChannelStateEnabled () const
 Returns true if channel state (i) function is enabled.
virtual bool isAnyUpdatePending () const
 Returns true if any update is pending.
void setInitialCaption (const char *caption, bool secondaryChannel=false)
 Sets initial caption.
bool setDefaultFunction (uint32_t defaultFunction)
 Sets default channel's function.
bool setFunction (uint32_t newFunction)
 Sets channel's function.
virtual void onFunctionChange (uint32_t currentFunction, uint32_t newFunction)
 Called when channel function changes.

Protected Member Functions

Supla::Sensor::MultiDsSensoraddDevice (DeviceAddress deviceAddress, int channelNumber=-1, int subDeviceId=-1)
virtual int refreshSensorsCount ()=0
virtual void requestTemperatures ()=0
virtual bool getSensorAddress (uint8_t *address, int index)=0

Protected Attributes

SuplaDeviceClasssdc = nullptr
MultiDsSensorsensors [MULTI_DS_MAX_DEVICES_COUNT] = {}
Protected Attributes inherited from Supla::Element
Element * nextPtr = nullptr

Additional Inherited Members

Static Public Member Functions inherited from Supla::Element
static Element * begin ()
 Returns first Element (based on creation order).
static Element * last ()
 Returns last Element (based on creation order).
static Element * getElementByChannelNumber (int channelNumber)
 Returns Element by channel number.
static Element * getOwnerOfSubDeviceId (int subDeviceId)
 Returns Element which owns given subDeviceId.
static bool IsAnyUpdatePending ()
 Checks if any element has pending update for remote server.
static void NotifyElementsAboutConfigChange (uint64_t fieldBit)
 Notifies all elements about device config change.
static bool IsInvalidPtrSet ()
 When "invalid pointer" is set, previously obtained Element pointer may be invalid.
static void ClearInvalidPtr ()
 Clears "invalid pointer" flag.
Static Protected Attributes inherited from Supla::Element
static Element * firstPtr = nullptr
static bool invalidatePtr = false

Member Function Documentation

◆ iterateAlways()

void MultiDsHandlerBase::iterateAlways ( )
overridevirtual

Method called on each SuplaDevice iteration.

It should provide all actions that have to be executed periodically regardless of network state.

Reimplemented from Supla::Element.

◆ iterateConnected()

bool MultiDsHandlerBase::iterateConnected ( )
overridevirtual

Method called on each SuplaDevice iteration when device is connected and registered to Supla server or other protocol.

Returns
true when element didn't communicate with server and next element should be iterated instead. false otherwise.

Reimplemented from Supla::Element.

◆ onChannelConflictReport()

bool MultiDsHandlerBase::onChannelConflictReport ( uint8_t * channelReport,
uint8_t channelReportSize,
bool hasConflictInvalidType,
bool hasConflictChannelMissingOnServer,
bool hasConflictChannelMissingOnDevice )
overridevirtual

◆ onInit()

void MultiDsHandlerBase::onInit ( )
overridevirtual

Third method called on element in SuplaDevice.begin().

Method called during SuplaDevice initialization. I.e. load initial state, initialize pins etc.

Reimplemented from Supla::Element.

◆ onLoadConfig()

void MultiDsHandlerBase::onLoadConfig ( SuplaDeviceClass * sdc)
overridevirtual

First method called on element in SuplaDevice.begin().

Called only if Config Storage class is configured. Element should read its configration in this method.

Parameters
sdc

Reimplemented from Supla::Element.

◆ onRegistered()

void MultiDsHandlerBase::onRegistered ( Supla::Protocol::SuplaSrpc * suplaSrpc)
overridevirtual

Method called each time when device successfully registers to Supla server.

Parameters
suplaSrpc

Reimplemented from Supla::Element.

◆ searchForFirstSensorDuringInitialization()

void MultiDsHandlerBase::searchForFirstSensorDuringInitialization ( )

Sets automatic single-sensor initialization mode.

When this flag is enabled, the device will attempt to detect and register one DS18B20 sensor during the initialization phase (onInit), but only if no sensors were restored from configuration inside onLoadConfig().

This mechanism is intended for simple setups with a single thermometer, where automatic pairing at startup is desired without requiring explicit user action.

If at least one sensor is successfully loaded from configuration, no additional scan will be performed.

By default, this flag is not set.

◆ setChannelNumberOffset()

void MultiDsHandlerBase::setChannelNumberOffset ( uint8_t offset)

Sets the offset for channel number.

Normally paired thermometers will get next free channel number. If you plan thermometeres on specific position in the device, use this method to define which first channel number should be assigned.

If you set the offset you need to garantee, that the amount of channel defined in 'maxDeviceCount' will be available just after offset

Default value is -1 so no offset is used

◆ setMaxDeviceCount()

void MultiDsHandlerBase::setMaxDeviceCount ( uint8_t count)

Sets the maximum number of DS18B20 devices handled by this instance.

The default and absolute maximum is 10 devices. The value can only be reduced from the default; setting a higher value has no effect.

If the limit is exceeded, pairing of additional devices will fail.

◆ setPairingTimeout()

void MultiDsHandlerBase::setPairingTimeout ( uint8_t timeout)

Sets the timeout for the pairing process.

The timeout defines how long the handler waits for DS18B20 devices to be detected and paired after the pairing procedure has started.

The default timeout is 5 seconds.

◆ setUseSubDevices()

void MultiDsHandlerBase::setUseSubDevices ( bool useSubDevices)

Sets the channel number offset for paired thermometers.

By default, newly paired thermometers are assigned the next available channel number. If you need thermometers to start at a specific channel position within the device, use this method to define the first channel number to be assigned.

When using an offset, you must ensure that at least 'maxDeviceCount' consecutive channel numbers are available starting from the specified offset.

The default value is -1, which means no offset is applied.

◆ startPairing()

bool MultiDsHandlerBase::startPairing ( Supla::Protocol::SuplaSrpc * srpc,
TCalCfg_SubdevicePairingResult * result )
overridevirtual

The documentation for this class was generated from the following files: