Check Bluetooth address before trying to set it

This commit is contained in:
Kristian Sloth Lauszus 2013-07-15 18:22:13 +02:00
parent 1a1c2a18d3
commit 9f855fca16

View file

@ -183,8 +183,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
#endif #endif
PS3NavigationConnected = true; PS3NavigationConnected = true;
} }
/* Set internal bluetooth address and request for data */ /* Set internal Bluetooth address and request for data */
setBdaddr(my_bdaddr);
enable_sixaxis(); enable_sixaxis();
setLedOn(LED1); setLedOn(LED1);
@ -199,11 +198,15 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
Notify(PSTR("\r\nMotion Controller Connected"), 0x80); Notify(PSTR("\r\nMotion Controller Connected"), 0x80);
#endif #endif
PS3MoveConnected = true; PS3MoveConnected = true;
setMoveBdaddr(my_bdaddr); // Set internal bluetooth address
moveSetBulb(Red); moveSetBulb(Red);
writeBuf[0] = 0x02; // Set report ID, this is needed for Move commands to work 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 #ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80); Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
@ -213,6 +216,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
} }
D_PrintHex<uint8_t > (my_bdaddr[0], 0x80); D_PrintHex<uint8_t > (my_bdaddr[0], 0x80);
#endif #endif
}
bPollEnable = true; bPollEnable = true;
Notify(PSTR("\r\n"), 0x80); Notify(PSTR("\r\n"), 0x80);