3.6 Heartbeat
The Heartbeat message in OCPP 1.6J is sent periodically by the charge point to the central system to confirm that it is still online and operational. The frequency is set during the BootNotification exchange. It ensures the central system can monitor the health of the charge point and detect any connectivity issues.
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
SendHeartbeatRequest |
Sends a heartbeat request to the server. Creates an OCPP frame for the request and sends it using “sendframe”. |
(void) |
HEARTBEATERROR_T |
Example:
case TRIGGER_MESSAGE_TYPE_HEARTBEAT:
SendHeartbeatRequest();
break;
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
GetSendHeartBeatVal |
Gets the current value of the SendHeartbeat flag. |
voids |
uint8_t |
Example:
case 'H': /*Heart Beat*/
{
uint32_t timeInterval;
LogDebug("APP_LOG", "Enter time in sec: ");
result = scanf("%d", (int *)&timeInterval);
if (result != 1)
{
LogDebug("APP_LOG", "Error reading timeInterval\n");
}
SetSendHeartBeatVal(1);
StartHeartBeatTimer(timeInterval);
/* Below code is used for testing purpose */
LogDebug("APP_LOG", "Do you want to stop the Heart Beat (y/n) : \n");
if(getchar() == 'y')
{
uint8_t heartBeatVal = GetSendHeartBeatVal();
LogDebug("APP_LOG", "HeartBeatVal is %d\n", heartBeatVal);
char currentTime[CISTRING_50TYPE_LENGTH];
GetHeartBeatCurrentTime(currentTime);
LogDebug("APP_LOG", "The Current Time is %s\n", currentTime);
StopHeartBeatTimer();
}
}
break;
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
SetSendHeartBeatVal |
Sets the value of the SendHeartbeat flag. |
uint8_t val |
void |
Example:
case 'H': /*Heart Beat*/
{
uint32_t timeInterval;
LogDebug("APP_LOG", "Enter time in sec: ");
result = scanf("%d", (int *)&timeInterval);
if (result != 1)
{
LogDebug("APP_LOG", "Error reading timeInterval\n");
}
SetSendHeartBeatVal(1);
StartHeartBeatTimer(timeInterval);
/* Below code is used for testing purpose */
LogDebug("APP_LOG", "Do you want to stop the Heart Beat (y/n) : \n");
if(getchar() == 'y')
{
uint8_t heartBeatVal = GetSendHeartBeatVal();
LogDebug("APP_LOG", "HeartBeatVal is %d\n", heartBeatVal);
char currentTime[CISTRING_50TYPE_LENGTH];
GetHeartBeatCurrentTime(currentTime);
LogDebug("APP_LOG", "The Current Time is %s\n", currentTime);
StopHeartBeatTimer();
}
}
break;
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
GetHeartBeatCurrentTime |
Gets the parameters from the heartbeat response. |
HEARTBEATRESPONSEVAL_T *parm |
void |
Example:
case 'H': /*Heart Beat*/
{
uint32_t timeInterval;
LogDebug("APP_LOG", "Enter time in sec: ");
result = scanf("%d", (int *)&timeInterval);
if (result != 1)
{
LogDebug("APP_LOG", "Error reading timeInterval\n");
}
SetSendHeartBeatVal(1);
StartHeartBeatTimer(timeInterval);
/* Below code is used for testing purpose */
LogDebug("APP_LOG", "Do you want to stop the Heart Beat (y/n) : \n");
if(getchar() == 'y')
{
uint8_t heartBeatVal = GetSendHeartBeatVal();
LogDebug("APP_LOG", "HeartBeatVal is %d\n", heartBeatVal);
char currentTime[CISTRING_50TYPE_LENGTH];
GetHeartBeatCurrentTime(currentTime);
LogDebug("APP_LOG", "The Current Time is %s\n", currentTime);
StopHeartBeatTimer();
}
}
break;
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
StopHeartBeatTimer |
Stops the heartbeat timer. |
void |
void |
Example:
case 'H': /*Heart Beat*/
{
uint32_t timeInterval;
LogDebug("APP_LOG", "Enter time in sec: ");
result = scanf("%d", (int *)&timeInterval);
if (result != 1)
{
LogDebug("APP_LOG", "Error reading timeInterval\n");
}
SetSendHeartBeatVal(1);
StartHeartBeatTimer(timeInterval);
/* Below code is used for testing purpose */
LogDebug("APP_LOG", "Do you want to stop the Heart Beat (y/n) : \n");
if(getchar() == 'y')
{
uint8_t heartBeatVal = GetSendHeartBeatVal();
LogDebug("APP_LOG", "HeartBeatVal is %d\n", heartBeatVal);
char currentTime[CISTRING_50TYPE_LENGTH];
GetHeartBeatCurrentTime(currentTime);
LogDebug("APP_LOG", "The Current Time is %s\n", currentTime);
StopHeartBeatTimer();
}
}
break;
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
StartHeartBeatTimer |
Starts the heartbeat timer with a specified interval. |
unsigned int inverval |
void |
Example:
case 'H': /*Heart Beat*/
{
uint32_t timeInterval;
LogDebug("APP_LOG", "Enter time in sec: ");
result = scanf("%d", (int *)&timeInterval);
if (result != 1)
{
LogDebug("APP_LOG", "Error reading timeInterval\n");
}
SetSendHeartBeatVal(1);
StartHeartBeatTimer(timeInterval);
/* ocpp_send_HeartBeet(); */
}
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
OCPPHeartbeatResetGlobals |
Function to reset global variables for Heartbeat. |
(void) |
void |
Example:
OCPPWebSocketResetGlobals();
OCPPProcessResetGlobals();
OCPPConfigManagerResetGlobals();
OCPPCleanUpGlobalProfiles();
OCPPHeartbeatResetGlobals();
OCPPLoggingResetGlobals();
| Syntax | Description | Constants/Members |
|---|---|---|
|
HEARTBEATERROR_T |
Enumeration for heartbeat error codes |
HEARTBEAT_SUCCESS HEARTBEAT_FAILED HEARTBEAT_response_SUCCESS HEARTBEAT_response_FAILED |
|
HEARTBEATRESPONSEVAL_T |
Structure to hold heartbeat response values |
char currentTime[] |
