pairing
ํ์ด๋ง ๋ณ๊ฒฝ ํ ๋ณ๊ฒฝ๋ ์ ๋ณด ํ์ธ
# ์กฐ์ข
๊ธฐ์ ํ์ด๋ง ์ ๋ณด๋ฅผ ๋ณ๊ฒฝํ๊ณ , ๋ณ๊ฒฝ๋ ์ ๋ณด๋ฅผ ์์ฒญํ ํ ์๋ต์ ๊ธฐ๋ค๋ ค ์ถ๋ ฅํ๋ ์์
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
if __name__ == '__main__':
drone = Drone(False)
drone.open()
# ํ์ด๋ง ์ค์
drone.sendPairing(DeviceType.Controller, 0x0001, 0x0002, 0x0003, 0x04, 0x05)
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("Address: 0x{0:04X}{1:04X}{2:04X} / {0}.{1}.{2}".format(
pairing.address0,
pairing.address1,
pairing.address2))
print("Scramble: {0}".format(pairing.scramble))
print("Channel: {0}".format(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("Address: 0x{0:04X}{1:04X}{2:04X} / {0}.{1}.{2}".format(
pairing.address0,
pairing.address1,
pairing.address2))
print("Scramble: {0}".format(pairing.scramble))
print("Channel: {0}".format(pairing.channel))
if __name__ == '__main__':
drone = Drone()
drone.open()
# ์ด๋ฒคํธ ํธ๋ค๋ง ํจ์ ๋ฑ๋ก
drone.setEventHandler(DataType.Pairing, eventPairing)
# ํ์ด๋ง ์ค์
drone.sendPairing(DeviceType.Controller, 0x0005, 0x0006, 0x0007, 0x08, 0x09)
sleep(0.01)
# ํ์ด๋ง๋ฐ์ดํฐ ์์ฒญ
drone.sendRequest(DeviceType.Controller, DataType.Pairing)
sleep(0.1)
drone.close()
Last updated