e_drone for python / Examples / Pairing
Modified : 2018.7.6
페어링 변경 후 변경된 정보 확인
from time import sleep
from e_drone.drone import *
from e_drone.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_drone.drone import *
from e_drone.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_drone for python
- Intro
- System
- Protocol
- Drone
- Examples - Ping
- Examples - Information
- Examples - Pairing
- Examples - Control
- Examples - Sensor
- Examples - Motor
- Examples - Setup
- Examples - Buzzer
- Examples - Vibrator
- Examples - Light
- Examples - Display
- Examples - Input
- Examples - Error