How to change Anafi wifi band to 5 GHz?

Hello.
I want to change wifi band of Anafi to 5Ghz.
How to change wifi band of Anafi to 5Ghz?

I use tp-link Archer T9UH to connect to ANAFI.
This wifi dongle(T9UH) supports dual band(2.4GHz and 5GHz).

OS is ubuntu 20.04.

I use olympe.messages.wifi.set_ap_channel() function but it won’t go well.

My code is like bellow.

    #connect to drone
    DRONE_IP_ADDRESS='192.168.42.1'
    DRONE_IP1=os.environ.get('DRONE_IP1', DRONE_IP_ADDRESS)
    drone1 = olympe.Drone(DRONE_IP1)
    drone1.connect()

    #set environment to indoor
    drone1(set_environment(environment=0)).wait()

    #set country to JAPAN
    drone1(set_country(selection_mode=0, code='JP')).wait()

    #check available band and channels
    drone1(update_authorized_channels()).wait()
    dict=drone1.get_state(authorized_channel)
    for key, val in dict.items():
        print(key, val)

    #change wifi band to 5ghz (channel is 40)
    drone1(set_ap_channel(type=3, band=1, channel=40)).wait()
    drone1.disconnect()

After running the above code, I check available wifi list by ‘nmcli dev wifi’ in terminal.

And the result of running the above code is not always same. (I don’t know why.)
I listed the all results I’ve ever had.

RESULT 1
ANAFI wifi SSID does not appear in available wifi list anymore.

RESULT 2
ANAFI wifi SSID appears as I specfied in the above code(5Ghz, 40 channel) and show up in available wifi list but is not able to connect to PC(wifi dongle).
ANAFI wifi SSID eventually disappear in 10~30 seconds.

RESULT 3 (this is what i want)
Correctly change to 5Ghz(40 channel) and connect to PC(wifi dongle).

I want to know how to change correctly ANAFI wifi band to 5ghz using Olympe.

Thanks.

Hello,

After the set_country command you should probably wait a few seconds (3 to 5 seconds) for the drone WiFi modem to correctly reconfigure itself before trying to change the WiFi channels.

1 Like

Thank you for your reply.

I tried to wait max 10 seconds but changing anafi wifi band to 5GHz didn’t go well.

I tried following codes.

    #before running this code, 
    #I set country_code to 'FR'(France) to check if my code works well.
    print(drone1.get_state(country_changed)['code'])# --> 'FR'
    
    exp_cnt=drone1(
        set_country(selection_mode=0, code='JP', _timeout=10)
        >> country_changed(selection_mode=0, code='JP', _timeout=10)
    ).wait()
    print(exp_cnt.success())# --> False
    print(exp_cnt.timedout())# --> True

    print(drone1.get_state(country_changed)['code'])# --> 'JP'

It seems setting country_code to ‘JP’ is successful, even if success() returns False and timedout() returns True.

I also waits 60 seconds for setting channel(set_ap_channel() method)

    chan_exp=drone1(
        set_ap_channel(type=3, band=1, channel=40, _timeout=60)
        >> ap_channel_changed(type=3, band=1, channel=40, _timeout=60)
    ).wait()
    print('chan_timedout:', chan_exp.timedout())# -->False
    print('chan_success', chan_exp.success()) # -->False

It didn’t go well.

Maybe, nothing changed from first post.

Is there anything else I should try?

Thanks.

I tried to change Anafi wifi band to 5ghz using the code below but it didn’t go well.
The result of the code is same as the first post.
(I realize same thing happens to switching to 2.4GHz)

The point I can’t understand is why sometimes my drone switches to 5Ghz and sometimes not under SAME CONDITION.

I’ve also tried hard reset(by pressing battery button) and factory reset(by using
olympe.messages.common.Factory.Reset).

Have someone ever succeeded in switching Anafi wifi band to 5GHz using olympe?
Are there any bugs or problems in set_ap_channel() method?

I need your help please…!!

def main():
    #connect to drone
    DRONE_IP_ADDRESS='192.168.42.1'
    DRONE_IP1=os.environ.get('DRONE_IP1', DRONE_IP_ADDRESS)
    drone1 = olympe.Drone(DRONE_IP1)
    drone1.connect()

    #set environment to 'indoor'
    drone1(set_environment(environment=0, _timeout=10)).wait()

    #set country to JAPAN.
    drone1(
        set_country(selection_mode=0, code='JP', _timeout=10)
        >> country_changed(selection_mode=0, code='JP', _timeout=10)
    ).wait()

    #change wifi band to 5ghz
    drone1(
        set_ap_channel(type=3, band=1, channel=40, _timeout=60)
        >> ap_channel_changed(type=3, band=1, channel=40, _timeout=60)
    ).wait()

    drone1.disconnect()
    

