Beispiel #1
0
 def handle_getSavedNetworks(self, req):
     '''
     Get list of registered WiFi networks
     Return: CsGetSavedNetworksResponse(wifiList).  
     '''
     try:
         wifiList = NetworkFlowFacade.GetRegisteredNetworks()
         return CsGetSavedNetworksResponse(wifiList)
     except Exception as e:
         rospy.logerr('Get Saved Networks Failed, Error: {}'.format(
             str(e.message)))
Beispiel #2
0
 def handle_startHotspot(self, req):
     '''
     Call to connect to Hotspot.
     Update SSID name in config (effective for next restart.)
     :return: true
     '''
     try:
         requestPosted = NetworkFlowFacade.RequestConnectHotspot()
         return CsStartHotspotResponse(requestPosted)
     except Exception as e:
         rospy.logerr('Start Hotspot Failed, Error: {}'.format(
             str(e.message)))
Beispiel #3
0
 def handle_getCurrentConnectionName(self, req):
     '''
     get current Connection name if connected
     :return: Connection name or empty if not connected, and or error if exists.
     '''
     try:
         connectionName = NetworkFlowFacade.GetCurrentConneectionName()
         return CsGetCurrentConnectionNameResponse(connectionName)
     except Exception as e:
         rospy.logerr(
             'Get Current Connection Name Failed, Error: {}'.format(
                 str(e.message)))
Beispiel #4
0
 def handle_getNetworksList(self, req):
     '''
     Get list of existing WiFi networks
     :return: CsNetworksListResponse(lastUpdateTime, wifiList).  
     '''
     try:
         wifiList = NetworkFlowFacade.GetAvailableNetworkList()
         lastUpdateTime = None  # FIXME
         return CsNetworksListResponse(str(lastUpdateTime), wifiList)
     except Exception as e:
         rospy.logerr('Get Network List Failed, Error: {}'.format(
             str(e.message)))
         return 'Get Network List Failed, Error: {}'.format(str(e.message))
Beispiel #5
0
    def handle_connectToSavedNetwork(self, req):
        '''
        Call to connect to known SSID.
        * System post async message request which: do:
            Verify requested ssid is in registered network list.
            Update SSID name in config (effective for next restart.)
        :return: True if message posted, otherwise False.
        '''
        try:
            ssid = req.ssid

            if (ssid is None or ssid == ''):
                return CsConnectToNetworkResponse(False, 'SSID is Null.')

            requestPosted = NetworkFlowFacade.RequestConnectNetwork(ssid)
            return CsConnectToSavedNetworkResponse(
                requestPosted,
                'Operation Done. Please connct to wifi: {0}'.format(ssid))
        except Exception as e:
            rospy.logerr('Connect To Saved Network Failed, Error: {}'.format(
                str(e.message)))
            return CsConnectToSavedNetworkResponse(False, str(e.message))
Beispiel #6
0
    def handle_registerNetwork(self, req):
        '''
        Call to connect to known WiFi with ssid and password.
        request have ssid and password.
        * System post async message request which: do:
            Verify requested SSID is in the known wifi list and abort if it is not.
            * Hold current connection name.
            * Stop current ip address publishing.
            * Call to register and connect to new network.
            *** If Connectd:
                ** Update SSID name in config (effective for next restart.)
                ** Reconnect previous SSID.
                ** Restart IP Discovery sender.
                ** Response with message that restart is required. 
            *** Else
                ** Return Error message
            :return: tuple of True/ False if operation done, Message to describe process.
        '''
        try:
            rospy.logdebug('Call Network Scan')
            ssid = req.ssid
            password = req.password

            if (ssid is None or ssid == ''):
                return CsConnectToNetworkResponse(False, 'SSID is Null.')

            if (password is None):
                return CsConnectToNetworkResponse(False, 'password is Null.')

            requestPosted = NetworkFlowFacade.RequestRegisterNetwork(
                ssid, password)

            return CsConnectToNetworkResponse(
                requestPosted, 'Please connct to wifi: {0}'.format(ssid))
        except Exception as e:
            rospy.logerr('Register Network Failed, Error: {}'.format(
                str(e.message)))
            return CsConnectToNetworkResponse(False, str(e.message))
Beispiel #7
0
    def handle_scanNetworks(self, req):
        '''
        * Call for rescan of networks.
        * System post async message request which: do:
            if currently connected to Hotspot:
                *** Stop IP Discovery sender
                *** Disconnect Hotspot.
                *** Run Rescan networks
                *** Save in available networks list.
                *** Reconnect to hotspot        
            Else:
                *** Run Rescan networks
                *** Save in available networks list.
        :return: True if message posted, otherwise False. --  CsScanNetworksResponse(True / False).
        '''
        try:
            rospy.logdebug('Call Network Scan')
            requestPosted = NetworkFlowFacade.RequestNetworkRescan()

            return CsScanNetworksResponse(requestPosted)
        except Exception as e:
            rospy.logerr('Scan Networks Failed, Error: {}'.format(
                str(e.message)))
            return CsScanNetworksResponse(False)