2016-07-21 7 views
1

나는 python으로 블루투스 서버로 작동하는 예제 코드를 시도하고있다. 이 코드는 오류 다음 있습니다 ..python 블루투스 오류 - _bluetooth라는 모듈 없음

역 추적 (가장 최근 통화 최종) : 파일 "은/var/lib 디렉토리/cloud9이/예/사이/RFCOMM-server_py", 7 호선, 에서 블루투스 가져 오기 * 파일에서 "/var/lib/cloud9/examples/Sa/bluetooth/초기화 .py ", 줄 43, 에서 .bluez 가져 오기 * 파일"/var/lib/cloud9/examples/Sa/bluetooth/bluez.py " _bt ImportError를 같은 수입 _bluetooth에서, 라인 6 : 나는 cloud9의 IDE에 beaglebone 녹색 무선 보드를 사용하고

_bluetooth라는 이름의 모듈

012 3,516, 는
# file: rfcomm-server.py 
    # auth: Albert Huang <[email protected]> 
    # desc: simple demonstration of a server application that uses RFCOMM sockets 
    # $Id: rfcomm-server.py 518 2007-08-10 07:20:07Z albert $ 

    from bluetooth import * 

    server_sock=BluetoothSocket(RFCOMM) 
    server_sock.bind(("",PORT_ANY)) 
    server_sock.listen(1) 

    port = server_sock.getsockname()[1] 

    uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee" 

    advertise_service(server_sock, "SampleServer", 
       service_id = uuid, 
       service_classes = [ uuid, SERIAL_PORT_CLASS ], 
       profiles = [ SERIAL_PORT_PROFILE ], 
#     protocols = [ OBEX_UUID ] 
       ) 

    print("Waiting for connection on RFCOMM channel %d" % port) 

    client_sock, client_info = server_sock.accept() 
    print("Accepted connection from ", client_info) 

try: 
while True: 
    data = client_sock.recv(1024) 
    if len(data) == 0: break 
    print("received [%s]" % data) 
except IOError: 
    pass 

    print("disconnected") 

client_sock.close() 
    server_sock.close() 
    print("all done") 

답변

0
내가 Beaglebone 녹색 무선 보드의 블루투스 설정하지 않았다

,하지만 다음 명령을 실행 한 후, 위의 코드는 완벽하게 작동 :

$ bb-wl18xx-bluetooth