AlteriomPainlessMesh v2.1.1
Easy ESP32/ESP8266 mesh networking with Alteriom IoT extensions
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
painlessmesh::gateway::GatewayAckPackage Class Reference

Gateway Acknowledgment Package for delivery confirmations. More...

#include <gateway.hpp>

Inheritance diagram for painlessmesh::gateway::GatewayAckPackage:
Inheritance graph
[legend]
Collaboration diagram for painlessmesh::gateway::GatewayAckPackage:
Collaboration graph
[legend]

Public Member Functions

 GatewayAckPackage ()
 Default constructor.
 
 GatewayAckPackage (JsonObject jsonObj)
 Construct from JSON object.
 
JsonObject addTo (JsonObject &&jsonObj) const
 Serialize to JSON object.
 
size_t jsonObjectSize () const
 Calculate JSON object size for ArduinoJson v6.
 
- Public Member Functions inherited from painlessmesh::plugin::SinglePackage
 SinglePackage (int type)
 
 SinglePackage (JsonObject jsonObj)
 
JsonObject addTo (JsonObject &&jsonObj) const
 
- Public Member Functions inherited from painlessmesh::protocol::PackageInterface
virtual ~PackageInterface ()=default
 

Public Attributes

uint32_t messageId = 0
 Original message ID being acknowledged.
 
uint32_t originNode = 0
 Original sender node ID.
 
bool success = false
 Delivery success status.
 
uint16_t httpStatus = 0
 HTTP response code (if applicable)
 
TSTRING error = ""
 Error message (if failed)
 
uint32_t timestamp = 0
 Acknowledgment timestamp.
 
TSTRING response = ""
 The start of the response body, summarized to one line.
 
int8_t retryable = -1
 Whether the origin node may resend the identical request.
 
uint32_t retryAfterMs = 0
 How long the server asked to wait before a retry, in milliseconds.
 
- Public Attributes inherited from painlessmesh::plugin::SinglePackage
uint32_t from = 0
 
uint32_t dest = 0
 
router::Type routing = router::SINGLE
 
int type = 0
 
int noJsonFields = 4
 

Static Public Attributes

static constexpr int numPackageFields = 9
 Number of additional JSON fields in this package.
 

Detailed Description

Gateway Acknowledgment Package for delivery confirmations.

This package is sent from the gateway back to the origin node to confirm delivery status of a GatewayDataPackage. It provides feedback on whether the data was successfully delivered to the Internet destination.

MEMORY FOOTPRINT

The GatewayAckPackage structure has an estimated memory footprint of:

For ESP8266 with ~80KB RAM, this represents <0.3% of available memory. For ESP32 with ~320KB RAM, this represents <0.1% of available memory.

Example usage:

// Gateway responding to a successful delivery
ack.messageId = originalPackage.messageId;
ack.originNode = originalPackage.originNode;
ack.dest = originalPackage.originNode; // Route back to origin
ack.from = mesh.getNodeId();
ack.success = true;
ack.httpStatus = 200;
ack.timestamp = mesh.getNodeTime();
mesh.sendPackage(&ack);
// Gateway responding to a failed delivery
ack.messageId = originalPackage.messageId;
ack.originNode = originalPackage.originNode;
ack.dest = originalPackage.originNode;
ack.from = mesh.getNodeId();
ack.success = false;
ack.httpStatus = 503;
ack.error = "Service unavailable";
ack.timestamp = mesh.getNodeTime();
mesh.sendPackage(&ack);
Gateway Acknowledgment Package for delivery confirmations.
Definition gateway.hpp:1651
bool success
Delivery success status.
Definition gateway.hpp:1675
uint32_t messageId
Original message ID being acknowledged.
Definition gateway.hpp:1659
uint32_t timestamp
Acknowledgment timestamp.
Definition gateway.hpp:1700
uint16_t httpStatus
HTTP response code (if applicable)
Definition gateway.hpp:1684
uint32_t originNode
Original sender node ID.
Definition gateway.hpp:1667
TSTRING error
Error message (if failed)
Definition gateway.hpp:1692
uint32_t dest
Definition plugin.hpp:46
uint32_t from
Definition plugin.hpp:45

