Skip to content

Jira 791: Sketch crash using both Firmata and BLE library, git #377 #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions libraries/CurieBLE/src/BLEDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ class BLEDevice
*/
BLEDevice(const BLEDevice* bledevice);
BLEDevice(const BLEDevice& bledevice);
/**
* @brief The BLE device constructure
*
* @param[in] bleaddress BLE device address
*
* @return none
*
* @note none
*/
BLEDevice(const bt_addr_le_t* bleaddress);
virtual ~BLEDevice();


Expand Down Expand Up @@ -653,16 +663,6 @@ class BLEDevice
void setAddress(const bt_addr_le_t& addr);

void setAdvertiseData(const uint8_t* adv_data, uint8_t len);
/**
* @brief The BLE device constructure
*
* @param[in] bleaddress BLE device address
*
* @return none
*
* @note none
*/
BLEDevice(const bt_addr_le_t* bleaddress);
private:
void preCheckProfile();

Expand Down
37 changes: 1 addition & 36 deletions libraries/CurieBLE/src/BLEPeripheral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,67 +55,37 @@ BLEPeripheral::~BLEPeripheral(void)

void BLEPeripheral::setAdvertisedServiceUuid(const char* advertisedServiceUuid)
{
if (!_initCalled) {
init();
}

BLE.setAdvertisedServiceUuid(advertisedServiceUuid);
}

void BLEPeripheral::setLocalName(const char* localName)
{
if (!_initCalled) {
init();
}

BLE.setLocalName(localName);
}


void BLEPeripheral::setDeviceName(const char *deviceName)
{
if (!_initCalled) {
init();
}

BLE.setDeviceName(deviceName);
}

void BLEPeripheral::setAppearance(const unsigned short appearance)
{
if (!_initCalled) {
init();
}

BLE.setAppearance(appearance);
}

void BLEPeripheral::setConnectionInterval(const unsigned short minConnInterval, const unsigned short maxConnInterval)
{
if (!_initCalled) {
init();
}

BLE.setConnectionInterval(minConnInterval, maxConnInterval);
}

void BLEPeripheral::addAttribute(BLEService& service)
{
if (!_initCalled)
{
init();
}

BLE.addService(service);
_lastService = &service;
}

void BLEPeripheral::addAttribute(BLECharacteristic& characteristic)
{
if (!_initCalled)
{
init();
}

if (_lastService)
{
_lastService->addCharacteristic(characteristic);
Expand All @@ -125,11 +95,6 @@ void BLEPeripheral::addAttribute(BLECharacteristic& characteristic)

void BLEPeripheral::addAttribute(BLEDescriptor& descriptor)
{
if (!_initCalled)
{
init();
}

if (_lastCharacteristic)
{
_lastCharacteristic->addDescriptor(descriptor);
Expand Down
12 changes: 8 additions & 4 deletions libraries/CurieBLE/src/internal/BLEDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ BLEDeviceManager::~BLEDeviceManager()

bool BLEDeviceManager::begin(BLEDevice *device)
{
if (NULL == _local_ble && false == *device)
if (NULL == _local_ble)
{
_local_ble = device;
_local_ble->setAddress(_local_bda);
bt_le_set_mac_address(_local_bda);

// Set device name
setDeviceName();
_state = BLE_PERIPH_STATE_READY;
Expand Down Expand Up @@ -133,7 +133,8 @@ void BLEDeviceManager::poll()
}

void BLEDeviceManager::end()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this empty function? Will it be implemented soon?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, Erik. Did talk to Liang about this issue.

The BLEDeviceManager class is a singleton. It is not expected to go away. However, it can end its operation and that's where end() can come in to tidy up its allocated resources. This will be done in the next release as part of the BLE performance improvement. Just create a Jira ticket #839 to track this task.

{}
{
}

bool BLEDeviceManager::connected(const BLEDevice *device) const
{
Expand Down Expand Up @@ -287,7 +288,10 @@ void BLEDeviceManager::setDeviceName(const char* deviceName)
if (len > BLE_MAX_DEVICE_NAME)
len = BLE_MAX_DEVICE_NAME;
memcpy(_device_name, deviceName, len);
setDeviceName();
if (NULL != _local_ble)
{
setDeviceName();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/CurieBLE/src/internal/BLEProfileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "BLECallbacks.h"
#include "BLEUtils.h"

BLEDevice BLE;
BLEDevice BLE(BLEUtils::bleGetLoalAddress());

BLEProfileManager* BLEProfileManager::_instance = NULL;

Expand Down