Host Communication Protocol  2.0
fpc_hcp.h File Reference

Host Communication Protocol interface. More...

#include <stdbool.h>
#include <stdint.h>
#include "fpc_hcp_common.h"
#include "fpc_com_chain.h"
Include dependency graph for fpc_hcp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

fpc_com_result_t fpc_hcp_transmit (fpc_hcp_packet_t *packet, fpc_com_chain_t *chain)
 Transmits an application packet through the supplied transmit chain. More...
 
fpc_com_result_t fpc_hcp_receive (fpc_hcp_packet_t *packet, fpc_com_chain_t *chain)
 Receives an application packet through the supplied transmit chain. More...
 
bool fpc_hcp_arg_add (fpc_hcp_packet_t *packet, fpc_hcp_arg_t arg, uint16_t size, bool free_data, void *data)
 Add argument to packet. More...
 
bool fpc_hcp_arg_check (fpc_hcp_packet_t *packet, fpc_hcp_arg_t arg)
 Check if command contains selected argument key. More...
 
fpc_hcp_arg_data_tfpc_hcp_arg_get (fpc_hcp_packet_t *packet, fpc_hcp_arg_t arg)
 Get Argument with specified key. More...
 
bool fpc_hcp_arg_copy_data (fpc_hcp_packet_t *packet, fpc_hcp_arg_t arg, uint16_t data_size, uint8_t *data)
 Copy data from an argument with specified key. More...
 
void fpc_hcp_free (fpc_com_chain_t *chain, fpc_hcp_packet_t *packet)
 Frees the resources held by the packet i.e. the dynamic data held in the arguments. More...
 
uint16_t fpc_hcp_get_size (fpc_hcp_packet_t *packet, uint16_t *num_args)
 Calculate serialized packet size. More...
 

Detailed Description

Host Communication Protocol interface.

Definition in file fpc_hcp.h.

Function Documentation

bool fpc_hcp_arg_add ( fpc_hcp_packet_t packet,
fpc_hcp_arg_t  arg,
uint16_t  size,
bool  free_data,
void *  data 
)

Add argument to packet.

Note
This function does not allocate any memory, it will only set the argument variables.
Parameters
[in]packetPacket to add to.
[in]argArgument id.
[in]sizeSize of argument data.
[in]free_dataSet to true if data should be owned by the argument, false if user still owns data.
[in]dataPointer to argument data.
Returns
true = success, false = failure.

Definition at line 145 of file fpc_hcp.c.

References fpc_hcp_arg_data::arg, ARG_NONE, fpc_hcp_packet::arguments, fpc_hcp_arg_data::data, fpc_hcp_arg_data::free_data, fpc_hcp_packet::num_args, and fpc_hcp_arg_data::size.

bool fpc_hcp_arg_check ( fpc_hcp_packet_t packet,
fpc_hcp_arg_t  arg 
)

Check if command contains selected argument key.

Parameters
[in]packetThe packet to scan.
[in]argArgument to look for.
Returns
true if found, false if not found.

Definition at line 169 of file fpc_hcp.c.

References fpc_hcp_arg_get().

Here is the call graph for this function:

bool fpc_hcp_arg_copy_data ( fpc_hcp_packet_t packet,
fpc_hcp_arg_t  arg,
uint16_t  data_size,
uint8_t *  data 
)

Copy data from an argument with specified key.

Argument data will be copied to specified data buffer. Remaining bytes in data will be cleared if the argument data size is less than data size when the argument contains data.

Parameters
[in]packetThe packet to operate on.
[in]argThe arg to retrieve data from.
[in]data_sizeNumber of bytes to copy.
[in,out]dataPointer to data buffer.
Returns
True if argument found, false if not found.

Definition at line 183 of file fpc_hcp.c.

References fpc_hcp_arg_data::data, fpc_hcp_arg_get(), and fpc_hcp_arg_data::size.

Here is the call graph for this function:

fpc_hcp_arg_data_t* fpc_hcp_arg_get ( fpc_hcp_packet_t packet,
fpc_hcp_arg_t  arg 
)

Get Argument with specified key.

Parameters
[in]packetThe packet to operate on.
[in]argThe arg to retrieve.
Returns
Pointer to fpc_hcp_arg_data_t is successful, otherwise NULL.

Definition at line 173 of file fpc_hcp.c.

References fpc_hcp_arg_data::arg, fpc_hcp_packet::arguments, and fpc_hcp_packet::num_args.

void fpc_hcp_free ( fpc_com_chain_t chain,
fpc_hcp_packet_t packet 
)

Frees the resources held by the packet i.e. the dynamic data held in the arguments.

Parameters
[in]chainPointer to the communication chain used to retrieve the packet.
[in]packetPointer to packet.

Definition at line 198 of file fpc_hcp.c.

References fpc_hcp_arg_data::arg, ARG_NONE, fpc_com_chain::argument_free, fpc_hcp_packet::arguments, CMD_NONE, fpc_com_chain::context, fpc_hcp_packet::id, and fpc_hcp_packet::num_args.

uint16_t fpc_hcp_get_size ( fpc_hcp_packet_t packet,
uint16_t *  num_args 
)

Calculate serialized packet size.

Parameters
[in]packetPacket to calculate.
[in,out]num_argsWill return number of arguments held by the command can be set to NULL.
Returns
Serialized size.

Definition at line 64 of file fpc_hcp.c.

References fpc_hcp_arg_data::arg, ARG_NONE, ARGUMENT_HEADER_SIZE, fpc_hcp_packet::arguments, fpc_hcp_packet::num_args, PACKET_HEADER_SIZE, and fpc_hcp_arg_data::size.

fpc_com_result_t fpc_hcp_receive ( fpc_hcp_packet_t packet,
fpc_com_chain_t chain 
)

Receives an application packet through the supplied transmit chain.

Parameters
[in,out]packetPointer to pre-allocated packet struct.
[in]chainThe chain to use.
Returns
fpc_com_result_t

Definition at line 117 of file fpc_hcp.c.

References fpc_com_chain::app_mtu_buffer, fpc_com_chain::app_mtu_size, FPC_COM_CHAIN_RX, FPC_COM_RESULT_INVALID_ARGUMENT, fpc_com_chain_private::hcp_packet, fpc_com_chain::initialized, fpc_com_chain::link_overhead_get, fpc_com_chain::phy_mtu_buffer, fpc_com_chain::phy_mtu_size, fpc_com_chain::private_vars, recieve_chunks(), and fpc_com_chain::tsp_overhead_get.

Here is the call graph for this function:

fpc_com_result_t fpc_hcp_transmit ( fpc_hcp_packet_t packet,
fpc_com_chain_t chain 
)

Transmits an application packet through the supplied transmit chain.

Parameters
[in]packetApplication packet to send.
[in]chainThe chain to use.
Returns
fpc_com_result_t

Definition at line 89 of file fpc_hcp.c.

References fpc_com_chain::app_mtu_buffer, fpc_com_chain::app_mtu_size, FPC_COM_CHAIN_TX, FPC_COM_RESULT_INVALID_ARGUMENT, fpc_com_chain_private::hcp_packet, fpc_com_chain::initialized, fpc_com_chain::link_overhead_get, fpc_com_chain::phy_mtu_buffer, fpc_com_chain::phy_mtu_size, fpc_com_chain::private_vars, transmit_chunks(), and fpc_com_chain::tsp_overhead_get.

Here is the call graph for this function: