#ifndef BOARDLINK_IOT_H
#define BOARDLINK_IOT_H
#ifndef PLATFORM_CPU
#define BL_IOT_MSG_TAGS     ("BLNLINK")
#define BL_MAX_MSG          (1024)
#define ETH_ALEN            (6)

typedef enum
{
    MSG_IN_DISCOVERY_MODE   = 0,
    MSG_OUT_DISCOVERY_MODE,
    MSG_GET_WLAN_INFO,
    MSG_BYPASS_MODE,
} BL_IOT_MSG_TYPE;

#pragma pack (push)
#pragma pack (1)
typedef struct
{
    unsigned char   msgTags[8];
    unsigned char   dstMac[ETH_ALEN];
    unsigned char   msgType;
    unsigned int    msglen;
    unsigned char   msgData[BL_MAX_MSG];
} BL_IOT_MSG, *PBL_IOT_MSG;

typedef struct
{
    unsigned char   channel;
    unsigned char   dev_mac[ETH_ALEN];
    unsigned char   bssid[ETH_ALEN];
    unsigned char   ssid[32];
} WL_INFO, *PWL_INFO;
#pragma pack (pop)

#define BL_IOT_MSG_LEN(len) (sizeof(BL_IOT_MSG) - BL_MAX_MSG + len)

typedef void (*BlMsgCb)(PBL_IOT_MSG pMsg);

int BL_Init(BlMsgCb cbOnMsg);
int BL_SendBLMsg(BL_IOT_MSG_TYPE msgType, unsigned char* pData, unsigned int len);
int BL_SendBLMsgTo(BL_IOT_MSG_TYPE msgType, unsigned char* pData, unsigned int len, unsigned char dstMac[ETH_ALEN]);
#endif
#endif
