nsresult StartStopGonkBluetooth(bool aShouldEnable) { bool result; // Platform specific check for gonk until object is divided in // different implementations per platform. Linux doesn't require // bluetooth firmware loading, but code should work otherwise. if (!EnsureBluetoothInit()) { NS_ERROR("Failed to load bluedroid library.\n"); return NS_ERROR_FAILURE; } // return 1 if it's enabled, 0 if it's disabled, and -1 on error int isEnabled = IsBluetoothEnabled(); if ((isEnabled == 1 && aShouldEnable) || (isEnabled == 0 && !aShouldEnable)) { result = true; } else if (isEnabled < 0) { result = false; } else if (aShouldEnable) { result = (EnableBluetooth() == 0) ? true : false; } else { result = (DisableBluetooth() == 0) ? true : false; } if (!result) { NS_WARNING("Could not set gonk bluetooth firmware!"); return NS_ERROR_FAILURE; } return NS_OK; }
bool InitializeBluetooth() { #ifdef WIN32 return true; #else // Set up SPI1 // Enable bluetooth chip //EnableBluetooth(); // Attempt to communicate with the bluetooth chip, fail if we can't // Configure the chip, and put it to sleep DisableBluetooth(); return FALSE; #endif }