Callisto4Bootloader: ARK/platform_coap.c File Reference

Callisto4Bootloader

Macros | Enumerations | Functions | Variables
platform_coap.c File Reference
`#include <float.h>`
`#include "coap.h"`
`#include "platform_coap.h"`
`#include "platform_encoder.h"`

Go to the source code of this file.

## Macros

#define | DEFAULT_PAYLOAD_BUFFER_SIZE 4096
#define | PAYLOAD_REALLOC_TRIGGER_LEVEL 512
#define | TYPE_ALLOCATION_INCREMENT 100
#define | RESOURCE_URI_PATH_MAXLEN 100

## Enumerations

enum | eFinalState_t { eFinalState_Field, eFinalState_Struct, eFinalState_NotFound, eFinalState_Error }

## Functions

static coap_resource_t * | CreateResource (const char *pchResourceStr, const char *pchResourceType, const char *pchInterfaceDescription, uint16_t ui16MediaType)
static void | META_Callback (coap_context_t *ctx, struct coap_resource_t *resource, coap_session_t *session, coap_pdu_t *request, coap_binary_t *token, coap_string_t *query, coap_pdu_t *response)
static void | GET_Callback (coap_context_t *ctx, struct coap_resource_t *resource, coap_session_t *session, coap_pdu_t *request, coap_binary_t *token, coap_string_t *query, coap_pdu_t *response)
static void | PUT_Callback (coap_context_t *ctx, struct coap_resource_t *resource, coap_session_t *session, coap_pdu_t *request, coap_binary_t *token, coap_string_t *query, coap_pdu_t *response)
static eFinalState_t | IterateDownwards (stPLATFORM_ObjectData_t *pstObjectData, coap_pdu_t *request, const stPLUGIN_Field_t **ppstFieldFound)
static uint32_t | UpdateWithFieldData (const stPLUGIN_Field_t *pstField, void *pvObject, uint32_t uiFieldFlags, void **pvObj)
static eAccess_t | GET_StructToJSON (stPayloadBuffer_t *pstPayload, void *pvObject, const stPLUGIN_Type_t *pstType, const stPayloadEncoder_t *pstEncoder, uint32_t uiFieldFlags)
static eAccess_t | GET_ObjectToJSON (stPayloadBuffer_t *pstPayload, void *pvObject, const stPLUGIN_Field_t *pstField, const stPayloadEncoder_t *pstEncoder, uint32_t uiFieldFlags)
static eAccess_t | PUT_StructToJSON (stPayloadBuffer_t *pstPayload, void *pvObject, const stPLUGIN_Type_t *pstType, const stPayloadDecoder_t *pstDecoder, uint32_t uiFieldFlags)
static eAccess_t | PUT_ObjectToJSON (stPayloadBuffer_t *pstPayload, void *pvObject, const stPLUGIN_Field_t *pstField, const stPayloadDecoder_t *pstDecoder, uint32_t uiFieldFlags)
static eAccess_t | META_StructToJSON (stPayloadBuffer_t *pstPayload, void *pvObject, const stPLUGIN_Type_t *pstType, const stPayloadEncoder_t *pstEncoder, uint32_t uiFieldFlags, uint8_t u8Owner)
static eAccess_t | META_ObjectToJSON (stPayloadBuffer_t *pstPayload, void *pvObject, const stPLUGIN_Field_t *pstField, const stPayloadEncoder_t *pstEncoder, uint32_t uiFieldFlags, uint8_t u8Owner)
void * | CoAP_Initialise (void)
bool | CoAP_CreateResource (stPLATFORM_ObjectData_t *pstObjectData)
void | CoAP_ObjectUpdated (const stPLATFORM_ObjectData_t *pstObjectData)
static bool | CoAP_ObjectEdited (const stPLATFORM_ObjectData_t *pstObjectData)
static void | META_OutputResourceInfo (const stPayloadEncoder_t *pstEncoder, stPayloadBuffer_t *pstPayload, const stPLATFORM_ObjectData_t *pstObjectData)
static void | META_OutputFlagInfo (const stPayloadEncoder_t *pstEncoder, stPayloadBuffer_t *pstPayload, const stPLATFORM_ObjectData_t *pstObjectData)
static bool | ThisIsABaseType (const char *pachTypeName)
static void | Payload_SetupFoundTypes (stPayloadBuffer_t *pstPayload)
static bool | Payload_BufferAlloc (stPayloadBuffer_t *pstPayload, uint32_t uiSize)
static bool | Payload_BufferRealloc (stPayloadBuffer_t *pstPayload)
static void | Payload_BufferForce (stPayloadBuffer_t *pstPayload, uint8_t *pau8Buffer, uint32_t uiSize)
static void | Payload_BufferFree (stPayloadBuffer_t *pstPayload)
static bool | Payload_FindType (stPayloadBuffer_t *pstPayload, uint8_t u8OwnerIndex, const char *pachTypeName)
static bool | GetFieldAttributes (void *pvObject, const stPLUGIN_Field_t *pstField, uint32_t *puiNumElements, bool *pbVisibility)
static void | META_EncodeType (stPayloadBuffer_t *pstPayload, const stPayloadEncoder_t *pstEncoder, uint8_t u8Owner, const char *pachTypeName)

