Functions | |
| const cy_p64_cJSON * | cy_p64_find_json_item (const char *path, const cy_p64_cJSON *json) |
| Finds items by name in the whole JSON. More... | |
| cy_p64_error_codes_t | cy_p64_decode_payload_data (const char *jwt_packet, cy_p64_cJSON **json_packet) |
| Decodes JWT payload data from the input jwt_packet to JSON object and returns pointer to this object: json_packet. More... | |
| cy_p64_error_codes_t | cy_p64_json_get_boolean (const cy_p64_cJSON *json, bool *value) |
| Gets the BOOLEAN value of a JSON object. More... | |
| cy_p64_error_codes_t | cy_p64_json_get_uint32 (const cy_p64_cJSON *json, uint32_t *value) |
| Gets the unsigned INTEGER value of a JSON object. More... | |
| cy_p64_error_codes_t | cy_p64_json_get_string (const cy_p64_cJSON *json, const char **value) |
| Gets the unsigned STRING value of a JSON object. More... | |
| cy_p64_error_codes_t | cy_p64_json_get_array_uint8 (const cy_p64_cJSON *json, uint8_t *buf, uint32_t size, uint32_t *olen) |
| Gets the ARRAY value, in uint8, of a JSON object. More... | |
| cy_p64_error_codes_t | cy_p64_policy_get_image_record (const cy_p64_cJSON *json, uint32_t image_id, const cy_p64_cJSON **json_image) |
| Gets the JSON object of the image_id. More... | |
| cy_p64_error_codes_t | cy_p64_policy_get_image_address_and_size (const cy_p64_cJSON *json, uint32_t image_id, const char *image_type, uint32_t *address, uint32_t *size) |
| Gets the image address and size from the provisioning policy. More... | |
| cy_p64_error_codes_t | cy_p64_policy_get_image_boot_config (const cy_p64_cJSON *json, uint32_t image_id, bool *wdt_enable, uint32_t *wdt_timeout, bool *set_img_ok) |
| Gets the image wdt configuration and image_ok from provisioning policy. More... | |
| const cy_p64_cJSON* cy_p64_find_json_item | ( | const char * | path, |
| const cy_p64_cJSON * | json | ||
| ) |
Finds items by name in the whole JSON.
The name can be not unique so the function returns the first item with this name. For not unique items, it is recommended to parse JSON in two steps: the first find upper unique JSON object, then parse items in this object. Alternatively, provide a full path to the path parameter with the next token(name) & index from the path, e.g.: "path:2/to/the:1/node" –> "path" & 2 For example: boot_upgrade/firmware/resources:1/address:1
| [in] | path | A unique string name to lookup after, or full path. |
| [in] | json | JSON object to check. |
| cy_p64_error_codes_t cy_p64_decode_payload_data | ( | const char * | jwt_packet, |
| cy_p64_cJSON ** | json_packet | ||
| ) |
Decodes JWT payload data from the input jwt_packet to JSON object and returns pointer to this object: json_packet.
It allocates the required space in RAM for the JSON object, so after usage the caller needs to free the JSON object by calling the cy_p64_cJSON_Delete() function.
| [in] | jwt_packet | The pointer to the JWT packet. |
| [out] | json_packet | Outputs the JSON object that contains the JWT payload. |
| CY_P64_SUCCESS | |
| CY_P64_JWT_ERR_INVALID_PARAMETER | This error code is returned, if json_packet is a null pointer. |
| CY_P64_JWT_ERR_MALLOC_FAIL | |
| CY_P64_JWT_ERR_B64DECODE_FAIL | |
| CY_P64_JWT_ERR_JSN_PARSE_FAIL | |
| CY_P64_JWT_ERR_OTHER |
| cy_p64_error_codes_t cy_p64_json_get_boolean | ( | const cy_p64_cJSON * | json, |
| bool * | value | ||
| ) |
Gets the BOOLEAN value of a JSON object.
It's caller's responsibility to use the right function that matches the data type to retrieve data.
| [in] | json | JSON object. |
| [out] | value | The pointer to the BOOLEAN value. |
| CY_P64_SUCCESS | |
| CY_P64_JWT_ERR_INVALID_PARAMETER | This error code is returned, if value is a null pointer. |
| CY_P64_JWT_ERR_JSN_WRONG_TYPE | This error code is returned, if JSON object type is not boolean. |
| cy_p64_error_codes_t cy_p64_json_get_uint32 | ( | const cy_p64_cJSON * | json, |
| uint32_t * | value | ||
| ) |
Gets the unsigned INTEGER value of a JSON object.
It's caller's responsibility to use the right function that matches the data type to retrieve data.
| [in] | json | JSON object. |
| [out] | value | The pointer to the unsigned INTEGER value. |
| CY_P64_SUCCESS | |
| CY_P64_JWT_ERR_INVALID_PARAMETER | This error code is returned, if value is a null pointer. |
| CY_P64_JWT_ERR_JSN_WRONG_TYPE | This error code is returned, if JSON object type is not an integer. |
| cy_p64_error_codes_t cy_p64_json_get_string | ( | const cy_p64_cJSON * | json, |
| const char ** | value | ||
| ) |
Gets the unsigned STRING value of a JSON object.
It's caller's responsibility to use the right function that matches the data type to retrieve data.
| [in] | json | The JSON object. |
| [out] | value | The pointer to the STRING value. |
| CY_P64_SUCCESS | |
| CY_P64_JWT_ERR_INVALID_PARAMETER | This error code is returned, if value is a null pointer. |
| CY_P64_JWT_ERR_JSN_WRONG_TYPE | This error ocde is returned, if JSON object type is not a string. |
| cy_p64_error_codes_t cy_p64_json_get_array_uint8 | ( | const cy_p64_cJSON * | json, |
| uint8_t * | buf, | ||
| uint32_t | size, | ||
| uint32_t * | olen | ||
| ) |
Gets the ARRAY value, in uint8, of a JSON object.
It's caller's responsibility to use the right function that matches the data type to retrieve data.
| [in] | json | The JSON object. |
| [out] | buf | The pointer to the buffer where to store the content. |
| [in] | size | The available size of the buffer in bytes. |
| [out] | olen | The actual size used in the buffer in bytes. |
| CY_P64_SUCCESS | |
| CY_P64_JWT_ERR_INVALID_PARAMETER | This error code is returned, if buf is a null pointer. |
| CY_P64_JWT_ERR_JSN_WRONG_TYPE | This error code is returned, if JSON object is not an array or it contains values other than integer or None. |
| cy_p64_error_codes_t cy_p64_policy_get_image_record | ( | const cy_p64_cJSON * | json, |
| uint32_t | image_id, | ||
| const cy_p64_cJSON ** | json_image | ||
| ) |
Gets the JSON object of the image_id.
| [in] | json | The JSON object with a policy to check. |
| [in] | image_id | The image ID. |
| [out] | json_image | Output JSON object that contains image configuration. |
| CY_P64_SUCCESS | |
| CY_P64_JWT_ERR_INVALID_PARAMETER | This error code is returned, if json_image is a null pointer. |
| CY_P64_JWT_ERR_JSN_NONOBJ | This error is returned, if JSON does not contain "boot_upgrade/firmware" array |
| CY_P64_JWT_ERR_JSN_WRONG_TYPE | This error is returned, if "boot_upgrade/firmware" object type is not an array |
| CY_P64_INVALID |
| cy_p64_error_codes_t cy_p64_policy_get_image_address_and_size | ( | const cy_p64_cJSON * | json, |
| uint32_t | image_id, | ||
| const char * | image_type, | ||
| uint32_t * | address, | ||
| uint32_t * | size | ||
| ) |
Gets the image address and size from the provisioning policy.
It calls cy_p64_policy_get_image_record() function to get the image policy.
| [in] | json | JSON object with policy to check. |
| [in] | image_id | The image ID. |
| [in] | image_type | The image type: "BOOT", "UPGRADE" or other. |
| [out] | address | Output image address. |
| [out] | size | Output image size. |
| CY_P64_SUCCESS | |
| CY_P64_JWT_ERR_INVALID_PARAMETER | This error code is returned, if address or size is a null pointer. |
| CY_P64_JWT_ERR_JSN_NONOBJ | This error is returned, if JSON does not contain "resources" array |
| CY_P64_JWT_ERR_JSN_WRONG_TYPE | This error is returned, if "resources" object type is not an array |
| CY_P64_JWT_ERR_JSN_PARSE_FAIL |
| cy_p64_error_codes_t cy_p64_policy_get_image_boot_config | ( | const cy_p64_cJSON * | json, |
| uint32_t | image_id, | ||
| bool * | wdt_enable, | ||
| uint32_t * | wdt_timeout, | ||
| bool * | set_img_ok | ||
| ) |
Gets the image wdt configuration and image_ok from provisioning policy.
It calls cy_p64_policy_get_image_record() function to get image policy. The function sets wdt_enable and set_img_ok output parameters to false if they are absent in the policy.
| [in] | json | The JSON object with the policy to check. |
| [in] | image_id | The image ID. |
| [out] | wdt_enable | An optional output wdt_enable config. If the set image needs to configure WDT before launching the next image. |
| [out] | wdt_timeout | WDT timeout value config used for WDT configuration if wdt_enable is set. |
| [out] | set_img_ok | Optional Image Ok config. When it is set to "true"
|
| CY_P64_SUCCESS | |
| CY_P64_JWT_ERR_JSN_PARSE_FAIL |