Move event handling from global variable to handle

- remove global event function pointer
- add event function pointer to handle structure
- add handle parameter to register functions
- move all register functions to mbus-protocol-aux.c
This commit is contained in:
Stefan Wahren
2013-10-13 21:49:40 +02:00
parent 9e23818152
commit 0cf57bfc35
6 changed files with 53 additions and 60 deletions

View File

@ -26,12 +26,6 @@ static char error_str[512];
//------------------------------------------------------------------------------
static mbus_slave_data slave_data[MBUS_MAX_PRIMARY_SLAVES];
//
// init event callback
//
void (*_mbus_recv_event)(unsigned char src_type, const char *buff, size_t len) = NULL;
void (*_mbus_send_event)(unsigned char src_type, const char *buff, size_t len) = NULL;
//
// trace callbacks
//
@ -47,24 +41,6 @@ mbus_dump_send_event(unsigned char src_type, const char *buff, size_t len)
mbus_hex_dump("SEND", buff, len);
}
//------------------------------------------------------------------------------
/// Register a function for receive events.
//------------------------------------------------------------------------------
void
mbus_register_recv_event(void (*event)(unsigned char src_type, const char *buff, size_t len))
{
_mbus_recv_event = event;
}
//------------------------------------------------------------------------------
/// Register a function for send events.
//------------------------------------------------------------------------------
void
mbus_register_send_event(void (*event)(unsigned char src_type, const char *buff, size_t len))
{
_mbus_send_event = event;
}
//------------------------------------------------------------------------------
/// Return a string that contains an the latest error message.
//------------------------------------------------------------------------------