## Variables

static coap_context_t * | context
static coap_resource_t * | meta_resource
static const char *const | apachBaseTypes []
const char * | apchFieldFlagNames []

## Macro Definition Documentation

## ◆ DEFAULT_PAYLOAD_BUFFER_SIZE

#define DEFAULT_PAYLOAD_BUFFER_SIZE 4096

Definition at line 15 of file platform_coap.c.

## ◆ PAYLOAD_REALLOC_TRIGGER_LEVEL

#define PAYLOAD_REALLOC_TRIGGER_LEVEL 512

Definition at line 18 of file platform_coap.c.

## ◆ RESOURCE_URI_PATH_MAXLEN

#define RESOURCE_URI_PATH_MAXLEN 100

Definition at line 24 of file platform_coap.c.

## ◆ TYPE_ALLOCATION_INCREMENT

#define TYPE_ALLOCATION_INCREMENT 100

Definition at line 21 of file platform_coap.c.

## Enumeration Type Documentation

## ◆ eFinalState_t

enum eFinalState_t

Enumerator
eFinalState_Field |
eFinalState_Struct |
eFinalState_NotFound |
eFinalState_Error |

Definition at line 26 of file platform_coap.c.

## Function Documentation

## ◆ CoAP_CreateResource()

bool CoAP_CreateResource | ( | stPLATFORM_ObjectData_t * | pstObjectData | ) |

Create a CoAP resource

Parameters

  [in] | pstObjectData | Object data to associate with a CoAP resource

Returns
  true if creation was successful, else false

Definition at line 180 of file platform_coap.c.

References CreateResource(), GET_Callback(), NULL, and PUT_Callback().

## ◆ CoAP_Initialise()

void* CoAP_Initialise | ( | void |  | ) |

Initialise the CoAP library

Returns
  Blind pointer to created context

Definition at line 148 of file platform_coap.c.

References context, CreateResource(), META_Callback(), meta_resource, and NULL.

## ◆ CoAP_ObjectEdited()

static bool CoAP_ObjectEdited | ( | const stPLATFORM_ObjectData_t * | pstObjectData | ) |

static

Notify an object owner that the contents of its object have been edited via CoAP

Parameters

  [in] | pstObjectData | Object data previously associated with the CoAP resource

Returns
  true if operation completed OK, else false

Definition at line 224 of file platform_coap.c.

References NULL.

Referenced by PUT_Callback().

## ◆ CoAP_ObjectUpdated()

void CoAP_ObjectUpdated | ( | const stPLATFORM_ObjectData_t * | pstObjectData | ) |

Notify the CoAP library that a resource has changed

Parameters

  [in] | pstObjectData | Object data previously associated with the CoAP resource

Definition at line 206 of file platform_coap.c.

References context.

## ◆ CreateResource()

