#include "bsp_bt.h"
#include "bsp_ml307.h"
#include "bsp_flash.h"
#include "rtdef.h"


valve_data_t valve_t[MAX_VALVE_NUM];

int BSP_BT_Init(void)
{
    rt_uint8_t num  = Flash_Get_Valve_Num();
    rt_uint8_t mac_buf[FLASH_VALVE_MAC_ADDR_LEN] = {0};
    if (num != 0)
    {
        for (size_t i = 0; i < MAX_VALVE_NUM; i++)
        {
            valve_t[i].valve_id = i;
            if (Flash_Get_Mac_Addr(valve_t[i].valve_mac, i) == RT_EOK)
            {
                rt_memcpy(valve_t[i].valve_mac, mac_buf, 6);
            }
        }
    }
    else
    {
        for (size_t i = 0; i < MAX_VALVE_NUM; i++)
        {
            rt_memset(&valve_t[i], 0, sizeof(valve_data_t));
        }
    }
    return RT_EOK;
}
INIT_PREV_EXPORT(BSP_BT_Init);
