Hi Daniel,
Thanks for helping.

2016-12-22 20:09 GMT+01:00 Daniel Wagner <wagi@monom.org>:
Hi Thomas,

On 12/22/2016 10:40 AM, Thomas Baron wrote:
I'm using connman (1.33) on a raspberry pi 3B to connect to a hidden
wifi. While this is working fine there is an strange behavior here :
 after the connection is established (using wpa_supplicant), few seconds
after connman switch to another AP which is broadcasting the same SSID
(actually there are several AP on the same network at that place). Once
this second connection is made connman stays connected properly.
The WiFi configuration is set on /var/lib/connman/wifi.config (with
Hidden = true on the relevant service_wifi).

Long time I looked into the roaming part. Let's see if I can help you here.

Is this only for hidden networks or do observe this also for normal networks?
This is happening only for hidden networks.

Extract of the relevant logs is below :

Dec 22 08:00:22 connmand[424]: Connection Manager version 1.33
connmand[424]: Adding configuration wifi
connmand[424]: Adding service configuration wifi_2458
[...]
systemd[1]: Started WPA supplicant.
connmand[424]: wlan0 {update} flags 36931 <UP,RUNNING>
wpa_supplicant[443]: wlan0: Trying to associate with 40:18:b1:0b:65:15
(SSID='name_of_the_ssid' freq=2437 MHz)
wpa_supplicant[443]: wlan0: Associated with 40:18:b1:0b:65:15
wpa_supplicant[443]: wlan0: WPA: Key negotiation completed with
40:18:b1:0b:65:15 [PTK=CCMP GTK=TKIP]
wpa_supplicant[443]: wlan0: CTRL-EVENT-CONNECTED - Connection to
40:18:b1:0b:65:15 completed [id=0 id_str=]
connmand[424]: wlan0 {update} flags 102467 <UP,RUNNING,LOWER_UP>
Dec 22 08:00:25  connmand[424]: ntp: time slew -0.215447 s
[...] (nothing here related to either connman or wpa_supplicant)
Dec 22 08:00:29 wpa_supplicant[443]: wlan0: Trying to associate with
00:19:77:3a:d1:54 (SSID='name_of_the_ssid' freq=2462 MHz)
connmand[424]: wlan0 {RX} 239 packets 79003 bytes
connmand[424]: Probably roaming right now! Staying connected...
wpa_supplicant[443]: wlan0: Associated with 00:19:77:3a:d1:54
wpa_supplicant[443]: wlan0: WPA: Key negotiation completed with
00:19:77:3a:d1:54 [PTK=CCMP GTK=TKIP]
wpa_supplicant[443]: wlan0: CTRL-EVENT-CONNECTED - Connection to
00:19:77:3a:d1:54 completed [id=0 id_str=]
connmand[424]: wlan0 {update} flags 102467 <UP,RUNNING,LOWER_UP>

Regarding the signal strengh with iwlist : Quality=36/70  Signal
level=-74 dBm for 40:18:B1:0B:65:15 and Quality=46/70  Signal level=-64
dBm for 00:19:77:3A:D1:54

So is it an expected behavior ?If yes why and is it connman,
wpa_supplicant or the AP which take the decision to switch AP ?

The roaming decission are taken by wpa_supplicant. ConnMan just tries to follow up. As you can see, we try to figure from the "Propably roaming..." message that wpa_supplicant is doing something. The states transitions exposed by wpa_supplicant are not complete and sometimes we just need to guess.

Is there
a way to force connman to stay on the first AP and only switch if it
doesn't catch the signal anymore ?

You might want to enable the wpa_supplicant debug features and see if there is some pointers what's going on. Also make sure you use a bleeding edge version of wpa_supplicant (e.g. compile the git version)
Thanks, I will enable the wpa_supplicant debug options. As it is used in our prod environnement I'm using the raspbian stable wpa_supplicant at the moment (v2.3) but I will try the latest available to see if it helps.

cheers,
daniel

Thanks,
Thomas