Type ID: 621 (GATEWAY_ACK) Base class: SinglePackage (routed back to origin node)

Constructor & Destructor Documentation

◆ GatewayAckPackage() [1/2]

painlessmesh::gateway::GatewayAckPackage::GatewayAckPackage ( )
inline

Default constructor.

Creates a GatewayAckPackage with type ID 621 (GATEWAY_ACK).

◆ GatewayAckPackage() [2/2]

painlessmesh::gateway::GatewayAckPackage::GatewayAckPackage ( JsonObject  jsonObj)
inline

Construct from JSON object.

Deserializes a GatewayAckPackage from a JSON object. Compatible with ArduinoJson v6 and v7.

Parameters
jsonObjJSON object containing package data

Member Function Documentation

◆ addTo()

JsonObject painlessmesh::gateway::GatewayAckPackage::addTo ( JsonObject &&  jsonObj) const
inlinevirtual

Serialize to JSON object.

Adds all package fields to the provided JSON object.

Parameters
jsonObjJSON object to add fields to
Returns
The modified JSON object

Implements painlessmesh::protocol::PackageInterface.

◆ jsonObjectSize()

size_t painlessmesh::gateway::GatewayAckPackage::jsonObjectSize ( ) const
inlinevirtual

Calculate JSON object size for ArduinoJson v6.

Used for buffer allocation when serializing.

Returns
Estimated size in bytes

Implements painlessmesh::protocol::PackageInterface.

Member Data Documentation

◆ error

TSTRING painlessmesh::gateway::GatewayAckPackage::error = ""

Error message (if failed)

A human-readable error message describing why delivery failed. Empty string if success is true.

◆ httpStatus

uint16_t painlessmesh::gateway::GatewayAckPackage::httpStatus = 0

HTTP response code (if applicable)

The HTTP status code received from the Internet destination. Examples: 200 (OK), 404 (Not Found), 500 (Server Error). Set to 0 if not applicable (e.g., connection failure).

◆ messageId

uint32_t painlessmesh::gateway::GatewayAckPackage::messageId = 0

Original message ID being acknowledged.

The messageId from the GatewayDataPackage that this acknowledgment corresponds to. Used for correlation at the origin node.

◆ numPackageFields

constexpr int painlessmesh::gateway::GatewayAckPackage::numPackageFields = 9
staticconstexpr

Number of additional JSON fields in this package.

Used for jsonObjectSize() calculation in ArduinoJson v6. Count: msgId, origin, success, http, err, ts, resp, retry, retryAfter = 9

◆ originNode

uint32_t painlessmesh::gateway::GatewayAckPackage::originNode = 0

Original sender node ID.

The node ID that originally sent the GatewayDataPackage. Used for routing and correlation.

◆ response

TSTRING painlessmesh::gateway::GatewayAckPackage::response = ""

The start of the response body, summarized to one line.

Carried on success as well as failure, because whether a reply means what the application wanted is the application's decision, not the library's. Empty when no body was read. JSON key "resp", omitted when empty.

◆ retryable

int8_t painlessmesh::gateway::GatewayAckPackage::retryable = -1

Whether the origin node may resend the identical request.

1 when the request cannot have reached the server or the server asked to be retried, 0 when a resend could deliver it twice. -1 when the gateway did not say – one that predates the field – and the origin node falls back to its own reading of the status. JSON key "retry", omitted at -1.

◆ retryAfterMs

uint32_t painlessmesh::gateway::GatewayAckPackage::retryAfterMs = 0

How long the server asked to wait before a retry, in milliseconds.

From a Retry-After header on a 429 or 503. JSON key "retryAfter", omitted when 0.

◆ success

bool painlessmesh::gateway::GatewayAckPackage::success = false

Delivery success status.

True if the message was successfully delivered to the Internet destination, false otherwise.

◆ timestamp

uint32_t painlessmesh::gateway::GatewayAckPackage::timestamp = 0

Acknowledgment timestamp.

Mesh time when the acknowledgment was created. Can be used to calculate round-trip time.


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