3.1 Authorize
The Authorize message in OCPP 1.6J verifies a user's identity before a charging session begins, ensuring only authorized users can charge. Key uses include starting a session, offline authorization with a local list and remote session initiation. It can re-verify users mid-session or validate credentials for reservations and maintenance. This message also helps handle invalid credentials, denying access to unauthorized users.
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
SendAuthorizeRequest |
This function sends the authorization request packet. It forms the OCPP packet and sends it to the server. It also handles error checking for the WebSocket connection. |
void |
return AUTHORIZE_FAILED return AUTHORIZE_SUCCESS |
Example:
SetAuthorizeIdTag(userId);
if (AUTHORIZE_SUCCESS != SendAuthorizeRequest())
{
LogDebug("APP_LOG", "SendAuthorizeRequest Failed \n\r");
}
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
SetAuthorizeIdTag |
This function sets the authorization ID tag used in the request. |
(char *idToken) |
void |
Example:
SetAuthorizeIdTag(userId);
(void)SetAuthorizeStatus(AUTHORIZE_ACCEPTED);
if (GetDriverpluginStatus())
{
UpdateAndSendStartTransaction(userId, 0, connectorId, 0);
}
else
{
LogDebug("APP_LOG", "Driver Plugin Status not received\n\r");
}
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
GetAuthorizeParms |
This function fetches the authorization parameters and stores them in the provided structure. |
Struct AUTHORIZERESPONSEVAL_T |
void |
Example:
case AUTHORIZE_ACCEPTED:
{
AUTHORIZERESPONSEVAL_T parm;
static char IdTag[CISTRING_20TYPE_LENGTH]={NULL_VALUE};
char chargePointStatus[CHARGE_POINT_STATUS_SIZE];
LogDebug("APP_LOG", " Authorize Response is accepted\n\r");
GetAuthorizeIdTag(IdTag);
GetAuthorizeParms(&parm);
GetChargePointStatus(chargePointStatus);
UpdateAuthorizationCache(IdTag, parm); /* Update authorization cache */
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
ProcessAuthorizeResponse |
This function processes the authorization response received from the server. It validates the response and updates the application with the authorization result. |
(ocpp_frame *rx) |
return OCPP_PROCESS_RECEIVED_RESPONSE_OK return OCPP_PROCESS_RECEIVED_RESPONSE_NOT_OK |
Example:
if (ProcessAuthorizeresponse(received) == OCPP_PROCESS_RECEIVED_RESPONSE_OK)
{
OCPP_log_message(LOG_INFO, LOG_SENDING, "This response is for authorize\n\r");
}
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
GetAuthorizeIdTag |
Function to read Authorized IdTag |
char *idToken |
void |
Example:
case AUTHORIZE_ACCEPTED:
{
AUTHORIZERESPONSEVAL_T parm;
static char IdTag[CISTRING_20TYPE_LENGTH]={NULL_VALUE};
char chargePointStatus[CHARGE_POINT_STATUS_SIZE];
LogDebug("APP_LOG", " Authorize Response is accepted\n\r");
GetAuthorizeIdTag(IdTag);
GetAuthorizeParms(&parm);
GetChargePointStatus(chargePointStatus);
UpdateAuthorizationCache(IdTag, parm); /* Update authorization cache */
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
SetAuthorizeStatus |
Sets the status of the Authorized IdTag. |
AUTHORIZATION_STATUS_T statusENUM |
bool |
Example:
if(localAuthStatus == LOCALAUTHORIZATION_SUCCESS)
{
SetAuthorizeIdTag(idTag); /* IdTag updated in Authorization structure but not required to send it to central system for authorization */
(void)SetAuthorizeStatus(AUTHORIZE_ACCEPTED);
if(GetDriverpluginStatus() == true)
{
UpdateAndSendStartTransaction(idTag, 0, connectorId, 0);
}
}
| API Syntax | Description | Input Params | Return Value |
|---|---|---|---|
|
GetAuthorizeStatusEnumTypeChar |
Returns the string of the authorized status of the IdTag. |
AUTHORIZATION_STATUS_T authStatus |
char |
Example:
if(strncmp(stopTransactionOnInvalidId, "false", strlen(stopTransactionOnInvalidId)) == 0)
{
for (int enumIndex = 0; enumIndex < STATUS_ENUM_COUNT; enumIndex++)
{
if (strncmp(GetAuthorizeStatusEnumTypeChar(enumIndex), status, STATUS_COMPARE_LENGTH) == 0)
{
UpdateAndSendStatusNotification(SUSPENDEDEVSE, NOERROR, connectorId);
break;
}
}
}
| Struct/Enum | Description | Constants/Members |
|---|---|---|
|
AUTHORIZEERROR_T |
Enum: error codes for the authorization process |
AUTHORIZE_SUCCESS AUTHORIZE_FAILED |
|
AUTHORIZERESPONSEVAL_T |
Structure to hold authorization response values |
idToken idTag IDTAG_INFO_T idTagInfo AUTHORIZATION_STATUS_T statusENUM |
|
AUTHORIZATION_STATUS_T |
Enum: status codes for authorization response |
AUTHORIZE_ACCEPTED AUTHORIZE_BLOCKED AUTHORIZE_EXPIRED AUTHORIZE_INVALID AUTHORIZE_CONCURRENT_TX AUTHORIZE_MISSING_PACKET_FIELD |
|
IDTAG_INFO_T |
This structure is used to store details about an ID tag, including its expiry date, associated parent ID tag and current status. It is designed to support systems that manage identification tags and their associated data. |
char expiryDate[CISTRING_50TYPE_LENGTH] idToken parentIdTag AUTHORIZATION_STATUS_T status |
