- add new type for context options
- add new function mbus_context_set_option to set context specific options like retransmission or echo cancelation
This commit is contained in:
parent
a266c96a2f
commit
9b94df16b9
@ -1485,6 +1485,38 @@ mbus_disconnect(mbus_handle * handle)
|
|||||||
return handle->close(handle);
|
return handle->close(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
mbus_context_set_option(mbus_handle * handle, mbus_context_option option, long value)
|
||||||
|
{
|
||||||
|
if (handle == NULL)
|
||||||
|
{
|
||||||
|
MBUS_ERROR("%s: Invalid M-Bus handle to set option.\n", __PRETTY_FUNCTION__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (option)
|
||||||
|
{
|
||||||
|
case MBUS_OPTION_MAX_RETRY:
|
||||||
|
if ((value >= 0) && (value <= 9))
|
||||||
|
{
|
||||||
|
handle->max_retry = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MBUS_OPTION_PURGE_FIRST_FRAME:
|
||||||
|
if ((value == MBUS_FRAME_PURGE_NONE) ||
|
||||||
|
(value == MBUS_FRAME_PURGE_M2S) ||
|
||||||
|
(value == MBUS_FRAME_PURGE_S2M))
|
||||||
|
{
|
||||||
|
handle->purge_first_frame = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1; // unable to set option
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mbus_recv_frame(mbus_handle * handle, mbus_frame *frame)
|
mbus_recv_frame(mbus_handle * handle, mbus_frame *frame)
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
* or
|
* or
|
||||||
* mbus_handle = mbus_context_tcp(host, port);
|
* mbus_handle = mbus_context_tcp(host, port);
|
||||||
*
|
*
|
||||||
|
* mbus_context_set_option(mbus_handle,option,value); // optional
|
||||||
|
*
|
||||||
* mbus_connect(mbus_handle);
|
* mbus_connect(mbus_handle);
|
||||||
*
|
*
|
||||||
* ...
|
* ...
|
||||||
@ -136,6 +138,15 @@ typedef struct _mbus_record {
|
|||||||
char *quantity; /**< Quantity type (e.g. Energy) */
|
char *quantity; /**< Quantity type (e.g. Energy) */
|
||||||
} mbus_record;
|
} mbus_record;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MBus handle option type
|
||||||
|
*/
|
||||||
|
enum _mbus_context_option {
|
||||||
|
MBUS_OPTION_MAX_RETRY,
|
||||||
|
MBUS_OPTION_PURGE_FIRST_FRAME
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum _mbus_context_option mbus_context_option;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event callback functions
|
* Event callback functions
|
||||||
@ -194,6 +205,17 @@ int mbus_connect(mbus_handle * handle);
|
|||||||
*/
|
*/
|
||||||
int mbus_disconnect(mbus_handle * handle);
|
int mbus_disconnect(mbus_handle * handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set option of a M-Bus context.
|
||||||
|
*
|
||||||
|
* @param handle Initialized handle
|
||||||
|
* @param option option to set
|
||||||
|
* @param value value to set
|
||||||
|
*
|
||||||
|
* @return Zero when successful.
|
||||||
|
*/
|
||||||
|
int mbus_context_set_option(mbus_handle * handle, mbus_context_option option, long value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives a frame using "unified" handle
|
* Receives a frame using "unified" handle
|
||||||
*
|
*
|
||||||
@ -436,10 +458,10 @@ int mbus_scan_2nd_address_range(mbus_handle * handle, int pos, char *addr_mask);
|
|||||||
/**
|
/**
|
||||||
* Convert a buffer with hex values into a buffer with binary values.
|
* Convert a buffer with hex values into a buffer with binary values.
|
||||||
*
|
*
|
||||||
* @param src_buff source buffer with hex values
|
* @param dst destination buffer with binary values
|
||||||
* @param src_len byte count of source buffer
|
* @param dst_len byte count of destination buffer
|
||||||
* @param dest_buff destination buffer with binary values
|
* @param src source buffer with hex values
|
||||||
* @param dest_len byte count of destination buffer
|
* @param src_len byte count of source buffer
|
||||||
*
|
*
|
||||||
* @return byte count of successful converted values
|
* @return byte count of successful converted values
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user