if __name__=='__main__':
    main()

The output(couldn’t switch to 5GHz) is below.
For reason of character limit, I truncated very first part of the output.

2022-07-19 13:38:55,374 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - gimbal.relative_attitude_bounds(gimbal_id=0, min_yaw=0.0, max_yaw=0.0, min_pitch=-135.0, max_pitch=105.0, min_roll=-38.0, max_roll=38.0, list_flags='')
2022-07-19 13:38:55,375 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - gimbal.absolute_attitude_bounds(gimbal_id=0, min_yaw=0.0, max_yaw=0.0, min_pitch=-90.0, max_pitch=90.0, min_roll=0.0, max_roll=0.0, list_flags='')
2022-07-19 13:38:55,375 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - gimbal.max_speed(gimbal_id=0, min_bound_yaw=0.0, max_bound_yaw=0.0, current_yaw=0.0, min_bound_pitch=0.0, max_bound_pitch=180.0, current_pitch=30.0, min_bound_roll=0.0, max_bound_roll=180.0, current_roll=30.0, list_flags='')
2022-07-19 13:38:55,376 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - camera.max_zoom_speed(cam_id=0, min=0.0, max=10.0, current=0.2345000058412552, list_flags='')
2022-07-19 13:38:55,377 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - camera.zoom_velocity_quality_degradation(cam_id=0, allowed=1, list_flags='')
2022-07-19 13:38:55,378 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - gimbal.calibration_state(state='required', gimbal_id=0, list_flags='')
2022-07-19 13:38:55,379 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - gimbal.offsets(gimbal_id=0, update_state='inactive', min_bound_yaw=0.0, max_bound_yaw=0.0, current_yaw=0.0, min_bound_pitch=-5.0, max_bound_pitch=5.0, current_pitch=0.0, min_bound_roll=-5.0, max_bound_roll=5.0, current_roll=0.0, list_flags='')
2022-07-19 13:38:55,379 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - camera.autorecord(cam_id=0, state='active', list_flags='')
2022-07-19 13:38:55,380 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - dri.dri_state(mode='disabled')
2022-07-19 13:38:55,380 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - rth.ending_hovering_altitude(current=2.0, min=1.0, max=10.0)
2022-07-19 13:38:55,380 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - ardrone3.SettingsState.ProductGPSVersionChanged(software='3.01R', hardware='')
2022-07-19 13:38:55,381 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - common.SettingsState.AllSettingsChanged()
2022-07-19 13:38:55,383 [INFO] 	olympe.drone.ANAFI-L105158 - _send_command_impl - mission.custom_msg_enable() has been sent to the device
2022-07-19 13:38:55,445 [INFO] 	olympe.drone.ANAFI-L105158 - _on_connected - <olympe.arsdkng.cmd_itf.ConnectedEvent object at 0x7f6669c73700>
2022-07-19 13:38:55,447 [INFO] 	olympe.pdraw.ANAFI-L105158 - _create_pomp_loop - Creating pomp loop
2022-07-19 13:38:55,448 [INFO] 	olympe.pdraw.ANAFI-L105158 - _create_pomp_loop - Creating pomp loop
2022-07-19 13:38:55,451 [INFO] 	olympe.drone.ANAFI-L105158 - _send_command_impl - wifi.set_environment(environment=0) has been sent to the device
2022-07-19 13:38:55,583 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.environment_changed(environment='indoor')
2022-07-19 13:38:55,734 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.country_changed(selection_mode='manual', code='FR')
2022-07-19 13:38:55,913 [WARNING] 	olympe.media - _get_all_media - HTTP 541: http://192.168.42.1:80/api/v1/media/medias b'Media Not Yet Indexed'
2022-07-19 13:38:56,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-33)
2022-07-19 13:38:56,914 [WARNING] 	olympe.media - _get_all_media - HTTP 541: http://192.168.42.1:80/api/v1/media/medias b'Media Not Yet Indexed'
2022-07-19 13:38:57,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-35)
2022-07-19 13:38:57,914 [ERROR] 	olympe.media - _get_all_media - The webserver is unavailable
2022-07-19 13:38:57,915 [WARNING] 	olympe.media - aconnect - Media are not yet indexed
2022-07-19 13:38:58,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-31)
2022-07-19 13:38:59,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-37)
2022-07-19 13:38:59,873 [INFO] 	olympe.drone.ANAFI-L105158 - _link_quality_cb - Link quality: tx=55, rx=100, rx_useful=98
2022-07-19 13:39:00,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-31)
2022-07-19 13:39:01,755 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-28)
2022-07-19 13:39:02,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-30)
2022-07-19 13:39:03,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-34)
2022-07-19 13:39:04,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-30)
2022-07-19 13:39:04,873 [INFO] 	olympe.drone.ANAFI-L105158 - _link_quality_cb - Link quality: tx=-1, rx=100, rx_useful=100
2022-07-19 13:39:05,462 [INFO] 	olympe.drone.ANAFI-L105158 - _send_command_impl - wifi.set_country(selection_mode=0, code='JP') has been sent to the device
2022-07-19 13:39:05,483 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.environment_changed(environment='indoor')
2022-07-19 13:39:05,631 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.country_changed(selection_mode='manual', code='JP')
2022-07-19 13:39:05,782 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-29)
2022-07-19 13:39:09,873 [INFO] 	olympe.drone.ANAFI-L105158 - _link_quality_cb - Link quality: tx=50, rx=100, rx_useful=100
2022-07-19 13:39:09,927 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-34)
2022-07-19 13:39:10,067 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=0)
2022-07-19 13:39:11,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-32)
2022-07-19 13:39:12,755 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-34)
2022-07-19 13:39:13,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-33)
2022-07-19 13:39:14,754 [INFO] 	olympe.drone.ANAFI-L105158 - _recv_cmd_cb - wifi.rssi_changed(rssi=-35)
2022-07-19 13:39:14,873 [INFO] 	olympe.drone.ANAFI-L105158 - _link_quality_cb - Link quality: tx=-1, rx=100, rx_useful=93
2022-07-19 13:39:15,479 [INFO] 	olympe.drone.ANAFI-L105158 - _send_command_impl - wifi.set_ap_channel(type=3, band=1, channel=40) has been sent to the device
2022-07-19 13:39:19,873 [INFO] 	olympe.drone.ANAFI-L105158 - _link_quality_cb - Link quality: tx=50, rx=100, rx_useful=100
2022-07-19 13:39:22,490 [ERROR] 	ulog - pomp - read(fd=26) err=110(Connection timed out)
2022-07-19 13:39:22,492 [INFO] 	olympe.media - _websocket_event_reader - websocket closed
2022-07-19 13:39:23,491 [ERROR] 	ulog - arsdk - net Too many ping failures
2022-07-19 13:39:23,492 [INFO] 	olympe.drone.ANAFI-L105158 - _link_status_cb - Link status: 0
2022-07-19 13:39:23,494 [INFO] 	olympe.pdraw.ANAFI-L105158 - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-5
2022-07-19 13:39:23,595 [INFO] 	olympe.pdraw.ANAFI-L105158 - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-4
2022-07-19 13:39:23,597 [INFO] 	olympe.drone.ANAFI-L105158 - _disconnected_cb - Disconnected from device: ANAFI-L105158
2022-07-19 13:39:23,607 [INFO] 	olympe.drone.ANAFI-L105158 - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7f6669c26c10>
2022-07-19 13:39:23,614 [INFO] 	olympe.drone.ANAFI-L105158 - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7f6669c26580>
2022-07-19 13:39:23,616 [INFO] 	olympe.drone.ANAFI-L105158 - disconnect - Disconnection with the device OK. IP: b'192.168.42.1'
2022-07-19 13:39:23,648 [INFO] 	olympe.drone.ANAFI-L105158 - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7f6669c26eb0>
2022-07-19 13:39:23,649 [INFO] 	olympe.media - _shutdown - olympe.media shutdown
2022-07-19 13:39:23,650 [INFO] 	olympe.scheduler - _destroy_pomp_loop - Pomp loop has been destroyed: subscribers_thread
2022-07-19 13:39:23,951 [INFO] 	olympe.media - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-3
2022-07-19 13:39:23,952 [INFO] 	olympe.backend - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-2

P.S.
I will be offline for 4~5 days. (sorry)

Hello,

The issue comes from the fact that “set environment to ‘indoor’” does not work with the Qualcomm wlan chip that we use. Indoor/outdoor is a kernel module option for this chip, it is a setting that is set at the time the kernel module is loaded. On Anafi it is always set to outdoor, so the wlan chip does not accept to start an AP on an indoor only channel.
Sorry, but with country JP you will not be able to use the 5GHz band on Anafi.

Thanks,
-Thierry

1 Like

Thank you for answering my question.

After removing set_environment() method from my code,
I made it to change wifi channel(2.4 GHz band).

I don’t know it is technically possible or not but I hope set_environment() method would work in a future update.

Thank you.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.