Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Posix EVBME

Functions for communicating with the EVBME of a connected Chili platform. More...

Collaboration diagram for Posix EVBME:

Classes

struct  EVBME_callbacks
 
struct  ca_version_number
 

Typedefs

typedef ca_error(* EVBME_Message_callback) (struct EVBME_Message *params, struct ca821x_dev *pDeviceRef)
 

Functions

struct EVBME_callbacksEVBME_GetCallbackStruct (struct ca821x_dev *pDeviceRef)
 Get the mutable callback structure for the given device. More...
 
ca_error EVBME_COMM_CHECK_request (uint8_t aHandle, uint8_t aDelay, uint8_t aIndCount, uint8_t aIndSize, uint8_t aPayloadLen, struct ca821x_dev *pDeviceRef)
 Send an asynchronous EVBME COMM CHECK request to the given device. More...
 
ca_error EVBME_HOST_CONNECTED_notify (struct ca821x_dev *pDeviceRef)
 Send a notification to the given device to reset and take control of it. More...
 
ca_error EVBME_HOST_DISCONNECTED_notify (struct ca821x_dev *pDeviceRef)
 Send a notification to the given device to reset and release control of it. More...
 
ca_error EVBME_DFU_REBOOT_request (enum evbme_dfu_rebootmode aRebootMode, struct ca821x_dev *pDeviceRef)
 Send a DFU request for reboot to the given device. More...
 
ca_error EVBME_DFU_ERASE_request (uint32_t aStartAddr, uint32_t aEraseLen, struct ca821x_dev *pDeviceRef)
 Send a DFU request for Erase to a given device. More...
 
ca_error EVBME_DFU_WRITE_request (uint32_t aStartAddr, size_t aWriteLen, void *aWriteData, struct ca821x_dev *pDeviceRef)
 Send a DFU request for Write to a given device. More...
 
ca_error EVBME_DFU_CHECK_request (uint32_t aStartAddr, uint32_t aCheckLen, uint32_t aChecksum, struct ca821x_dev *pDeviceRef)
 Send a DFU request to verify a flash range of a given device. More...
 
ca_error EVBME_DFU_BOOTMODE_request (enum evbme_dfu_rebootmode aBootMode, struct ca821x_dev *pDeviceRef)
 Send a DFU request to set the default boot mode of the given device. More...
 
ca_error EVBME_SET_request_sync (enum evbme_attribute aAttrId, size_t aAttrLen, uint8_t *aAttrData, struct ca821x_dev *pDeviceRef)
 Send an EVBME SET request to set the value of an EVBME attribute. More...
 
ca_error EVBME_GET_request_sync (enum evbme_attribute aAttrId, size_t aMaxAttrLen, uint8_t *aAttrData, uint8_t *aAttrLen, struct ca821x_dev *pDeviceRef)
 Send an EVBME GET request to get the value of an EVBME attribute. More...
 
int EVBME_CompareVersions (const char *aVersion1, const char *aVersion2, struct ca_version_number *aVersion1Number, struct ca_version_number *aVersion2Number)
 Compares two input version strings and returns the result. More...
 
ca_error EVBME_CheckVersion (const char *aMinVerString, struct ca821x_dev *pDeviceRef)
 Check the EVBME version of the device and compare it to the SDK version of the application. More...
 

Detailed Description

Functions for communicating with the EVBME of a connected Chili platform.

Typedef Documentation

◆ EVBME_Message_callback

typedef ca_error(* EVBME_Message_callback) (struct EVBME_Message *params, struct ca821x_dev *pDeviceRef)

Function Documentation

◆ EVBME_CheckVersion()

ca_error EVBME_CheckVersion ( const char *  aMinVerString,
struct ca821x_dev pDeviceRef 
)

Check the EVBME version of the device and compare it to the SDK version of the application.

This function should be called in posix applications that communicate with a Chili device in order to warn the user if there is a version mismatch, and potentially exit from the application.

Parameters
aMinVerStringThe string containing the minimum version number allowed. This should be in the form of "x.y", where x is the integer part of the version number and y is the fractional part, e.g. "0.18". NULL if no version requirement, in which case the function always returns CA_ERROR_SUCCESS.
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess - EVBME and host versions compatible
CA_ERROR_FAILEVBME and host versions are not compatible

◆ EVBME_COMM_CHECK_request()

