Skip to content

Commit

Permalink
Forgot to commit all changes
Browse files Browse the repository at this point in the history
  • Loading branch information
scaryghost committed Feb 3, 2016
1 parent 2e19bc5 commit 3a8e438
Show file tree
Hide file tree
Showing 56 changed files with 1,034 additions and 721 deletions.
8 changes: 4 additions & 4 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "MetaWear Cpp API"
PROJECT_NAME = "MetaWear C++ API"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.2.2
PROJECT_NUMBER = 0.3.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down Expand Up @@ -779,7 +779,7 @@ FILE_PATTERNS =
# be searched for input files as well.
# The default value is: NO.

RECURSIVE = NO
RECURSIVE = YES

# The EXCLUDE tag can be used to specify files and/or directories that should be
# excluded from the INPUT source files. This way you can easily exclude a
Expand All @@ -804,7 +804,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*

EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = */cpp/*

# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
Expand Down
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,34 @@
This project is a C++ implementation of the MetaWear protocol. If compiled as a shared library, it can be used with any language that supports calling C functions from a shared library, such as C# and Python. The library only constructs the bytes for communicating with the MetaWear platform, it **does not** contain any Bluetooth LE code. Users will need to fill in the appropriate Bluetooth LE functions for their target device.

# Build #
Building the project has been tested on Linux using GCC 4.8.3 and make, and on Windows with Visual Studio Community 2015.
Building the project has been tested on Linux with GCC 4.8.5 and Clang 3.7.0, and on Windows with Visual Studio Community 2015.

## GCC and Make ##
```sh
> gcc --version
gcc (SUSE Linux) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> clang++ --version
clang version 3.7.0 (tags/RELEASE_370/final 246586)
Target: x86_64-suse-linux
Thread model: posix
```

## GCC and Clang ##
Linux users can build the project by invoking make. The default action is to build the shared library for your platform.

```sh
> make
```

Upon a successful compile, the library will be placed in the newly created dist directory.
You can change the C++ compiler by overriding the CXX make variable.
```sh
> make CXX=clang++
```

Upon a successful compile, the library will be placed in the newly created "dist" directory.

```sh
> tree dist
Expand All @@ -20,8 +38,8 @@ dist/
└── lib
└── x64
├── libmetawear.so -> libmetawear.so.0
├── libmetawear.so.0 -> libmetawear.so.0.2.2
└── libmetawear.so.0.2.2
├── libmetawear.so.0 -> libmetawear.so.0.3.0
└── libmetawear.so.0.3.0

```

Expand All @@ -31,16 +49,18 @@ Unit tests for the library are written in Python (min v3.4.1) and can be invoked
```sh
> make test
python3 -m unittest discover -s test
...................................................................................
................................................................................
................................................................................
......
----------------------------------------------------------------------
Ran 83 tests in 0.018s
Ran 166 tests in 0.047s

OK
```

## Visual Studio ##
A VIsual Studio solution building the C# wrapper is available as a separate project, link [here](https://github.com/mbientlab/MetaWear-CSharpWrapper). The C++ source code is built as Windows Runtime Component with the following changes to the project properties:
A Visual Studio solution building the C# wrapper is available as a separate project, link [here](https://github.com/mbientlab/MetaWear-CSharpWrapper). The C++ source code is built as Windows Runtime Component with the following changes to the project properties:

1. Disable the **Precompiled Headers** compile option
2. Disable **Generate Windows Metadata** linker option
3. Add **METAWEAR_DLL_EXPORTS** to the preprocessor list
3. Add **METAWEAR_DLL_EXPORTS** to the preprocessor list
6 changes: 3 additions & 3 deletions project_version.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=0.2.77
VERSION=0.3.0
VERSION_MAJOR=0
VERSION_MINOR=2
VERSION_STEP=77
VERSION_MINOR=3
VERSION_STEP=0
59 changes: 46 additions & 13 deletions src/metawear/core/connection.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* @copyright MbientLab License
* @file connection.h
* @brief Methods and types for communicating with the metawear board
*/
#pragma once

