e_drive for python / Examples / Pairing

Modified : 2018.7.6



페어링 변경 후 변경된 정보 확인

from time import sleep

from e_drive.drone import *
from e_drive.protocol import *


if __name__ == '__main__':

    drone = Drone(False)
    drone.open("COM22")

    # 페어링 설정
    drone.sendPairing(DeviceType.Controller, 0x0005, 0x0004, 0x03)
    sleep(0.01)

    # 페어링데이터 요청
    drone.sendRequest(DeviceType.Controller, DataType.Pairing)
    
    timeStart = time.time()

    while True:
        sleep(0.01)
        dataType = drone.check()
        
        if    dataType == DataType.Pairing:
            pairing = drone.getData(DataType.Pairing)
            print("{0} / {1} / {2} / {3} / {4}".format(
                pairing.address0,
                pairing.address1,
                pairing.address2,
                pairing.scramble,
                pairing.channel))
            break;

        if time.time() > timeStart + 1:
            break;
    
    drone.close()



페어링 변경 후 변경된 정보 확인(이벤트 함수 등록)

from time import sleep

from e_drive.drone import *
from e_drive.protocol import *


def eventPairing(pairing):
    print("eventPairing()")
    print("{0} / {1} / {2} / {3} / {4}".format(
        pairing.address0,
        pairing.address1,
        pairing.address2,
        pairing.scramble,
        pairing.channel))


if __name__ == '__main__':

    drone = Drone()
    drone.open("COM22")

    # 이벤트 핸들링 함수 등록
    drone.setEventHandler(DataType.Pairing, eventPairing)

    # 페어링 설정
    drone.sendPairing(DeviceType.Controller, 0x0000, 0x0001, 0x0002, 0x03, 0x04)
    sleep(0.01)

    # 페어링데이터 요청
    drone.sendRequest(DeviceType.Controller, DataType.Pairing)
    sleep(0.1)
    
    drone.close()



e_drive for python

  1. Intro
  2. System
  3. Protocol
  4. Drone
  5. Examples - Ping
  6. Examples - Information
  7. Examples - Pairing
  8. Examples - Control
  9. Examples - Sensor
  10. Examples - Motor
  11. Examples - Setup
  12. Examples - Buzzer
  13. Examples - Vibrator
  14. Examples - Light
  15. Examples - Display
  16. Examples - Input
  17. Examples - Error


Index