static coap_resource_t * CreateResource | ( | const char * | pchResourceStr,
|  | const char * | pchResourceType,
|  | const char * | pchInterfaceDescription,
|  | uint16_t | ui16MediaType
| ) |  |

static

Create a libcoap resource

Parameters

  [in] | pchResourceStr | Name of the resource (e.g. "inputs")
  [in] | pchResourceType | Resource Type
  [in] | pchInterfaceDescription | Interface Description
  [in] | ui16MediaType | Content Type (50 = JSON, 60 = CBOR, etc)

Return values

  N | Pointer to successfully created libcoap resource
  NULL | Was unable to create libcoap resource

Definition at line 249 of file platform_coap.c.

References context, and NULL.

Referenced by CoAP_CreateResource(), and CoAP_Initialise().

## ◆ GET_Callback()

static void GET_Callback | ( | coap_context_t * | ctx,
|  | struct coap_resource_t * | resource,
|  | coap_session_t * | session,
|  | coap_pdu_t * | request,
|  | coap_binary_t * | token,
|  | coap_string_t * | query,
|  | coap_pdu_t * | response
| ) |  |

static

Registered callback for GET to a CoAP resource. The resource URI to be created is passed in the options.

Parameters

  [in] | ctx | CoAP context
  [in] | resource | CoAP resource
  [in] | session | CoAP session
  [in] | request | CoAP incoming request
  [in] | token | CoAP token
  [in] | query | CoAP query
  [out] | response | CoAP response to fill out

Definition at line 789 of file platform_coap.c.

References DEFAULT_PAYLOAD_BUFFER_SIZE, eFinalState_Error, eFinalState_Field, eFinalState_NotFound, eFinalState_Struct, GET_ObjectToJSON(), GET_StructToJSON(), IterateDownwards(), NULL, stPayloadBuffer_t::pau8Buffer, Payload_BufferAlloc(), Payload_BufferFree(), PayloadEncoder_Get(), stPayloadEncoder_t::pfn_EncodeStructEnd, stPayloadEncoder_t::pfn_EncodeStructStart, and stPayloadBuffer_t::uiBufferLen.

Referenced by CoAP_CreateResource().

## ◆ GET_ObjectToJSON()

static eAccess_t GET_ObjectToJSON | ( | stPayloadBuffer_t * | pstPayload,
|  | void * | pvObject,
|  | const stPLUGIN_Field_t * | pstField,
|  | const stPayloadEncoder_t * | pstEncoder,
|  | uint32_t | uiFieldFlags
| ) |  |

static

Serialise an object's field out to a buffer

Parameters

  [out] | pstPayload | Buffer to fill with serialised data
  [in] | pvObject | Current object
  [in] | pstField | Current field
  [in] | pstEncoder | Selected serialiser
  [in] | uiFieldFlags | Current field flags

Returns
  eAccess_OK if successful, else eAccess_t failure code

Definition at line 1247 of file platform_coap.c.

References GET_StructToJSON(), GetFieldAttributes(), i, NULL, Payload_BufferRealloc(), stPayloadEncoder_t::pfn_EncodeArrayEnd, stPayloadEncoder_t::pfn_EncodeArraySeparator, stPayloadEncoder_t::pfn_EncodeArrayStart, stPayloadEncoder_t::pfn_EncodeBoolean, stPayloadEncoder_t::pfn_EncodeReal, stPayloadEncoder_t::pfn_EncodeSignedInt, stPayloadEncoder_t::pfn_EncodeString, and stPayloadEncoder_t::pfn_EncodeUnsignedInt.

Referenced by GET_Callback(), and GET_StructToJSON().

## ◆ GET_StructToJSON()

static eAccess_t GET_StructToJSON | ( | stPayloadBuffer_t * | pstPayload,
|  | void * | pvObject,
|  | const stPLUGIN_Type_t * | pstType,
|  | const stPayloadEncoder_t * | pstEncoder,
|  | uint32_t | uiFieldFlags
| ) |  |

static

Serialise an object's struct out to a buffer

