@@ -255,8 +255,39 @@ def test_reset_config(get_openiris_device, config):
255255
256256
257257@pytest .mark .has_capability ("wireless" )
258- def test_set_wifi (get_openiris_device , ensure_board_in_mode , config ):
259- # since we want to test actual connection to the network, let's reset the device and reboot it
258+ def test_set_wifi_no_bssid_in_payload (
259+ get_openiris_device , ensure_board_in_mode , config
260+ ):
261+ device = get_openiris_device ()
262+ reset_command = device .send_command ("reset_config" , {"section" : "all" })
263+ assert not has_command_failed (reset_command )
264+
265+ with DetectPortChange ():
266+ device .send_command ("restart_device" )
267+ time .sleep (config .SWITCH_MODE_REBOOT_TIME )
268+
269+ device = ensure_board_in_mode ("wifi" , device )
270+ params = {
271+ "name" : "main" ,
272+ "ssid" : config .WIFI_SSID ,
273+ "password" : config .WIFI_PASS ,
274+ "channel" : 0 ,
275+ "power" : 0 ,
276+ }
277+ set_wifi_result = device .send_command ("set_wifi" , params )
278+ assert not has_command_failed (set_wifi_result )
279+
280+ connect_wifi_result = device .send_command ("connect_wifi" )
281+ assert not - has_command_failed (connect_wifi_result )
282+ time .sleep (config .WIFI_CONNECTION_TIMEOUT ) # and let it try to for some time
283+
284+ wifi_status_command = device .send_command ("get_wifi_status" )
285+ assert not has_command_failed (wifi_status_command )
286+ assert wifi_status_command ["results" ][0 ]["result" ]["data" ]["status" ] == "connected"
287+
288+
289+ @pytest .mark .has_capability ("wireless" )
290+ def test_set_wifi_no_bssid (get_openiris_device , ensure_board_in_mode , config ):
260291 device = get_openiris_device ()
261292 reset_command = device .send_command ("reset_config" , {"section" : "all" })
262293 assert not has_command_failed (reset_command )
@@ -270,6 +301,7 @@ def test_set_wifi(get_openiris_device, ensure_board_in_mode, config):
270301 params = {
271302 "name" : "main" ,
272303 "ssid" : config .WIFI_SSID ,
304+ "bssid" : "" ,
273305 "password" : config .WIFI_PASS ,
274306 "channel" : 0 ,
275307 "power" : 0 ,
@@ -287,12 +319,76 @@ def test_set_wifi(get_openiris_device, ensure_board_in_mode, config):
287319 assert wifi_status_command ["results" ][0 ]["result" ]["data" ]["status" ] == "connected"
288320
289321
322+ @pytest .mark .has_capability ("wireless" )
323+ def test_set_wifi_correct_bssid (get_openiris_device , ensure_board_in_mode , config ):
324+ device = get_openiris_device ()
325+ reset_command = device .send_command ("reset_config" , {"section" : "all" })
326+ assert not has_command_failed (reset_command )
327+
328+ with DetectPortChange ():
329+ device .send_command ("restart_device" )
330+ time .sleep (config .SWITCH_MODE_REBOOT_TIME )
331+
332+ device = ensure_board_in_mode ("wifi" , device )
333+ params = {
334+ "name" : "main" ,
335+ "ssid" : config .WIFI_SSID ,
336+ "bssid" : config .WIFI_BSSID ,
337+ "password" : config .WIFI_PASS ,
338+ "channel" : 0 ,
339+ "power" : 0 ,
340+ }
341+ set_wifi_result = device .send_command ("set_wifi" , params )
342+ assert not has_command_failed (set_wifi_result )
343+
344+ connect_wifi_result = device .send_command ("connect_wifi" )
345+ assert not - has_command_failed (connect_wifi_result )
346+ time .sleep (config .WIFI_CONNECTION_TIMEOUT )
347+
348+ wifi_status_command = device .send_command ("get_wifi_status" )
349+ assert not has_command_failed (wifi_status_command )
350+ assert wifi_status_command ["results" ][0 ]["result" ]["data" ]["status" ] == "connected"
351+
352+
353+ @pytest .mark .has_capability ("wireless" )
354+ def test_set_wifi_nonexitant_bssid (get_openiris_device , ensure_board_in_mode , config ):
355+ device = get_openiris_device ()
356+ reset_command = device .send_command ("reset_config" , {"section" : "all" })
357+ assert not has_command_failed (reset_command )
358+
359+ with DetectPortChange ():
360+ device .send_command ("restart_device" )
361+ time .sleep (config .SWITCH_MODE_REBOOT_TIME )
362+
363+ device = ensure_board_in_mode ("wifi" , device )
364+ params = {
365+ "name" : "main" ,
366+ "ssid" : config .WIFI_SSID ,
367+ "bssid" : "99:99:99:99:99:99" , # a completely wrong BSSID, just to test that we fail to connect
368+ "password" : config .WIFI_PASS ,
369+ "channel" : 0 ,
370+ "power" : 0 ,
371+ }
372+
373+ set_wifi_result = device .send_command ("set_wifi" , params )
374+ assert not has_command_failed (set_wifi_result )
375+
376+ connect_wifi_result = device .send_command ("connect_wifi" )
377+ assert not - has_command_failed (connect_wifi_result )
378+ time .sleep (config .WIFI_CONNECTION_TIMEOUT )
379+
380+ wifi_status_command = device .send_command ("get_wifi_status" )
381+ assert not has_command_failed (wifi_status_command )
382+ assert wifi_status_command ["results" ][0 ]["result" ]["data" ]["status" ] == "error"
383+
384+
290385@pytest .mark .has_capability ("wireless" )
291386def test_set_wifi_invalid_network (get_openiris_device , ensure_board_in_mode , config ):
292387 device = ensure_board_in_mode ("wifi" , get_openiris_device ())
293388 params = {
294389 "name" : "main" ,
295390 "ssid" : "PleaseDontBeARealNetwork" ,
391+ "bssid" : "" ,
296392 "password" : "AndThePasswordIsFake" ,
297393 "channel" : 0 ,
298394 "power" : 0 ,
@@ -351,6 +447,7 @@ def test_update_main_wifi_network(ensure_board_in_mode, get_openiris_device, con
351447 params1 = {
352448 "name" : "main" ,
353449 "ssid" : "Nada" ,
450+ "bssid" : "" ,
354451 "password" : "Nuuh" ,
355452 "channel" : 0 ,
356453 "power" : 0 ,
@@ -377,6 +474,7 @@ def test_set_wifi_add_another_network(ensure_board_in_mode, get_openiris_device)
377474 params = {
378475 "name" : "anotherNetwork" ,
379476 "ssid" : "PleaseDontBeARealNetwork" ,
477+ "bssid" : "" ,
380478 "password" : "AndThePassowrdIsFake" ,
381479 "channel" : 0 ,
382480 "power" : 0 ,
@@ -475,6 +573,7 @@ def test_update_wifi_command(ensure_board_in_mode, get_openiris_device, payload)
475573 params = {
476574 "name" : "anotherNetwork" ,
477575 "ssid" : "PleaseDontBeARealNetwork" ,
576+ "bssid" : "" ,
478577 "password" : "AndThePasswordIsFake" ,
479578 "channel" : 0 ,
480579 "power" : 0 ,
0 commit comments