#include <net.h>
#include <net_serial_private.h>
#include <transport.h>

void net_serial_on_received(const struct transport_event *const t_ev,
    const struct net_event *const n_ev)
{
    static struct peer
    {
        int dummy;
    } peer;

    switch (t_ev->common.type)
    {
        case TRANSPORT_EVENT_TYPE_CONNECT:
            if (n_ev->connected)
                n_ev->connected(&peer, n_ev->arg);

            break;

        case TRANSPORT_EVENT_TYPE_DISCONNECT:
            if (n_ev->disconnected)
                n_ev->disconnected(&peer, n_ev->arg);

            break;

        case TRANSPORT_EVENT_TYPE_DATA:
            if (n_ev->received)
            {
                const struct transport_event_data *const d = &t_ev->u.data;

                n_ev->received(&peer, d->buf, d->n, n_ev->arg);
            }

            break;
    }
}