Parameters

  [out] | pstPayload | Buffer to fill with serialised data
  [in] | pvObject | Current object
  [in] | pstType | Type of the current object
  [in] | pstEncoder | Selected serialiser
  [in] | uiFieldFlags | Current field flags

Returns
  eAccess_OK if successful, else eAccess_t failure code

Definition at line 1147 of file platform_coap.c.

References GET_ObjectToJSON(), NULL, stPayloadEncoder_t::pfn_EncodeFieldName, stPayloadEncoder_t::pfn_EncodeFieldSeparator, stPayloadEncoder_t::pfn_EncodeStructEnd, stPayloadEncoder_t::pfn_EncodeStructStart, and UpdateWithFieldData().

Referenced by GET_Callback(), and GET_ObjectToJSON().

## ◆ GetFieldAttributes()

static bool GetFieldAttributes | ( | void * | pvObject,
|  | const stPLUGIN_Field_t * | pstField,
|  | uint32_t * | puiNumElements,
|  | bool * | pbVisibility
| ) |  |

static

Helper function to get the array size and visibility of a dynamic field element

Parameters

  [in] | pvObject | Current object
  [in] | pstField | Current field
  [out] | puiNumElements | Number of array elements
  [out] | pbVisibility | true if field is visible, else false

Returns
  true if the element is an array, else false

Definition at line 1197 of file platform_coap.c.

Referenced by GET_ObjectToJSON(), and PUT_ObjectToJSON().

## ◆ IterateDownwards()

static eFinalState_t IterateDownwards | ( | stPLATFORM_ObjectData_t * | pstObjectData,
|  | coap_pdu_t * | request,
|  | const stPLUGIN_Field_t ** | ppstFieldFound
| ) |  |

static

Iterate downwards through the CoAP request's full URI path

Parameters

  [in] | pstObjectData | Object data previously associated with the CoAP resource
  [in] | request | Current CoAP request
  [out] | ppstFieldFound | If iterating downwards reached a field, this is the field that was found

Return values

  eFinalState_Field | The item specified was an individual field
  eFinalState_Struct | The item specified was a struct
  eFinalState_NotFound | The item name was not recognised
  eFinalState_Error | A different error occurred

Definition at line 1024 of file platform_coap.c.

References eFinalState_Error, eFinalState_Field, eFinalState_NotFound, eFinalState_Struct, NULL, and UpdateWithFieldData().

Referenced by GET_Callback(), and PUT_Callback().

## ◆ META_Callback()

static void META_Callback | ( | coap_context_t * | ctx,
|  | struct coap_resource_t * | resource,
|  | coap_session_t * | session,
|  | coap_pdu_t * | request,
|  | coap_binary_t * | token,
|  | coap_string_t * | query,
|  | coap_pdu_t * | response
| ) |  |

static

Registered callback for GET to a meta resource. The resource URI Path is passed in the options.

Parameters

  [in] | ctx | CoAP context
  [in] | resource | CoAP resource
  [in] | session | CoAP session
  [in] | request | CoAP incoming request
  [in] | token | CoAP token
  [in] | query | CoAP query
  [out] | response | CoAP response to fill out

Definition at line 558 of file platform_coap.c.

References context, i, META_OutputFlagInfo(), META_OutputResourceInfo(), META_StructToJSON(), NULL, stPayloadBuffer_t::pau8Buffer, Payload_BufferAlloc(), Payload_BufferFree(), stPayloadEncoder_t::pfn_EncodeArrayEnd, stPayloadEncoder_t::pfn_EncodeArraySeparator, stPayloadEncoder_t::pfn_EncodeArrayStart, stPayloadEncoder_t::pfn_EncodeFieldName, stPayloadEncoder_t::pfn_EncodeFieldSeparator, stPayloadEncoder_t::pfn_EncodeStructEnd, stPayloadEncoder_t::pfn_EncodeStructStart, RESOURCE_URI_PATH_MAXLEN, stJSONEncoder, and stPayloadBuffer_t::uiBufferLen.

Referenced by CoAP_Initialise().

## ◆ META_EncodeType()

