01-21-2013 12:13 PM
Im having problems trying to adapt the Cascades "BluetootoothSPPChat example(on Blackberry gitHub). to scan for bluetooth low energy devices. My current road block in trying to adopt instructions from JAM 21 session code descriptions to the Cascade example is the following:
bt_le_callbacks_t le_callbacks = {
.advert = le_advertisement_cb
};
But the compiler is complaining about syntax so I split in up to the following:
bt_le_callbacks_t le_callbacks;
le_callbacks.advert = le_advertisement_cb;
But the compiler is complaining about mismatching return types.
I have the imports:
#include <btapi/btdevice.h>
#include <btapi/btle.h>
and a skeletal function definition for le_advertisement_cb:
void le_advertisement_cb(const char *bdaddr, const char *data, int len, void *userData){
}
Any help would be much appreciated.
Solved! Go to Solution.
01-23-2013 02:18 AM
Hi rbork,
I am also working with BT LE, and I think I passed this roadblock. Try this:
#include <QDebug>
#include <btapi/btdevice.h>
#include <btapi/btgatt.h>
#include <btapi/btle.h>
#include <errno.h>
void my_advertisement_cb (const char *bdaddr, int8_t rssi, const char *data, int len, void *userData) { qDebug("Advertisement from BTAddr:%s. (Signal strength %d)", bdaddr, rssi); } /* * Note that this must be static. `bt_le_init()` does not "retain" the callbacks. */ static bt_le_callbacks_t le_callbacks = { my_advertisement_cb }; void initAndSearch() { bt_le_init(&le_callbacks); qDebug("BEGIN Scanning for device!"); int retVal = bt_le_add_scan_device(BT_LE_BDADDR_ANY, this); if (retVal != EOK) { qDebug("Couldn't start scanning for devices. Error: %d", retVal); } }
I am stuck at getting a service to connect. I'll start a new thread for that challenge ![]()
Good luck!