Skip to content

Commit

Permalink
Worked around known issue in early 10.2 OS builds whereby event_data can
Browse files Browse the repository at this point in the history
be null as opposed to a pointer to a null string. This is expected to
change so the workaround is temporary. Also know ignoring false errno 16
gatt connect failures. Removed Thumbs.db file from SmsMessageService.
  • Loading branch information
Martin Woolley committed Aug 9, 2013
1 parent d267277 commit d4644ec
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions HeartMonitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).

* **V1.0.0** - Initial release
* **V1.0.1** - OS Version support for Device Software **10.1.***
* **V1.0.3** - Workaround for problem caused by NULL event_data in early 10.2 builds. Ignore false GATT connect errno 16 errors.

**Dependencies**

Expand Down
2 changes: 1 addition & 1 deletion HeartMonitor/assets/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ TabbedPane {
}
Label {
id: lblHeading_version
text: qsTr("V1.0.1")
text: qsTr("V1.0.3")
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
}
Expand Down
31 changes: 30 additions & 1 deletion HeartMonitor/src/BluetoothHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,14 @@ void btEvent(const int event, const char *bt_addr, const char *event_data) {
Q_UNUSED(bt_addr)

QString event_name = btEventName(event);
QString event_data_str = QString(*event_data);
qDebug() << "XXXX BT event_name=" << event_name;

if (event_data != NULL) {
QString event_data_str = QString(*event_data);
qDebug() << "XXXX BT event_data=" << event_data_str;
} else {
qDebug() << "XXXX BT event_data=NULL";
}
}

void notifications_cb(int instance, uint16_t handle, const uint8_t *val, uint16_t len, void *userData) {
Expand Down Expand Up @@ -189,6 +196,11 @@ void gatt_service_connected(const char *bdaddr, const char *service, int instanc

qDebug() << "YYYY gatt_service_connected";

uint8_t* ONE;
ONE = (uint8_t*) malloc(sizeof(uint8_t));
memset(ONE, 1, sizeof(uint8_t));


QString bdaddr_str = QString(bdaddr);
QString service_str = QString(service);

Expand All @@ -199,6 +211,8 @@ void gatt_service_connected(const char *bdaddr, const char *service, int instanc
if (rc != 0) {
qDebug() << "YYYY bt_gatt_reg_notifications errno=" << errno;
qDebug() << "YYYY bt_gatt_reg_notifications errno=" << strerror(errno);
Utilities::alert("bt_gatt_reg_notifications errno=" + QString::number(errno));
return;
} else {
qDebug() << "YYYY bt_gatt_reg_notifications was presumably OK";
}
Expand All @@ -212,8 +226,12 @@ void gatt_service_connected(const char *bdaddr, const char *service, int instanc
return;
}

qDebug() << "YYYY Allocated memory for notifications";

int num_characteristics = bt_gatt_characteristics_count(instance);

qDebug() << "YYYY # characteristics=" << num_characteristics;

if (num_characteristics > -1) {
qDebug() << QString("YYYY # characteristics: %1").arg(num_characteristics);
bt_gatt_characteristic_t *characteristicList;
Expand Down Expand Up @@ -250,6 +268,12 @@ void gatt_service_connected(const char *bdaddr, const char *service, int instanc
qDebug() << "YYYY bt_gatt_enable_notify errno=" << strerror(errno);
} else {
qDebug() << "YYYY bt_gatt_enable_notify was presumably OK";
qDebug() << "YYYY updating client characteristic config to switch on notifications on the HRM";
if (bt_gatt_write_value_noresp(instance, characteristicList[i].handle, 0, ONE, sizeof(ONE)) == EOK) {
qDebug() << "YYYY notifications config written successfully";
} else {
qDebug() << "YYYY notifications config write error - errno=(" << errno << ") :" << strerror(errno);
}
}
qDebug() << "YYYY rc from registering for heart_rate_measurement notification=" << rc;

Expand All @@ -266,6 +290,7 @@ void gatt_service_connected(const char *bdaddr, const char *service, int instanc
/* END WORKAROUND */

qDebug() << "YYYY done registering for heart_rate_measurement notifications";

}
}

Expand Down Expand Up @@ -355,6 +380,10 @@ void BluetoothHandler::receiveHrNotifications() {

if (bt_gatt_connect_service(device_addr.toAscii().constData(), HR_SERVICE_UUID, NULL, &conParm, this) < 0) {
qDebug() << "YYYY GATT connect service request failed: " + QString::number(errno) + " (" + QString(strerror(errno)) + ")";
// there's a known issue where sometimes we get ERRNO=EBUSY (16) when this is not the case and we've connected to the service OK. So for now we ignore this errno value.
if (errno != 16) {
Utilities::alert("GATT connect service request failed: " + QString::number(errno));
}
} else {
qDebug() << "YYYY requested connection to HR service OK";
}
Expand Down
Binary file removed SmsMessageService/Thumbs.db
Binary file not shown.

0 comments on commit d4644ec

Please sign in to comment.