static void META_EncodeType | ( | stPayloadBuffer_t * | pstPayload,
|  | const stPayloadEncoder_t * | pstEncoder,
|  | uint8_t | u8Owner,
|  | const char * | pachTypeName
| ) |  |

static

Encode a given user type out to a payload, adding a prefix if it is owned by a plugin

Parameters

  [in] | pstPayload | Current payload
  [in] | pstEncoder | Current encoder
  [in] | u8Owner | Type's owner (e.g. platform, plugin#1, etc)
  [in] | pachTypeName | Type's name

Definition at line 1679 of file platform_coap.c.

References stPayloadEncoder_t::pfn_EncodeFieldName, and stPayloadEncoder_t::pfn_EncodeString.

Referenced by META_ObjectToJSON().

## ◆ META_ObjectToJSON()

static eAccess_t META_ObjectToJSON | ( | stPayloadBuffer_t * | pstPayload,
|  | void * | pvObject,
|  | const stPLUGIN_Field_t * | pstField,
|  | const stPayloadEncoder_t * | pstEncoder,
|  | uint32_t | uiFieldFlags,
|  | uint8_t | u8Owner
| ) |  |

static

Serialise an object's field metainformation out to a buffer

Parameters

  [out] | pstPayload | Buffer to fill with serialised metainformation
  [in] | pvObject | Current object
  [in] | pstField | Current field
  [in] | pstEncoder | Selected serialiser
  [in] | uiFieldFlags | Current field flags
  [in] | u8Owner | Owner of this resource

Returns
  eAccess_OK if successful, else eAccess_t failure code

Definition at line 1708 of file platform_coap.c.

References META_EncodeType(), META_StructToJSON(), NULL, Payload_BufferRealloc(), Payload_FindType(), stPayloadEncoder_t::pfn_EncodeArrayEnd, stPayloadEncoder_t::pfn_EncodeArraySeparator, stPayloadEncoder_t::pfn_EncodeArrayStart, stPayloadEncoder_t::pfn_EncodeFieldName, stPayloadEncoder_t::pfn_EncodeFieldSeparator, stPayloadEncoder_t::pfn_EncodeReal, stPayloadEncoder_t::pfn_EncodeSignedInt, stPayloadEncoder_t::pfn_EncodeString, stPayloadEncoder_t::pfn_EncodeStructEnd, stPayloadEncoder_t::pfn_EncodeStructStart, stPayloadEncoder_t::pfn_EncodeUnsignedInt, and ThisIsABaseType().

Referenced by META_StructToJSON().

## ◆ META_OutputFlagInfo()

static void META_OutputFlagInfo | ( | const stPayloadEncoder_t * | pstEncoder,
|  | stPayloadBuffer_t * | pstPayload,
|  | const stPLATFORM_ObjectData_t * | pstObjectData
| ) |  |

static

Output an object's uiFieldFlags bitmask as an array of named elements

Parameters

  [in] | pstEncoder | Current encoder
  [in] | pstPayload | Payload to write to
  [in] | pstObjectData | Current object

Definition at line 358 of file platform_coap.c.

References apchFieldFlagNames, i, NULL, stPayloadEncoder_t::pfn_EncodeArrayEnd, stPayloadEncoder_t::pfn_EncodeArraySeparator, stPayloadEncoder_t::pfn_EncodeArrayStart, stPayloadEncoder_t::pfn_EncodeFieldName, and stPayloadEncoder_t::pfn_EncodeString.

Referenced by META_Callback().

## ◆ META_OutputResourceInfo()

static void META_OutputResourceInfo | ( | const stPayloadEncoder_t * | pstEncoder,
|  | stPayloadBuffer_t * | pstPayload,
|  | const stPLATFORM_ObjectData_t * | pstObjectData
| ) |  |

static

Output the resource's metadata to a payload as fields using a particular encoder

Parameters

  [in] | pstEncoder | JSON encoder
  [in] | pstPayload | Payload buffer
  [in] | pstObjectData | Resource

Definition at line 296 of file platform_coap.c.

