Added BACnet Zigbee Link Layer (#1052)
This commit is contained in:
@@ -119,6 +119,45 @@ struct vmac_data *VMAC_Find_By_Key(uint32_t device_id)
|
||||
return Keylist_Data(VMAC_List, device_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a VMAC in the list by seeking the list index
|
||||
*
|
||||
* @param index - Index that shall be returned
|
||||
* @param device_id - BACnet device object instance number
|
||||
*
|
||||
* @return true if the device_id and vmac are found
|
||||
*/
|
||||
bool VMAC_Entry_By_Index(int index, uint32_t *device_id, struct vmac_data *vmac)
|
||||
{
|
||||
bool status = false;
|
||||
struct vmac_data *data;
|
||||
KEY key = 0;
|
||||
uint8_t i;
|
||||
|
||||
data = Keylist_Data_Index(VMAC_List, index);
|
||||
if (data) {
|
||||
/* virtual MAC is the Device ID */
|
||||
status = Keylist_Index_Key(VMAC_List, index, &key);
|
||||
if (status) {
|
||||
if (device_id) {
|
||||
*device_id = key;
|
||||
}
|
||||
if (vmac) {
|
||||
for (i = 0; i < sizeof(vmac->mac); i++) {
|
||||
if (i < data->mac_len) {
|
||||
vmac->mac[i] = data->mac[i];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
vmac->mac_len = data->mac_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/** Compare the VMAC address
|
||||
*
|
||||
* @param vmac1 - VMAC address that will be compared to vmac2
|
||||
|
||||
@@ -35,6 +35,9 @@ unsigned int VMAC_Count(void);
|
||||
BACNET_STACK_EXPORT
|
||||
struct vmac_data *VMAC_Find_By_Key(uint32_t device_id);
|
||||
BACNET_STACK_EXPORT
|
||||
bool VMAC_Entry_By_Index(
|
||||
int index, uint32_t *device_id, struct vmac_data *vmac);
|
||||
BACNET_STACK_EXPORT
|
||||
bool VMAC_Find_By_Data(const struct vmac_data *vmac, uint32_t *device_id);
|
||||
BACNET_STACK_EXPORT
|
||||
bool VMAC_Add(uint32_t device_id, const struct vmac_data *pVMAC);
|
||||
|
||||
@@ -85,6 +85,10 @@ struct ethernet_port {
|
||||
uint8_t MAC_Address[6];
|
||||
};
|
||||
|
||||
struct bacnet_zigbee_port {
|
||||
uint8_t MAC_Address[3];
|
||||
};
|
||||
|
||||
struct mstp_port {
|
||||
uint8_t MAC_Address;
|
||||
uint8_t Max_Master;
|
||||
@@ -114,6 +118,7 @@ struct object_data {
|
||||
struct bacnet_ipv4_port IPv4;
|
||||
struct bacnet_ipv6_port IPv6;
|
||||
struct ethernet_port Ethernet;
|
||||
struct bacnet_zigbee_port Zigbee;
|
||||
struct mstp_port MSTP;
|
||||
struct bsc_port BSC;
|
||||
} Network;
|
||||
@@ -163,6 +168,20 @@ static const int Ethernet_Port_Properties_Optional[] = {
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Zigbee_Port_Properties_Optional[] = {
|
||||
/* unordered list of optional properties */
|
||||
PROP_DESCRIPTION,
|
||||
PROP_MAC_ADDRESS,
|
||||
PROP_VIRTUAL_MAC_ADDRESS_TABLE,
|
||||
#if (BACNET_PROTOCOL_REVISION >= 24)
|
||||
PROP_APDU_LENGTH,
|
||||
PROP_NETWORK_NUMBER,
|
||||
PROP_NETWORK_NUMBER_QUALITY,
|
||||
PROP_LINK_SPEED,
|
||||
#endif
|
||||
-1
|
||||
};
|
||||
|
||||
static const int MSTP_Port_Properties_Optional[] = {
|
||||
/* unordered list of optional properties */
|
||||
PROP_DESCRIPTION,
|
||||
@@ -224,6 +243,7 @@ static const int BIP6_Port_Properties_Optional[] = {
|
||||
PROP_IPV6_DEFAULT_GATEWAY,
|
||||
PROP_BACNET_IPV6_MULTICAST_ADDRESS,
|
||||
PROP_IPV6_DNS_SERVER,
|
||||
PROP_VIRTUAL_MAC_ADDRESS_TABLE,
|
||||
#if defined(BACDL_BIP6) && (BACNET_NETWORK_PORT_IP_DHCP_ENABLED)
|
||||
PROP_IPV6_AUTO_ADDRESSING_ENABLE,
|
||||
PROP_IPV6_DHCP_LEASE_TIME,
|
||||
@@ -337,6 +357,9 @@ void Network_Port_Property_List(
|
||||
case PORT_TYPE_BIP6:
|
||||
*pOptional = BIP6_Port_Properties_Optional;
|
||||
break;
|
||||
case PORT_TYPE_ZIGBEE:
|
||||
*pOptional = Zigbee_Port_Properties_Optional;
|
||||
break;
|
||||
case PORT_TYPE_ETHERNET:
|
||||
default:
|
||||
*pOptional = Ethernet_Port_Properties_Optional;
|
||||
@@ -857,6 +880,10 @@ uint8_t Network_Port_MAC_Address_Value(
|
||||
mac_len =
|
||||
sizeof(Object_List[index].Network.Ethernet.MAC_Address);
|
||||
break;
|
||||
case PORT_TYPE_ZIGBEE:
|
||||
mac = &Object_List[index].Network.Zigbee.MAC_Address[0];
|
||||
mac_len = sizeof(Object_List[index].Network.Zigbee.MAC_Address);
|
||||
break;
|
||||
case PORT_TYPE_MSTP:
|
||||
mac = &Object_List[index].Network.MSTP.MAC_Address;
|
||||
mac_len = sizeof(Object_List[index].Network.MSTP.MAC_Address);
|
||||
@@ -941,6 +968,11 @@ bool Network_Port_MAC_Address_Set(
|
||||
mac_size =
|
||||
sizeof(Object_List[index].Network.Ethernet.MAC_Address);
|
||||
break;
|
||||
case PORT_TYPE_ZIGBEE:
|
||||
mac_dest = &Object_List[index].Network.Zigbee.MAC_Address[0];
|
||||
mac_size =
|
||||
sizeof(Object_List[index].Network.Zigbee.MAC_Address);
|
||||
break;
|
||||
case PORT_TYPE_MSTP:
|
||||
mac_dest = &Object_List[index].Network.MSTP.MAC_Address;
|
||||
mac_size = sizeof(Object_List[index].Network.MSTP.MAC_Address);
|
||||
@@ -3909,6 +3941,35 @@ bool Network_Port_MSTP_Max_Info_Frames_Set(
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Encode a Calendar entity list complex data type
|
||||
*
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param apdu - the APDU buffer
|
||||
* @param apdu_size - size of the apdu buffer.
|
||||
*
|
||||
* @return bytes encoded or zero on error.
|
||||
*/
|
||||
static int Network_Port_Virtual_MAC_Table_Encode(
|
||||
uint32_t object_instance, uint8_t *apdu, int max_apdu)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
unsigned index = 0;
|
||||
|
||||
(void)apdu;
|
||||
(void)max_apdu;
|
||||
index = Network_Port_Instance_To_Index(object_instance);
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
/* fixme: add abstraction to get the BACnetLIST */
|
||||
} else if (Object_List[index].Network_Type == PORT_TYPE_ZIGBEE) {
|
||||
/* fixme: add abstraction to get the BACnetLIST */
|
||||
}
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* ReadProperty handler for this object. For the given ReadProperty
|
||||
* data, the application_data is loaded or the error flags are set.
|
||||
@@ -4190,6 +4251,11 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
case PROP_VIRTUAL_MAC_ADDRESS_TABLE:
|
||||
/* BACnetLIST of BACnetVMACEntry */
|
||||
apdu_len = Network_Port_Virtual_MAC_Table_Encode(
|
||||
rpdata->object_instance, apdu, apdu_size);
|
||||
break;
|
||||
#ifdef BACDL_BSC
|
||||
case PROP_MAX_BVLC_LENGTH_ACCEPTED:
|
||||
apdu_len = encode_application_unsigned(
|
||||
|
||||
Reference in New Issue
Block a user