ca_error EVBME_COMM_CHECK_request ( uint8_t  aHandle,
uint8_t  aDelay,
uint8_t  aIndCount,
uint8_t  aIndSize,
uint8_t  aPayloadLen,
struct ca821x_dev pDeviceRef 
)

Send an asynchronous EVBME COMM CHECK request to the given device.

This is used to stress the comms bus.

Parameters
aHandleThe handle used to associate indications to this request
aDelayThe delay the receiving device should wait before sending COMM CHECK indications
aIndCountThe number of indications that the receiving device should send back
aIndSizeThe size of the indications that the receiving device should send back
aPayloadLenThe additional size of the payload to be included in this request
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess
CA_ERROR_INVALID_ARGSaPayloadLen or aIndSize is too large

◆ EVBME_CompareVersions()

int EVBME_CompareVersions ( const char *  aVersion1,
const char *  aVersion2,
struct ca_version_number aVersion1Number,
struct ca_version_number aVersion2Number 
)

Compares two input version strings and returns the result.

Parameters
aVersion1The first version string of the comparison
aVersion2The second version string of the comparison
[out]aVersion1Number(Optional, can be set to NULL) Stores the aVersion1 string into a 'ca_version_number' structure
[out]aVersion2Number(Optional, can be set to NULL) Stores the aVersion2 string into a 'ca_version_number' structure
Returns
Result of the comparison
Return values
0The versions compared are the same
1aVersion1 is newer (i.e. the version number is higher) than aVersion2
-1aVersion1 is older (i.e. the version number is lower) than aVersion2

◆ EVBME_DFU_BOOTMODE_request()

ca_error EVBME_DFU_BOOTMODE_request ( enum evbme_dfu_rebootmode  aBootMode,
struct ca821x_dev pDeviceRef 
)

Send a DFU request to set the default boot mode of the given device.

This command is processed asynchronously and the EVBME_DFU_STATUS_indication will indicate completion.

Parameters
aBootModeThe mode to boot into by default
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess

◆ EVBME_DFU_CHECK_request()

ca_error EVBME_DFU_CHECK_request ( uint32_t  aStartAddr,
uint32_t  aCheckLen,
uint32_t  aChecksum,
struct ca821x_dev pDeviceRef 
)

Send a DFU request to verify a flash range of a given device.

Can be used to verify a flash range of the external flash chip of the given device if aStartAddr >= 0xB0000000. This command is processed asynchronously and the EVBME_DFU_STATUS_indication will indicate completion.

Note: Only send this command if an EVBME_DFU_STATUS_indication was received for the previous one.

EVBME_DFU_STATUS Status code meaning
CA_ERROR_SUCCESS Command was successful, checksum matches
CA_ERROR_INVALID_ARGS aStartAddr or aCheckLen is not aligned
CA_ERROR_INVALID_STATE Device is not in DFU mode
CA_ERROR_FAIL Command was successful, CHECKSUM DOES NOT MATCH
CA_ERROR_ALREADY Command was sent without first having received indication for previous command
Parameters
aStartAddrThe start address of the check, must be page-aligned
aCheckLenThe number of bytes to check, must be a multiple of the page size
aChecksumThe CRC32 Checksum expected of the flash range
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess - check EVBME_DFU_STATUS_indication for checksum status

◆ EVBME_DFU_ERASE_request()

ca_error EVBME_DFU_ERASE_request ( uint32_t  aStartAddr,
uint32_t  aEraseLen,
struct ca821x_dev pDeviceRef 
)

Send a DFU request for Erase to a given device.

Causes the given flash pages to be erased. Can be used to request an Erase to the external flash chip of the given device if aStartAddr >= 0xB0000000. This command is processed asynchronously and the EVBME_DFU_STATUS_indication will indicate completion.

Note: Only send this command if an EVBME_DFU_STATUS_indication was received for the previous one.

EVBME_DFU_STATUS Status code meaning
CA_ERROR_SUCCESS Command was successful
CA_ERROR_INVALID_ARGS aStartAddr or aEraseLen is not aligned
CA_ERROR_INVALID_STATE Device is not in DFU mode
CA_ERROR_ALREADY Command was sent without first having received indication for previous command
Parameters
aStartAddrThe start address of the erase, must be page-aligned. Addresses 0xB0000000 and above represent the external flash.
aEraseLenThe number of bytes to erase, must be a multiple of the page size
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess

◆ EVBME_DFU_REBOOT_request()