References stPayloadEncoder_t::pfn_EncodeFieldName, stPayloadEncoder_t::pfn_EncodeFieldSeparator, stPayloadEncoder_t::pfn_EncodeSignedInt, stPayloadEncoder_t::pfn_EncodeString, and stPayloadEncoder_t::pfn_EncodeUnsignedInt.

Referenced by META_Callback().

## ◆ META_StructToJSON()

static eAccess_t META_StructToJSON | ( | stPayloadBuffer_t * | pstPayload,
|  | void * | pvObject,
|  | const stPLUGIN_Type_t * | pstType,
|  | const stPayloadEncoder_t * | pstEncoder,
|  | uint32_t | uiFieldFlags,
|  | uint8_t | u8Owner
| ) |  |

static

Serialise an object's metadata out to a buffer

Parameters

  [out] | pstPayload | Buffer to fill with serialised data
  [in] | pvObject | Current object
  [in] | pstType | Type of the current object
  [in] | pstEncoder | Selected serialiser
  [in] | uiFieldFlags | Current field flags
  [in] | u8Owner | Who owns this resource

Returns
  eAccess_OK if successful, else eAccess_t failure code

Definition at line 1629 of file platform_coap.c.

References META_ObjectToJSON(), NULL, stPayloadEncoder_t::pfn_EncodeFieldName, stPayloadEncoder_t::pfn_EncodeFieldSeparator, stPayloadEncoder_t::pfn_EncodeStructEnd, stPayloadEncoder_t::pfn_EncodeStructStart, and UpdateWithFieldData().

Referenced by META_Callback(), and META_ObjectToJSON().

## ◆ Payload_BufferAlloc()

static bool Payload_BufferAlloc | ( | stPayloadBuffer_t * | pstPayload,
|  | uint32_t | uiSize
| ) |  |

static

Allocate a payload buffer

Parameters

  [in] | pstPayload | Current payload
  [in] | uiSize | Size of the payload buffer to allocate

Returns
  true if allocation was successful, else false

Definition at line 427 of file platform_coap.c.

References stPayloadBuffer_t::bWasMalloced, NULL, stPayloadBuffer_t::pau8Buffer, Payload_SetupFoundTypes(), stPayloadBuffer_t::uiBufferLen, and stPayloadBuffer_t::uiBufferSize.

Referenced by GET_Callback(), and META_Callback().

## ◆ Payload_BufferForce()

static void Payload_BufferForce | ( | stPayloadBuffer_t * | pstPayload,
|  | uint8_t * | pau8Buffer,
|  | uint32_t | uiSize
| ) |  |

static

Force a payload to use an existing buffer in memory

Parameters

  [in] | pstPayload | Payload structure to update
  [in] | pau8Buffer | Existing buffer in memory
  [in] | uiSize | Length of the existing buffer

Definition at line 476 of file platform_coap.c.

References stPayloadBuffer_t::bWasMalloced, stPayloadBuffer_t::pau8Buffer, Payload_SetupFoundTypes(), stPayloadBuffer_t::uiBufferLen, and stPayloadBuffer_t::uiBufferSize.

Referenced by PUT_Callback().

## ◆ Payload_BufferFree()

static void Payload_BufferFree | ( | stPayloadBuffer_t * | pstPayload | ) |

static

Definition at line 491 of file platform_coap.c.

References stPayloadBuffer_t::bWasMalloced, NULL, stPayloadBuffer_t::pastFoundTypes, and stPayloadBuffer_t::pau8Buffer.

Referenced by GET_Callback(), META_Callback(), and PUT_Callback().

## ◆ Payload_BufferRealloc()

static bool Payload_BufferRealloc | ( | stPayloadBuffer_t * | pstPayload | ) |

static

Reallocate a payload buffer if it looks like it might possibly overflow

Parameters

  [in] | pstPayload | Current payload

Returns
  false if a realloc was attempted but failed, else true

Definition at line 446 of file platform_coap.c.

References stPayloadBuffer_t::bWasMalloced, NULL, stPayloadBuffer_t::pau8Buffer, PAYLOAD_REALLOC_TRIGGER_LEVEL, stPayloadBuffer_t::uiBufferLen, and stPayloadBuffer_t::uiBufferSize.

