
#ifndef ETHERCAT_MASTER_HOT_CONNECT_H
#define ETHERCAT_MASTER_HOT_CONNECT_H

#pragma once

#include "../ethercat_types.h"
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef DYNAMIC_LOAD

#define EC_HOTCONNECT_MAX_GROUPS 32

typedef enum {
    EC_HOTCONNECT_UNKNOWN = -1,
    EC_HOTCONNECT_ABSENT  = 0,
    EC_HOTCONNECT_PRESENT = 1
} ec_hotconnect_status_t;

#pragma pack(push, 1)
typedef struct {
    uint16_t group_id;
    uint16_t alias_address;
    uint32_t vendor_id;
    uint32_t product_code;
    int32_t  is_present;
    uint16_t detected_slave_idx;
    uint16_t reserved;
} ec_hotconnect_group_t;
#pragma pack(pop)

int  HotConnectAddGroup(uint16_t master_index, uint16_t group_id,
                        uint16_t alias_address, uint32_t vendor_id, uint32_t product_code);

int  HotConnectRemoveGroup(uint16_t master_index, uint16_t group_id);

int  HotConnectGetGroupStatus(uint16_t master_index, uint16_t group_id);

int  HotConnectEnumerate(uint16_t master_index, ec_hotconnect_group_t* out_buf, int max);

void HotConnectClearAll(uint16_t master_index);

int  HotConnectGetGroupCount(uint16_t master_index);

#endif

#ifdef __cplusplus
}
#endif

#endif
