@@ -12,7 +12,8 @@ class WirepasTLVAppConfigHelper:
12
12
13
13
This class contains methods allowing the modification (addition, removal)
14
14
of app_config data inside a Wirepas network compliant with the TLV format.
15
- It offers an abstraction
15
+ It offers an abstraction for wirepas supported feature at application level
16
+ like the local provisioning.
16
17
17
18
"""
18
19
@@ -24,9 +25,9 @@ def __init__(self, wni, network=None, gateway_sink_subset=None):
24
25
:param wni: Wirepas network interface
25
26
:type wni: :obj:`~wirepas_mqtt_library.wirepas_network_interface.WirepasNetworkInterface`
26
27
:param network: Network address concerned by the otap
27
- :param gateway_sink : list of (gateway, sink) tupple concerned by the change
28
+ :param gateway_sink_subset : list of (gateway, sink) tupple concerned by the change
28
29
29
- :note: Either network or gateway_sink must be specified
30
+ :note: Either network or gateway_sink_subset must be specified
30
31
"""
31
32
if wni is None :
32
33
raise RuntimeError ("No Wirepas Network Interface provided" )
@@ -85,6 +86,16 @@ def remove_raw_entry(self, entry):
85
86
return self
86
87
87
88
def setup_local_provisioning (self , enabled , psk_id = None , psk = None ):
89
+ """Set a new entry to enable or disable local provisioning
90
+
91
+ :param enabled: True to enable local provisioning, False to disable it
92
+ :type enabled: bool
93
+ :param psk_id: Id of the psk on 4 bytes (only valid when enabled)
94
+ :type psk_id: bytearray
95
+ :param psk: psk to use for lacal provisioning on 32 bytes (only valid when enabled)
96
+ :type psk: bytearray
97
+ :raises ValueError: if psk and psk_id are not both set or unset or with a wrong size
98
+ """
88
99
# check parameters
89
100
if psk_id is not None and psk_id .__len__ () != 4 :
90
101
raise ValueError ("psk_id must be a 4 bytes bytearray" )
@@ -109,7 +120,9 @@ def update_entries(self, override=False):
109
120
110
121
:param override: if True, if an app config is already present that doesn't
111
122
follow the TLV format, full app config is overriden with TLV format with this entry
112
- :return: True if all specified sinks are updated
123
+ :return: True if all specified sinks are updated, False otherwise.
124
+
125
+ .. warning:: If returned value is False, only a subset of sinks may be updated
113
126
"""
114
127
115
128
if self ._new_entries .__len__ () == 0 and \
@@ -177,6 +190,7 @@ def update_entries(self, override=False):
177
190
logging .info ("Check done, doing the change" )
178
191
logging .debug ("New configs are: %s" % new_configs )
179
192
193
+ res = True
180
194
for gw , sink , app_config , seq , diag in new_configs :
181
195
new_config = {}
182
196
new_config ["app_config_data" ] = app_config
@@ -187,6 +201,7 @@ def update_entries(self, override=False):
187
201
self .wni .set_sink_config (gw , sink , new_config )
188
202
except TimeoutError :
189
203
logging .error ("Issue when setting new app config to [%s][%s]" % (gw , sink ))
204
+ res = False
190
205
continue
191
206
192
207
logging .info ("New app config set for [%s][%s]" % (gw , sink ))
@@ -195,7 +210,7 @@ def update_entries(self, override=False):
195
210
self ._removed_entries = list ()
196
211
self ._new_entries = dict ()
197
212
198
- return True
213
+ return res
199
214
200
215
def __str__ (self ):
201
216
str = ""
0 commit comments