NAO ロボットを ALConnectionManager を使用して新しい Wi-Fi ネットワークに接続したいので、Web ページを使用する必要はありません。Web ページをクリックするよりも、Python API を使用する方が優れています...
1 に答える
1
これが私が見つけた方法です。完全にスマートではありませんが、2.xxバージョンでは正常に動作します...
def connect(strSsid, strPassword):
print( "INF: trying to connect to '%s', with some password..." % (strSsid) )
self.cm = naoqi.ALProxy( "ALConnectionManager")
self.cm.scan();
aS = self.cm.services();
bFound = False;
for s in aS:
print( "\nService: %s" % s )
strServiceID = None;
for attr in s:
attrName, attrValue = attr;
if( attrName == "ServiceId" ):
strServiceID = attrValue;
if( attrName == "Name" and attrValue == strSsid ): # ASSUME, serviceID always set before Name
assert( strServiceID != None );
print( "INF: Good found the right wifi, ServiceID: '%s'\n" % strServiceID )
bFound = True;
break;
if( bFound ):
break;
# for each services - end
if( bFound ):
# real connection
aServiceInput = [];
aServiceInput.append( ["ServiceId", strServiceID ] );
aServiceInput.append( ["Passphrase", strPassword ] );
aServiceInput.append( ["PrivateKeyPassphrase", strPassword ] ); # don't know wich one is usefull!
# aServiceInput.append( ["Favorite", True ] ); # not working
print( "DBG: ServiceInput: %s" % aServiceInput )
retVal = self.cm.setServiceInput( aServiceInput );
print( "DBG: setServiceInput return: %s" % str(retVal) )
retVal = self.cm.connect( strServiceID );
print( "DBG: connect return: %s" % str(retVal) )
于 2015-05-13T10:31:41.090 に答える