A027 Station Mode with Raspberry-Can’t Establish Socket Connection With Access Point—solved

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #13641
    Quark Elec
    Keymaster

      Objective:

      Connect A027 (in station mode) to Raspberry Pi Access Point

      Overview:

      My A027 works fine in adhoc mode. I have reconfigured it in an attempt to send the AIS/GPS data wirelessly to a Raspberry Pi (RPi) access point (AP) located on the other side of the boat. I have verified that the RPi functions as an AP insofar as I can connect to it wirelessly from another device and display the data sent to it (the RPi) via TCP port 2000. In station mode, the A027 connects (sort of) to the RPi AP but no socket gets established and none of its (the A027’s) AIS/GPS data is ever seen by the RPi AP.

      AIS/GPS data can be observed coming out of the A027’s USB port.


      A027 Station Mode Configuration:

      Working mode: Station

      SSID: vixen_ap

      Password: vixen_31

      IP Address: 192.168.4.10 (note: Config tool would not allow this field to be left empty, so I don’t see how DHCP could assign the A027 an IP address)

      Gateway: 192.168.4.1 (note: Config tool would not allow this field to be left empty, as seen in the Station Mode documentation.)

      NetMask: 255.255.255.0

      Port: 2000


      RPi (hostname vixenpi) /var/log/syslog output when A027 is powered on:

      Dec 26 18:16:18 vixenpi hostapd: wlan0: STA 84:0d:8e:ae:c6:06 IEEE 802.11: disassociated

      Dec 26 18:16:18 vixenpi hostapd: wlan0: STA 84:0d:8e:ae:c6:06 IEEE 802.11: associated

      Dec 26 18:16:18 vixenpi hostapd: wlan0: STA 84:0d:8e:ae:c6:06 IEEE 802.11: disassociated

      Dec 26 18:16:21 vixenpi hostapd: wlan0: STA 84:0d:8e:ae:c6:06 IEEE 802.11: associated

      Dec 26 18:16:21 vixenpi hostapd: wlan0: STA 84:0d:8e:ae:c6:06 RADIUS: starting accounting session 92B2B69E7028CFE5

      Dec 26 18:16:21 vixenpi hostapd: wlan0: STA 84:0d:8e:ae:c6:06 WPA: pairwise key handshake completed (RSN)

      Note: 84:0d:8e:ae:c6:06 is the A027’s MAC address.


      Simple listener program running on the RPi AP (perhaps too much information):

      #!/usr/bin/env python

      import socket

      TCP_HOST =”

      TCP_PORT = 2000

      tcp_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # TCP

      tcp_sock.bind((TCP_HOST, TCP_PORT))

      tcp_sock.listen(1)

      tcp_conn, addr = tcp_sock.accept()

      print ‘Connected by’, addr

      tcp_data = tcp_conn.recv(1024)

      print ‘from simulated Quark: ‘, tcp_data

      tcp_conn.close()


      When this program runs on the RPi AP, netstat shows port 2000 listening for a connection.

      pi@vixenpi:~ $ netstat -a |grep 2000

      tcp 0 0 0.0.0.0:2000 0.0.0.0:* LISTEN

      pi@vixenpi:~ $


      But, the A027 does not connect to it, even after cycling its power while port 2000 is listening on the RPi AP.


      A simple client program running on another host is able to establish a socket on port 2000 and send a message.

      Here’s the output on the RPi AP when a simple client program sends a short message on a socket associated with port 2000:

      pi@vixenpi:~ $ ./pyserver.py

      Connected by (‘192.168.4.2’, 47572)

      from simulated Quark: Hello, world

      pi@vixenpi:~ $


      Here’s the simple client program that simulated the A027 and sent “Hello, world”:

      bob@bob-OptiPlex-580:~/Desktop$ cat pyclient.py

      #!/usr/bin/env python

      import socket

      HOST = ‘192.168.4.1’ #IP address of the RPi AP

      PORT = 2000

      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

      s.connect((HOST, PORT))

      s.sendall(‘Hello, world’)


      hostapd.conf on the RPi AP:

      pi@vixenpi:~ $ cat /etc/hostapd/hostapd.conf

      interface=wlan0

      driver=nl80211

      ssid=vixen_ap

      hw_mode=g

      channel=7

      wmm_enabled=0

      macaddr_acl=0

      auth_algs=1

      ignore_broadcast_ssid=0

      wpa=2

      wpa_passphrase=vixen_31

      wpa_key_mgmt=WPA-PSK

      wpa_pairwise=TKIP

      rsn_pairwise=CCMP


      The A027’s static IP address (192.168.4.10) lies outside the range of IP addresses assigned by the RPi AP’s DHCP service.

      pi@vixenpi:~ $ cat /etc/dnsmasq.conf

      interface=wlan0

      dhcp-range=192.168.4.2,192.168.4.5,255.255.255.0,24h


      In Summary:

      1) The A027 appears to see the RPi AP and establishes a (partial?) connection with it.

      2) “WPA: pairwise key handshake completed (RSN)” seems to indicate that the password validation is successful when the A027 is powered on and the RPi AP is running.

      3) No socket gets established on a listening port 2000 (on the RPi AP) when the A027 is powered on.

      4) My simple server app (pyserver.py – which creates the listening port 2000) seems adequate to receive data from the A027, but it doesn’t because no socket gets established.

      5) It seems the A027 cannot be assigned, via DHCP, an IP address from a router because the Config utility will not allow the IP Address field to be left blank. This probably isn’t relevant to my problem.

      Any insight into any of my observations/approach is much appreciated.

      I’ve searched for, and read, the forum posts with the word “station” but didn’t see anything that helped.

      Cheers and TIA,

      –Bob M

      #14704
      Quark Elec
      Keymaster

        I stupidly assumed that the A027 would start to function as a client when put in station mode.

        I can connect the RPi to the A027 and, with a client program running on the RPi, establish a socket connection and receive the AIS/GPS data. Woohoo.

        Sorry if I wasted anyone’s time or bandwidth.

        Cheers,

        –Bob M

        #14705
        Quark Elec
        Keymaster

          Your attempts to connect in station mode only prove that your A027, like my A026, do not work as a WiFi client.

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.