ca_error EVBME_DFU_REBOOT_request ( enum evbme_dfu_rebootmode  aRebootMode,
struct ca821x_dev pDeviceRef 
)

Send a DFU request for reboot to the given device.

Causes a full device reset into the requested mode.

Parameters
aRebootModeThe mode to boot into
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess

◆ EVBME_DFU_WRITE_request()

ca_error EVBME_DFU_WRITE_request ( uint32_t  aStartAddr,
size_t  aWriteLen,
void *  aWriteData,
struct ca821x_dev pDeviceRef 
)

Send a DFU request for Write to a given device.

Causes the given flash to be written. Can be used to request a Write to the external flash chip of the given device if aStartAddr >= 0xB0000000. This command is processed asynchronously and the EVBME_DFU_STATUS_indication will indicate completion.

Note: Only send this command if an EVBME_DFU_STATUS_indication was received for the previous one.

EVBME_DFU_STATUS Status code meaning
CA_ERROR_SUCCESS Command was successful
CA_ERROR_INVALID_ARGS aStartAddr or aWriteLen is not aligned
CA_ERROR_INVALID_STATE Device is not in DFU mode
CA_ERROR_ALREADY Command was sent without first having received indication for previous command
Parameters
aStartAddrThe start address of the write, must be word-aligned
aWriteLenThe length of data to write in bytes, must be word-aligned and max 244 bytes
aWriteDataThe data to write, of length aWriteLen
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess
CA_ERROR_INVALID_ARGSaWriteLen is too long

◆ EVBME_GET_request_sync()

ca_error EVBME_GET_request_sync ( enum evbme_attribute  aAttrId,
size_t  aMaxAttrLen,
uint8_t *  aAttrData,
uint8_t *  aAttrLen,
struct ca821x_dev pDeviceRef 
)

Send an EVBME GET request to get the value of an EVBME attribute.

Parameters
aAttrIdThe ID of the target EVBME attribute
aMaxAttrLenThe size of the aAttrData buffer
[out]aAttrDataThe buffer to store the got attribute value
[out]aAttrLenThe length of the attribute stored in the buffer
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess - attribute value in aAttrData
CA_ERROR_NO_BUFFERaAttrData buffer too small to hold received data
CA_ERROR_UNKNOWNAttribute rejected by device for unknown Attr ID

◆ EVBME_GetCallbackStruct()

struct EVBME_callbacks* EVBME_GetCallbackStruct ( struct ca821x_dev pDeviceRef)

Get the mutable callback structure for the given device.

Modify this to add EVBME callback handlers. Do not modify the EVBME callback handlers while the upstream dispatch worker is running asynchronously after being started with ca821x_util_start_upstream_dispatch_worker.

Parameters
pDeviceRefThe device struct for the device that is to have callbacks modified
Returns
A mutable pointer to the device's EVBME callback structure

◆ EVBME_HOST_CONNECTED_notify()

ca_error EVBME_HOST_CONNECTED_notify ( struct ca821x_dev pDeviceRef)

Send a notification to the given device to reset and take control of it.

Causes an RF reset and print of device info.

Warning
This command causes a device reset, so should only be used with simple stateless applications like mac-dongle
Parameters
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess

◆ EVBME_HOST_DISCONNECTED_notify()

ca_error EVBME_HOST_DISCONNECTED_notify ( struct ca821x_dev pDeviceRef)

Send a notification to the given device to reset and release control of it.

Causes an RF reset.

Warning
This command causes a device reset, so should only be used with simple stateless applications like mac-dongle
Parameters
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess

◆ EVBME_SET_request_sync()

ca_error EVBME_SET_request_sync ( enum evbme_attribute  aAttrId,
size_t  aAttrLen,
uint8_t *  aAttrData,
struct ca821x_dev pDeviceRef 
)

Send an EVBME SET request to set the value of an EVBME attribute.

Parameters
aAttrIdThe ID of the target EVBME attribute
aAttrLenThe length of the data to send
aAttrDataThe Data to set in the EVBME attribute
pDeviceRefThe device struct for the device this message is to be sent to
Returns
Status of the command
Return values
CA_ERROR_SUCCESSSuccess
CA_ERROR_INVALID_ARGSLength too long
CA_ERROR_INVALIDAttribute rejected by device for invalid len/value
CA_ERROR_UNKNOWNAttribute rejected by device for unknown Attr ID