Expand All @@ -14,20 +13,54 @@
extern "C" {
#endif

/** High QWORD of the MetaWear gatt service UUID */
const uint64_t METAWEAR_GATT_SERVICE_UUID_HIGH= 0x326a900085cb9195;
/** Low QWORD of the MetaWear gatt service uuid */
const uint64_t METAWEAR_GATT_SERVICE_UUID_LOW= 0xd9dd464cfbbae75a;
/**
* UUIDs identifying a gatt characteristic and its parent service
*/
typedef struct {
uint64_t service_uuid_high; ///< High 64 bits of the parent service uuid
uint64_t service_uuid_low; ///< Low 64 bits of the parent service uuid
uint64_t uuid_high; ///< High 64 bits of the characteristic uuid
uint64_t uuid_low; ///< Low 64 bits of the characteristic uuid
} MblMwGattChar;

/** UUIDs for the MetaWear notification characteristic */
const MblMwGattChar METAWEAR_SERVICE_NOTIFY_CHAR = { 0x326a900085cb9195, 0xd9dd464cfbbae75a, 0x326a900685cb9195, 0xd9dd464cfbbae75a };

/** High QWORD of the MetaWear command gatt characteristic */
const uint64_t METAWEAR_GATT_CHAR_COMMAND_UUID_HIGH= 0x326a900185cb9195;
/** Low QWORD of the MetaWear command gatt characteristic */
const uint64_t METAWEAR_GATT_CHAR_COMMAND_UUID_LOW= 0xd9dd464cfbbae75a;
/**
* Wrapper class containing functions for communicating with the MetaWear through a Bluetooth Low Energy connection.
*/
typedef struct {
/**
* Writes the characteristic and value to the device
* @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)(const MblMwGattChar *characteristic, const uint8_t *value, uint8_t length);
/**
* Reads the value of the characteristic from the device
* @param characteristic Gatt characteristic to read
*/
void (*read_gatt_char)(const MblMwGattChar *characteristic);
} MblMwBtleConnection;

/** High QWORD of the MetaWear notification gatt characteristic */
const uint64_t METAWEAR_GATT_CHAR_NOTIFY_UUID_HIGH= 0x326a900685cb9195;
/** Low QWORD of the MetaWear notification gatt characteristic */
const uint64_t METAWEAR_GATT_CHAR_NOTIFY_UUID_LOW= 0xd9dd464cfbbae75a;
/**
* Handles changes from the MetaWear notify characteristic. All characteristic changes from the notify characteristic must be forwarded
* to this function
* @param board Board the characteristic change is from
* @param value Byte array containing the new characteristic value
* @param len Length of the array
* @see METAWEAR_SERVICE_NOTIFY_CHAR
*/
METAWEAR_API int32_t mbl_mw_connection_notify_char_changed(MblMwMetaWearBoard *board, const uint8_t *value, uint8_t len);
/**
* Handles responses from reading gatt characteristics. All characteristic values read must be forwaded to this function.
* @param board Board the response is from
* @param characteristic Characteristic that was read
* @param value Byte array containing the characteristic value
* @param length Length of the array
*/
METAWEAR_API void mbl_mw_connection_char_read(MblMwMetaWearBoard *board, const MblMwGattChar *characteristic, const uint8_t *value, uint8_t length);

#ifdef __cplusplus
}
Expand Down
19 changes: 14 additions & 5 deletions src/metawear/core/data.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/**
* @copyright MbientLab License
* @file data.h
* @brief Functions and types for data received from an MblMwDataSignal
*/
#pragma once

/**
* Enumeration of sensor data types
*/
typedef enum {
MBL_MW_DT_ID_UINT32= 0, ///< Data is a uint32_t
MBL_MW_DT_ID_FLOAT, ///< Data is a float
MBL_MW_DT_ID_CARTESIAN_FLOAT, ///< Data is a CartesianFloat
MBL_MW_DT_ID_INT32
MBL_MW_DT_ID_UINT32= 0, ///< Data is an unsigned integer
MBL_MW_DT_ID_FLOAT, ///< Data is a float
MBL_MW_DT_ID_CARTESIAN_FLOAT, ///< Data is a CartesianFloat
MBL_MW_DT_ID_INT32 ///< Data is a signed integer
} MblMwDataTypeId;

