@@ -126,60 +126,59 @@ void bacnet_basic_task_object_timer_set(unsigned long milliseconds)
126126#if defined(CONFIG_BACNETSTACK_BACNET_SETTINGS )
127127void bacnet_basic_settings_restore (void )
128128{
129- /* use MAX_INSTANCE for our internal device data location */
130- const uint32_t object_instance = BACNET_MAX_INSTANCE ;
131- const BACNET_OBJECT_TYPE object_type = OBJECT_DEVICE ;
132- BACNET_CHARACTER_STRING char_string = { 0 };
133- char name [BACNET_STORAGE_VALUE_SIZE_MAX + 1 ] = { 0 };
134- BACNET_UNSIGNED_INTEGER value_unsigned = 0 ;
135- BACNET_UNSIGNED_INTEGER default_unsigned = 0 ;
136- const char * default_name ;
137- const char * default_reinit_password = "" ;
138- uint32_t array_index = BACNET_ARRAY_ALL ;
139- int rc ;
129+ /* use MAX_INSTANCE for our internal device data location */
130+ const uint32_t object_instance = BACNET_MAX_INSTANCE ;
131+ const BACNET_OBJECT_TYPE object_type = OBJECT_DEVICE ;
132+ BACNET_CHARACTER_STRING char_string = { 0 };
133+ char name [BACNET_STORAGE_VALUE_SIZE_MAX + 1 ] = { 0 };
134+ BACNET_UNSIGNED_INTEGER value_unsigned = 0 ;
135+ BACNET_UNSIGNED_INTEGER default_unsigned = 0 ;
136+ const char * default_name ;
137+ const char * default_reinit_password = "" ;
138+ uint32_t array_index = BACNET_ARRAY_ALL ;
139+ int rc ;
140140
141- /* Set the device object name from non-volatile or default */
142- default_name = Device_Object_Name_ANSI ();
143- rc = bacnet_settings_characterstring_get (object_type , object_instance ,
144- PROP_OBJECT_NAME , array_index ,
145- default_name , & char_string );
146- if (rc < 1 ) {
147- LOG_INF ("The Device object-name was not stored."
148- " Using default \"%s\"" ,
149- default_name );
150- }
151- Device_Set_Object_Name (& char_string );
152- /* Set the device reinitialize password from non-volatile or default */
153- /* Note: doesn't have a standard property enumeration, use vendor range */
154- rc = bacnet_settings_string_get (object_type , object_instance , 512 ,
155- array_index , default_reinit_password , name ,
156- sizeof (name ));
157- if (rc < 0 ) {
158- LOG_INF ("The ReinitializeDevice Password was not stored."
159- " Using default \"%s\"" ,
160- name );
161- }
162- Device_Reinitialize_Password_Set (name );
163- /* Set the device object instance from non-volatile or use a default */
164- rc = bacnet_settings_unsigned_get (object_type , object_instance ,
165- PROP_OBJECT_IDENTIFIER , array_index ,
166- BACNET_MAX_INSTANCE , & value_unsigned );
167- if (rc < 0 ) {
168- LOG_INF ("The device instance was not stored. Using default %lu." ,
169- (unsigned long )value_unsigned );
170- }
171- Device_Set_Object_Instance_Number (value_unsigned );
172- /* Set the device object instance from non-volatile or use a default */
173- default_unsigned = Device_Database_Revision ();
174- rc = bacnet_settings_unsigned_get (object_type , object_instance ,
175- PROP_DATABASE_REVISION , array_index , 0UL ,
176- & value_unsigned );
177- if (rc < 0 ) {
178- LOG_INF (
179- "The device database-revision is not readable. Using default %lu." ,
180- (unsigned long )value_unsigned );
181- }
182- Device_Set_Database_Revision (value_unsigned );
141+ /* Set the device object name from non-volatile or default */
142+ default_name = Device_Object_Name_ANSI ();
143+ rc = bacnet_settings_characterstring_get (object_type , object_instance ,
144+ PROP_OBJECT_NAME , array_index ,
145+ default_name , & char_string );
146+ if (rc < 1 ) {
147+ LOG_INF ("The Device object-name was not stored."
148+ " Using default \"%s\"" ,
149+ default_name );
150+ }
151+ Device_Set_Object_Name (& char_string );
152+ /* Set the device reinitialize password from non-volatile or default */
153+ /* Note: doesn't have a standard property enumeration, use vendor range */
154+ rc = bacnet_settings_string_get (object_type , object_instance , 512 ,
155+ array_index , default_reinit_password ,
156+ name , sizeof (name ));
157+ if (rc < 0 ) {
158+ LOG_INF ("The ReinitializeDevice Password was not stored."
159+ " Using default \"%s\"" ,
160+ name );
161+ }
162+ Device_Reinitialize_Password_Set (name );
163+ /* Set the device object instance from non-volatile or use a default */
164+ rc = bacnet_settings_unsigned_get (object_type , object_instance ,
165+ PROP_OBJECT_IDENTIFIER , array_index ,
166+ BACNET_MAX_INSTANCE , & value_unsigned );
167+ if (rc < 0 ) {
168+ LOG_INF ("The device instance was not stored. Using default %lu." ,
169+ (unsigned long )value_unsigned );
170+ }
171+ Device_Set_Object_Instance_Number (value_unsigned );
172+ /* Set the device object instance from non-volatile or use a default */
173+ default_unsigned = Device_Database_Revision ();
174+ rc = bacnet_settings_unsigned_get (object_type , object_instance ,
175+ PROP_DATABASE_REVISION , array_index ,
176+ 0UL , & value_unsigned );
177+ if (rc < 0 ) {
178+ LOG_INF ("The device database-revision is not readable. Using default %lu." ,
179+ (unsigned long )value_unsigned );
180+ }
181+ Device_Set_Database_Revision (value_unsigned );
183182}
184183#endif
185184
@@ -193,19 +192,21 @@ void bacnet_basic_settings_restore(void)
193192 * @param application_data - pointer to the data
194193 * @param application_data_len - length of the data
195194*/
196- void bacnet_basic_settings_store (BACNET_OBJECT_TYPE object_type , uint32_t object_instance ,
197- BACNET_PROPERTY_ID object_property ,
198- BACNET_ARRAY_INDEX array_index ,
199- uint8_t * application_data , int application_data_len )
195+ void bacnet_basic_settings_store (BACNET_OBJECT_TYPE object_type ,
196+ uint32_t object_instance ,
197+ BACNET_PROPERTY_ID object_property ,
198+ BACNET_ARRAY_INDEX array_index ,
199+ uint8_t * application_data ,
200+ int application_data_len )
200201{
201- BACNET_STORAGE_KEY key = { 0 };
202+ BACNET_STORAGE_KEY key = { 0 };
202203
203- LOG_INF ("WriteProperty data store" );
204- /* create the key */
205- bacnet_storage_key_init (& key , object_type , object_instance , object_property ,
206- array_index );
207- /* store the data */
208- (void )bacnet_storage_set (& key , application_data , application_data_len );
204+ LOG_INF ("WriteProperty data store" );
205+ /* create the key */
206+ bacnet_storage_key_init (& key , object_type , object_instance ,
207+ object_property , array_index );
208+ /* store the data */
209+ (void )bacnet_storage_set (& key , application_data , application_data_len );
209210}
210211#endif
211212
@@ -233,10 +234,11 @@ bool bacnet_basic_write_property_store(BACNET_WRITE_PROPERTY_DATA *wp_data)
233234 } else {
234235 array_index = wp_data -> array_index ;
235236 }
236- bacnet_basic_settings_store (wp_data -> object_type , wp_data -> object_instance ,
237- wp_data -> object_property , array_index ,
238- wp_data -> application_data ,
239- wp_data -> application_data_len );
237+ bacnet_basic_settings_store (wp_data -> object_type ,
238+ wp_data -> object_instance ,
239+ wp_data -> object_property , array_index ,
240+ wp_data -> application_data ,
241+ wp_data -> application_data_len );
240242
241243 return true;
242244}
@@ -298,7 +300,6 @@ void bacnet_basic_init(void)
298300#if defined(CONFIG_BACNETSTACK_BACNET_SETTINGS )
299301 bacnet_basic_settings_restore ();
300302#endif
301-
302303}
303304
304305/* local buffer for incoming PDUs to process */
0 commit comments