Called by the µC/HTTP-client core when the form table is formatted to be sent.
Each HTTPc_KEY_VAL_EXT
objects contained in a table form must have set up a hook function pointer with the parameter OnValTx
. The HTTPc transmit buffer pointer and the length available inside are passed as argument to allow the hook function to copy the data value directly inside the HTTPc buffer.
Prototype
Code Block |
---|
CPU_BOOLEAN HTTPc_FormKeyValExtHook (HTTPc_CONN_OBJ *p_conn_obj,
HTTPc_REQ_OBJ *p_req_obj,
HTTPc_KEY_VAL_EXT *p_key_val_obj,
CPU_CHAR *p_buf,
CPU_INT16U buf_len,
CPU_INT16U *p_len_wr); |
Arguments
p_conn_obj
Pointer to the current HTTPc Connection Object.
p_req_obj
Pointer to the current HTTPc Request Object.
p_key_val_obj
Pointer to the Key-Value Extended object.
p_buf
Pointer to transmit buffer.
buf_len
Length available inside the transmit buffer.
p_len_wr
Data length actually written inside the buffer by the hook function.
Return Values
DEF_YES
, if all the data have been written to the buffer.
DEF_NO
, otherwise
Required Configuration
None.
Notes / Warnings
None.
Example Template
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
CPU_CHAR HTTPc_AppBuf[512];
static CPU_BOOLEAN HTTPc_FormKeyValExtHook (HTTPc_CONN_OBJ *p_conn_obj,
HTTPc_REQ_OBJ *p_req_obj,
HTTPc_KEY_VAL_EXT *p_key_val_obj,
CPU_CHAR *p_buf,
CPU_INT16U buf_len,
CPU_INT16U *p_len_wr);
{
HTTPc_KEY_VAL_EXT *p_field;
CPU_CHAR *p_data;
CPU_INT16U min_len;
static CPU_INT16U data_ix;
p_data = &HTTPc_AppBuf[data_ix];
min_len = DEF_MIN(buf_len, (p_key_val_obj->ValLen - data_ix));
if (min_len <= 0) {
data_ix = 0;
*p_len_wr = min_len;
return (DEF_YES);
}
Str_Copy_N(p_buf, p_data, min_len);
*p_len_wr = min_len;
data_ix += min_len;
return (DEF_NO);
} |
Info |
---|
This code uses a variable declared as static for example purpose. It cannot work if multiple connections call the same hook function. In that case, the |