Mbient Lab Sensor API C ++帮助:Visual Studio 2019的未声明标识符?

问题描述 投票:0回答:1

我最近购买了Mbient Lab IMU蓝牙传感器,并按照教程found here.尝试通过API进行工作>

我在Visual Studio 2019中使用CMAKE构建了该项目。创建了一个解决方案文件,我正努力开始为该项目编写代码。我创建了一个解决方案,包括在src文件夹中找到的目录,链接了包含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;

任何帮助将不胜感激!我是否可能错误地链接/构建了它?

我最近购买了Mbient Lab IMU蓝牙传感器,并按照此处找到的教程尝试通过API进行操作。我在Visual Studio 2019中使用CMAKE构建了项目。我...

c++ build linker sensor
1个回答
0
投票

尽管您已经指出,这些功能是在btle_connection头文件中声明的,但尚未定义。在调用mbl_mw_metawearboard_create之前,我们必须编写这些函数的定义/实现。 (https://mbientlab.com/cppdocs/latest/btlecommunication.html

© www.soinside.com 2019 - 2024. All rights reserved.