def connect(self):
    ' Connect to the board and configure it. Note: recreates various objects upon call. '
    if (self.ip_address is None):
        raise ValueError('self.ip_address cannot be None')
    if self.log:
        print(('Init WiFi connection with IP: ' + self.ip_address))
    '\n        Docs on these HTTP requests and more are found:\n        https://app.swaggerhub.com/apis/pushtheworld/openbci-wifi-server/1.3.0\n        '
    res_board = requests.get(('http://%s/board' % self.ip_address))
    if (res_board.status_code == 200):
        board_info = res_board.json()
        if (not board_info['board_connected']):
            raise RuntimeError('No board connected to WiFi Shield. To learn how to connect to a Cyton or Ganglion visit http://docs.openbci.com/Tutorials/03-Wifi_Getting_Started_Guide')
        self.board_type = board_info['board_type']
        self.eeg_channels_per_sample = board_info['num_channels']
        if self.log:
            print(('Connected to %s with %s channels' % (self.board_type, self.eeg_channels_per_sample)))
    self.gains = None
    if (self.board_type == k.BOARD_CYTON):
        self.gains = [24, 24, 24, 24, 24, 24, 24, 24]
        self.daisy = False
    elif (self.board_type == k.BOARD_DAISY):
        self.gains = [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24]
        self.daisy = True
    elif (self.board_type == k.BOARD_GANGLION):
        self.gains = [51, 51, 51, 51]
        self.daisy = False
    self.local_wifi_server.set_daisy(daisy=self.daisy)
    self.local_wifi_server.set_parser(ParseRaw(gains=self.gains, board_type=self.board_type))
    if self.high_speed:
        output_style = 'raw'
    else:
        output_style = 'json'
    res_tcp_post = requests.post(('http://%s/tcp' % self.ip_address), json={'ip': self.local_ip_address, 'port': self.local_wifi_server_port, 'output': output_style, 'delimiter': True, 'latency': self.latency})
    if (res_tcp_post.status_code == 200):
        tcp_status = res_tcp_post.json()
        if tcp_status['connected']:
            if self.log:
                print('WiFi Shield to Python TCP Socket Established')
        else:
            raise RuntimeWarning('WiFi Shield is not able to connect to local server. Please open an issue.')
Connect to the board and configure it. Note: recreates various objects upon call.
def connect(self):
    '  '
    if (self.ip_address is None):
        raise ValueError('self.ip_address cannot be None')
    if self.log:
        print(('Init WiFi connection with IP: ' + self.ip_address))
    '\n        Docs on these HTTP requests and more are found:\n        https://app.swaggerhub.com/apis/pushtheworld/openbci-wifi-server/1.3.0\n        '
    res_board = requests.get(('http://%s/board' % self.ip_address))
    if (res_board.status_code == 200):
        board_info = res_board.json()
        if (not board_info['board_connected']):
            raise RuntimeError('No board connected to WiFi Shield. To learn how to connect to a Cyton or Ganglion visit http://docs.openbci.com/Tutorials/03-Wifi_Getting_Started_Guide')
        self.board_type = board_info['board_type']
        self.eeg_channels_per_sample = board_info['num_channels']
        if self.log:
            print(('Connected to %s with %s channels' % (self.board_type, self.eeg_channels_per_sample)))
    self.gains = None
    if (self.board_type == k.BOARD_CYTON):
        self.gains = [24, 24, 24, 24, 24, 24, 24, 24]
        self.daisy = False
    elif (self.board_type == k.BOARD_DAISY):
        self.gains = [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24]
        self.daisy = True
    elif (self.board_type == k.BOARD_GANGLION):
        self.gains = [51, 51, 51, 51]
        self.daisy = False
    self.local_wifi_server.set_daisy(daisy=self.daisy)
    self.local_wifi_server.set_parser(ParseRaw(gains=self.gains, board_type=self.board_type))
    if self.high_speed:
        output_style = 'raw'
    else:
        output_style = 'json'
    res_tcp_post = requests.post(('http://%s/tcp' % self.ip_address), json={'ip': self.local_ip_address, 'port': self.local_wifi_server_port, 'output': output_style, 'delimiter': True, 'latency': self.latency})
    if (res_tcp_post.status_code == 200):
        tcp_status = res_tcp_post.json()
        if tcp_status['connected']:
            if self.log:
                print('WiFi Shield to Python TCP Socket Established')
        else:
            raise RuntimeWarning('WiFi Shield is not able to connect to local server. Please open an issue.')