#include "zigbee_port.h"
#include "app_zigbee.h"

/*
 * Markdown note:
 * - Keep STM32_WPAN / Zigbee Cluster Library calls in this adapter.
 * - Master should create/open the network and receive reports.
 * - Slave should join the network and send AppSlaveInputs_t payload.
 */

void ZigbeePort_Init(const AppZigbeeConfig_t *config, AppRole_t role)
{
    (void)config;
    (void)role;
}

void ZigbeePort_Process(void)
{
    APP_ZIGBEE_Process();
}

ZigbeePortStatus_t ZigbeePort_SendSlaveInputs(const AppSlaveInputs_t *inputs)
{
    const AppSlaveReport_t report = App_MakeSlaveReport(inputs);

    App_DebugOnSlaveReportTx(&report);

    return APP_ZIGBEE_SendSlaveReport(&report) ? ZIGBEE_PORT_OK : ZIGBEE_PORT_BUSY;
}

void ZigbeePort_OnSlaveReportReceived(const AppSlaveReport_t *report, uint32_t now_ms)
{
    App_MasterAcceptReport(report, now_ms);
}