/**
Expand All @@ -18,4 +23,8 @@ typedef struct {
MblMwDataTypeId type_id; ///< ID represnting the data type the value pointer points to
} MblMwData;

typedef void (*MblMwFnData)(const MblMwData* data);
/**
* Definition for callback functions that handle data from an MblMwDataSignal
* @param data Data returned from the signal
*/
typedef void (*MblMwFnData)(const MblMwData* data);
15 changes: 14 additions & 1 deletion src/metawear/core/dataprocessor_fwd.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
/**
* @copyright MbientLab License
* @file dataprocessor_fwd.h
* @brief Forward declaration for the MblMwDataProcessor type
*/
#pragma once

#ifdef __cplusplus
struct MblMwDataProcessor;
#else
/**
* Data signal from the on board data processor. An MblMwDataProcessor pointer can be casted as an
* MblMwDataSignal pointer and used with any function tht accepts an MblMwdDataSignal.
*/
typedef struct MblMwDataProcessor MblMwDataProcessor;
#endif

typedef void (*MblMwFnDataProcessor)(MblMwDataProcessor* new_processor);
/**
* Definition for callback functions that accept an MblMwDataProcessor pointer
* @param processor Processor to be used with the function
*/
typedef void (*MblMwFnDataProcessor)(MblMwDataProcessor* processor);
5 changes: 3 additions & 2 deletions src/metawear/core/datasignal.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @copyright MbientLab License
* @file datasignal.h
* @brief Generic functions for handling sensor data
* @brief Functions for controlling a MblMwDataSignal
*/
#pragma once

Expand All @@ -15,7 +15,8 @@ extern "C" {

/**
* Subscribes to a data stream, processing messages with the given handler
* @param signal Data signal to subscribe to
* @param signal Data signal to subscribe to
* @param received_data Callback function to handle data received from the signal
*/
METAWEAR_API void mbl_mw_datasignal_subscribe(MblMwDataSignal *signal, MblMwFnData received_data);

Expand Down
13 changes: 6 additions & 7 deletions src/metawear/core/datasignal_fwd.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/**
* @copyright MbientLab License
* @file datasignal_fwd.h
* @brief Forward declarations for datasignal types
*/
* @copyright MbientLab License
* @file datasignal_fwd.h
* @brief Forward declaration for the MblMwDataSignal type
*/
#pragma once

#ifdef __cplusplus
struct MblMwDataSignal;
#else
/**
* Represents a data producer
* A event fired from the MetaWear board that also contains data. An MblMwDataSignal pointer can be casted as an
* MblMwEvent pointer and used with any function that accepts an MblMwEvent pointer.
*/
typedef struct MblMwDataSignal MblMwDataSignal;
#endif

typedef void(*MblMwFnDataSignal)(MblMwDataSignal* new_signal);
23 changes: 22 additions & 1 deletion src/metawear/core/event.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* @copyright MbientLab License
* @file event.h
* @brief Functions for the MblMwEvent type
*/

#pragma once

#include "callback.h"
Expand All @@ -9,10 +15,25 @@
extern "C" {
#endif

/**
* Retrieves the MblMwMetaWearBoard the event belongs to
* @param event Event to lookup
* @return Pointer to the owner
*/
METAWEAR_API MblMwMetaWearBoard* mbl_mw_event_get_owner(const MblMwEvent *event);
/**
* Enables command recording. All MetaWear commands called after this point will be executed
* when the owning event is fired
* @param event Event to record commands for
*/
METAWEAR_API void mbl_mw_event_record_commands(MblMwEvent *event);
/**
* Ends command recording. This function is non-blocking and will asynchronously alert the caller
* when the operation is completed.
* @param event Event to end recording for
* @param commands_recorded Callback function to be executed when commands have been recorded
*/
METAWEAR_API void mbl_mw_event_end_record(MblMwEvent *event, MblMwFnVoid commands_recorded);
METAWEAR_API void mbl_mw_event_remove_commands(MblMwEvent *event);

#ifdef __cplusplus
}
Expand Down
10 changes: 9 additions & 1 deletion src/metawear/core/event_fwd.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
/**
* @copyright MbientLab License
* @file event_fwd.h
* @brief Forward declaration of the MblMwEvent type
*/
#pragma once

#ifdef __cplusplus
struct MblMwEvent;
#else
/**
* Represents an event fired from the MetaWear board.
*/
typedef struct MblMwEvent MblMwEvent;
#endif
#endif
Loading

0 comments on commit 3a8e438

Please sign in to comment.