From 9f855fca16e225e7fd1ee80a4f0aecb7f7b90519 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Mon, 15 Jul 2013 18:22:13 +0200 Subject: [PATCH] Check Bluetooth address before trying to set it --- PS3USB.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/PS3USB.cpp b/PS3USB.cpp index 7bbcfd9d..8882c92c 100644 --- a/PS3USB.cpp +++ b/PS3USB.cpp @@ -183,8 +183,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { #endif PS3NavigationConnected = true; } - /* Set internal bluetooth address and request for data */ - setBdaddr(my_bdaddr); + /* Set internal Bluetooth address and request for data */ enable_sixaxis(); setLedOn(LED1); @@ -199,20 +198,25 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { Notify(PSTR("\r\nMotion Controller Connected"), 0x80); #endif PS3MoveConnected = true; - setMoveBdaddr(my_bdaddr); // Set internal bluetooth address moveSetBulb(Red); writeBuf[0] = 0x02; // Set report ID, this is needed for Move commands to work } + if (my_bdaddr[0] != 0x00 || my_bdaddr[1] != 0x00 || my_bdaddr[2] != 0x00 || my_bdaddr[3] != 0x00 || my_bdaddr[4] != 0x00 || my_bdaddr[5] != 0x00) { + if (PS3MoveConnected) + setMoveBdaddr(my_bdaddr); // Set internal Bluetooth address + else + setBdaddr(my_bdaddr); // Set internal Bluetooth address #ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80); - for (int8_t i = 5; i > 0; i--) { - D_PrintHex (my_bdaddr[i], 0x80); - Notify(PSTR(":"), 0x80); - } - D_PrintHex (my_bdaddr[0], 0x80); + Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80); + for (int8_t i = 5; i > 0; i--) { + D_PrintHex (my_bdaddr[i], 0x80); + Notify(PSTR(":"), 0x80); + } + D_PrintHex (my_bdaddr[0], 0x80); #endif + } bPollEnable = true; Notify(PSTR("\r\n"), 0x80);