I recently purchased an Mbient Lab IMU Bluetooth Sensor, and I am attempting to work through the API, following the tutorial found here.
I built the project using CMAKE in Visual Studio 2019. I created a solution file and I am struggling to begin writing code for the project. I created a solution, included the directory found in the src folder, linked the folder including the Win32 library and added it into additional dependencies in the input section in the linker. However, while following the simple tutorial seen in the first section of the code, I am receiving an error of the write_gatt_char, read_gatt_char, and enable_char_notify functions being an undeclared identifier, and I cannot find a fix.
One major difference is that the connection.h file is not present. Instead, the file with those functions is in the btle_connection.h header file in a separate folder.
The code is seen below:
#include "metawear/core/metawearboard.h"
#include "metawear/platform/btle_connection.h"
int main(int argc, char** argv)
{
MblMwBtleConnection btle_conn = {nullptr, write_gatt_char, read_gatt_char, enable_char_notify};
MblMwMetaWearBoard* board = mbl_mw_metawearboard_create(&btle_conn);
}
And I receive a C2065 error that those functions are undeclared identifiers.
Furthermore, in the btle_connectoin header file, these functions are defined in the structure seen below:
/**
* Wrapper class containing functions for communicating with the MetaWear through a Bluetooth Low Energy connection.
*/
typedef struct {
/**
* Provides the calling function the ability to pass any context specific data required
*/
void *context;
/**
* Writes the characteristic and value to the device
* @param context Pointer to the <code>context</code> field
* @param caller Object using this function pointer
* @param characteristic Gatt characteristic to write
* @param value Value to write as a byte array
* @param length Length of the byte array
*/
void (*write_gatt_char)(void *context, const void* caller, MblMwGattCharWriteType writeType, const MblMwGattChar* characteristic,
const uint8_t* value, uint8_t length);
/**
* Reads the value of the characteristic from the device
* @param context Pointer to the <code>context</code> field
* @param caller Object using this function pointer
* @param characteristic Gatt characteristic to read
* @param handler Callback function to handle the received value
*/
void (*read_gatt_char)(void *context, const void* caller, const MblMwGattChar* characteristic, MblMwFnIntVoidPtrArray handler);
/**
* Enables notifications for characeristic changes
* @param context Pointer to the <code>context</code> field
* @param caller Object using this function pointer
* @param characteristic Characteristic to enable notifications for
* @param handler Callback function for handling characteristic notifications
* @param ready Callback function to handle when the enable notify task is completed
*/
void (*enable_notifications)(void *context, const void* caller, const MblMwGattChar* characteristic, MblMwFnIntVoidPtrArray handler, MblMwFnVoidVoidPtrInt ready);
/**
* Register a handler for disconnect events
* @param context Pointer to the <code>context</code> field
* @param caller Object using this function pointer
* @param handler Handler to respond to the disconnect event
*/
void (*on_disconnect)(void *context, const void* caller, MblMwFnVoidVoidPtrInt handler);
} MblMwBtleConnection;
Any help would be greatly appreciated! Is it possible that I am linking/built it incorrectly?