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

@ -255,8 +255,8 @@ mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame)
//
// call the send event function, if the callback function is registered
//
if (_mbus_send_event)
_mbus_send_event(MBUS_HANDLE_TYPE_SERIAL, buff, len);
if (handle->send_event)
handle->send_event(MBUS_HANDLE_TYPE_SERIAL, buff, len);
}
else
{
@ -353,8 +353,8 @@ mbus_serial_recv_frame(mbus_handle *handle, mbus_frame *frame)
//
// call the receive event function, if the callback function is registered
//
if (_mbus_recv_event)
_mbus_recv_event(MBUS_HANDLE_TYPE_SERIAL, buff, len);
if (handle->recv_event)
handle->recv_event(MBUS_HANDLE_TYPE_SERIAL, buff, len);
if (remaining != 0)
{