Updated demo port for BDK to use MAC as device ID until configured with WriteProperty.
This commit is contained in:
@@ -80,16 +80,26 @@ static bool seeprom_version_test(
|
||||
void bacnet_init(
|
||||
void)
|
||||
{
|
||||
uint32_t device_id = 0;
|
||||
|
||||
MSTP_MAC_Address = input_address();
|
||||
dlmstp_set_mac_address(MSTP_MAC_Address);
|
||||
dlmstp_init(NULL);
|
||||
|
||||
/* test for valid data structure in SEEPROM */
|
||||
if (!seeprom_version_test()) {
|
||||
/* do something when SEEPROM is invalid - i.e. init to defaults */
|
||||
}
|
||||
/* initialize objects */
|
||||
Device_Init(NULL);
|
||||
|
||||
/* Get the device ID from the eeprom */
|
||||
eeprom_bytes_read(NV_EEPROM_DEVICE_0, (uint8_t *) & device_id,
|
||||
sizeof(device_id));
|
||||
if (device_id < BACNET_MAX_INSTANCE) {
|
||||
Device_Set_Object_Instance_Number(device_id);
|
||||
} else {
|
||||
/* use the DIP switch address as the Device ID if unconfigured */
|
||||
Device_Set_Object_Instance_Number(MSTP_MAC_Address);
|
||||
}
|
||||
/* set up our confirmed service unrecognized service handler - required! */
|
||||
apdu_set_unrecognized_service_handler_handler
|
||||
(handler_unrecognized_service);
|
||||
|
||||
@@ -430,15 +430,6 @@ void Device_Init(
|
||||
pObject++;
|
||||
}
|
||||
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
|
||||
/* Get the data from the eeprom */
|
||||
eeprom_bytes_read(NV_EEPROM_DEVICE_0, (uint8_t *) & Object_Instance_Number,
|
||||
sizeof(Object_Instance_Number));
|
||||
if (Object_Instance_Number >= BACNET_MAX_INSTANCE) {
|
||||
Object_Instance_Number = 0;
|
||||
eeprom_bytes_write(NV_EEPROM_DEVICE_0,
|
||||
(uint8_t *) & Object_Instance_Number,
|
||||
sizeof(Object_Instance_Number));
|
||||
}
|
||||
}
|
||||
|
||||
/* methods to manipulate the data */
|
||||
@@ -455,9 +446,6 @@ bool Device_Set_Object_Instance_Number(
|
||||
|
||||
if (object_id <= BACNET_MAX_INSTANCE) {
|
||||
Object_Instance_Number = object_id;
|
||||
eeprom_bytes_write(NV_EEPROM_DEVICE_0,
|
||||
(uint8_t *) & Object_Instance_Number,
|
||||
sizeof(Object_Instance_Number));
|
||||
} else
|
||||
status = false;
|
||||
|
||||
@@ -865,6 +853,8 @@ bool Device_Write_Property_Local(
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(value.type.
|
||||
Object_Id.instance))) {
|
||||
eeprom_bytes_write(NV_EEPROM_DEVICE_0,
|
||||
(uint8_t *) & value.type.Object_Id.instance, 4);
|
||||
/* we could send an I-Am broadcast to let the world know */
|
||||
status = true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user