Referenced by GET_ObjectToJSON(), and META_ObjectToJSON().

## ◆ Payload_FindType()

static bool Payload_FindType | ( | stPayloadBuffer_t * | pstPayload,
|  | uint8_t | u8OwnerIndex,
|  | const char * | pachTypeName
| ) |  |

static

See if we have already encountered a given type while building the current payload, else add it to the list

Parameters

  [in] | pstPayload | Current payload
  [in] | u8OwnerIndex | Who owns this type (e.g. platform, plugin#1, etc)
  [in] | pachTypeName | Typename to check

Returns
  true if we have already encountered the specified type, else false

Definition at line 516 of file platform_coap.c.

References stFoundType_t::pachTypeName, stPayloadBuffer_t::pastFoundTypes, TYPE_ALLOCATION_INCREMENT, stFoundType_t::u8OwnerIndex, stPayloadBuffer_t::uiFoundTypesAlloced, and stPayloadBuffer_t::uiFoundTypesNum.

Referenced by META_ObjectToJSON().

## ◆ Payload_SetupFoundTypes()

static void Payload_SetupFoundTypes | ( | stPayloadBuffer_t * | pstPayload | ) |

static

Initialise the list of found types inside the current payload

Parameters

  [in] | pstPayload | Current payload

Definition at line 412 of file platform_coap.c.

References NULL, stPayloadBuffer_t::pastFoundTypes, stPayloadBuffer_t::uiFoundTypesAlloced, and stPayloadBuffer_t::uiFoundTypesNum.

Referenced by Payload_BufferAlloc(), and Payload_BufferForce().

## ◆ PUT_Callback()

static void PUT_Callback | ( | coap_context_t * | ctx,
|  | struct coap_resource_t * | resource,
|  | coap_session_t * | session,
|  | coap_pdu_t * | request,
|  | coap_binary_t * | token,
|  | coap_string_t * | query,
|  | coap_pdu_t * | response
| ) |  |

static

Registered callback for PUT to a CoAP resource. The resource URI to be created is passed in the options (uri path) The values to be set are in the incoming request's payload.

Parameters

  [in] | ctx | CoAP context
  [in] | resource | CoAP resource
  [in] | session | CoAP session
  [in] | request | CoAP incoming request
  [in] | token | CoAP token
  [in] | query | CoAP query
  [out] | response | CoAP response to fill out

Definition at line 896 of file platform_coap.c.

References CoAP_ObjectEdited(), eFinalState_Error, eFinalState_Field, eFinalState_NotFound, eFinalState_Struct, IterateDownwards(), NULL, Payload_BufferForce(), Payload_BufferFree(), PayloadDecoder_Get(), stPayloadDecoder_t::pfn_DecodeStructEnd, stPayloadDecoder_t::pfn_DecodeStructStart, PUT_ObjectToJSON(), and PUT_StructToJSON().

Referenced by CoAP_CreateResource().

## ◆ PUT_ObjectToJSON()

static eAccess_t PUT_ObjectToJSON | ( | stPayloadBuffer_t * | pstPayload,
|  | void * | pvObject,
|  | const stPLUGIN_Field_t * | pstField,
|  | const stPayloadDecoder_t * | pstDecoder,
|  | uint32_t | uiFieldFlags
| ) |  |

static

Deserialize data in a buffer out to an object's field

Parameters

  [in] | pstPayload | Buffer to fill with serialised data
  [in] | pvObject | Current object
  [in] | pstField | Current field structure
  [in] | pstDecoder | Selected deserialiser
  [in] | uiFieldFlags | Current field flags

Returns
  eAccess_OK if successful, else eAccess_t failure code

Definition at line 1484 of file platform_coap.c.

References GetFieldAttributes(), i, NULL, stPayloadDecoder_t::pfn_DecodeArrayEnd, stPayloadDecoder_t::pfn_DecodeArraySeparator, stPayloadDecoder_t::pfn_DecodeArrayStart, stPayloadDecoder_t::pfn_DecodeBoolean, stPayloadDecoder_t::pfn_DecodeReal, stPayloadDecoder_t::pfn_DecodeSignedInt, stPayloadDecoder_t::pfn_DecodeString, stPayloadDecoder_t::pfn_DecodeUnsignedInt, and PUT_StructToJSON().

Referenced by PUT_Callback(), and PUT_StructToJSON().

## ◆ PUT_StructToJSON()

static eAccess_t PUT_StructToJSON | ( | stPayloadBuffer_t * | pstPayload,
|  | void * | pvObject,
|  | const stPLUGIN_Type_t * | pstType,
|  | const stPayloadDecoder_t * | pstDecoder,
|  | uint32_t | uiFieldFlags
| ) |  |

static

Deserialize data in a buffer out to an object's struct

Parameters

  [in] | pstPayload | Buffer containing serialised data to deserialise
  [in] | pvObject | Current object data
  [in] | pstType | Current object's structure
  [in] | pstDecoder | Selected deserialiser
  [in] | uiFieldFlags | Current field flags

Returns
  eAccess_OK if successful, else eAccess_t failure code

Definition at line 1391 of file platform_coap.c.

References NULL, stPayloadDecoder_t::pfn_DecodeFieldName, stPayloadDecoder_t::pfn_DecodeFieldSeparator, stPayloadDecoder_t::pfn_DecodeStructEnd, stPayloadDecoder_t::pfn_DecodeStructStart, PUT_ObjectToJSON(), and UpdateWithFieldData().

Referenced by PUT_Callback(), and PUT_ObjectToJSON().

## ◆ ThisIsABaseType()

static bool ThisIsABaseType | ( | const char * | pachTypeName | ) |

static

Determine whether a given type is a (shared) base type

Parameters

  [in] | pachTypeName | Type to check

Returns
  true if the type is a shared base type, else false

Definition at line 393 of file platform_coap.c.

References apachBaseTypes, and i.

Referenced by META_ObjectToJSON().

## ◆ UpdateWithFieldData()

static uint32_t UpdateWithFieldData | ( | const stPLUGIN_Field_t * | pstField,
|  | void * | pvObject,
|  | uint32_t | uiFieldFlags,
|  | void ** | pvObj
| ) |  |

static

Use a field's data to update the current object and current permission flags

Parameters

  [in] | pstField | Field struct to update from
  [in] | pvObject | Current object pointer
  [in] | uiFieldFlags | Current field flags
  [out] | pvObj | Updated object pointer

Returns
  Updated field flags

Definition at line 1118 of file platform_coap.c.

Referenced by GET_StructToJSON(), IterateDownwards(), META_StructToJSON(), and PUT_StructToJSON().

## Variable Documentation

## ◆ apachBaseTypes

const char* const apachBaseTypes[]

static

Initial value:
=
{
"tInt8",
"tInt16",
"tInt32",
"tInt64",
"tUint8",
"tUint16",
"tUint32",
"tUint64",
"tBool"
}

Definition at line 124 of file platform_coap.c.

Referenced by ThisIsABaseType().

## ◆ apchFieldFlagNames

const char* apchFieldFlagNames[]

Initial value:
=
{
NULL,
NULL,
"ReadFact",
"ReadComm",
"ReadLive",
"WriteFact",
"WriteComm",
"WriteLive",
NULL,
"Persistent",
"Managed",
"Live",
"NeedsReboot",
"Button",
"Radio",
"Hex",
"Private",
}

Array mapping uiFieldFlags bitmask bits to strings that appear in a JSON "Flags" array

Definition at line 330 of file platform_coap.c.

Referenced by META_OutputFlagInfo().

## ◆ context

coap_context_t* context

static

Definition at line 119 of file platform_coap.c.

Referenced by CoAP_Initialise(), CoAP_ObjectUpdated(), CreateResource(), and META_Callback().

## ◆ meta_resource

coap_resource_t* meta_resource

static

Definition at line 121 of file platform_coap.c.

Referenced by CoAP_Initialise().

NULL
#define NULL
Definition: bootloader_common.h:26