Справка по API Mbient Lab Sensor C ++: необъявленный идентификатор для Visual Studio 2019? - PullRequest
0 голосов
/ 04 марта 2020

Недавно я приобрел датчик Bluetooth IMU Mbient Lab и пытаюсь работать через API, следуя инструкции , найденной здесь.

Я построил проект с использованием CMAKE в Visual Studio 2019. Я создал файл решения и изо всех сил пытаюсь начать писать код для проекта. Я создал решение, включил каталог, найденный в папке sr c, связал папку с библиотекой Win32 и добавил ее в дополнительные зависимости в разделе ввода в компоновщике. Однако, следуя простому учебнику, описанному в первом разделе кода, я получаю сообщение об ошибке функций write_gatt_char, read_gatt_char и enable_char_notify, являющихся необъявленным идентификатором, и я не могу найти исправление.

Один главный Разница в том, что файл connection.h отсутствует. Вместо этого файл с этими функциями находится в заголовочном файле btle_connection.h в отдельной папке.

Код показан ниже:

#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);
}

И я получаю ошибку C2065, что эти функции являются необъявленными идентификаторами.

Кроме того, в заголовочном файле btle_connectoin эти функции определены в приведенной ниже структуре:

/**
 * 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;

Любая помощь будет принята с благодарностью! Возможно ли, что я связываю / строю это неправильно?

...