Giter Club home page Giter Club logo

metawear-sdk-ios-macos-tvos's Introduction

MetaWear SDK for iOS/macOS/tvOS/watchOS by MBIENTLAB

Platforms License Version

alt tag

SDK for creating MetaWear apps that run in the Apple ecosystem. This is a thin wrapper around the MetaWear C++ API so you will find the C++ documentation and API reference useful. Check out the starter App and the very through example App App for sample code.

Like Combine more than Bolts? 😎

We're developing a Swift Combine SDK, now in beta with interactive documentation and two sample apps.

Overview

MetaWear is a complete development and production platform for wearable and connected device applications.

MetaWear features a number of sensors and peripherals all easily controllable over Bluetooth 4.0/5.0 Low Energy using this SDK, no firmware or hardware experience needed!

The MetaWear hardware comes pre-loaded with a wirelessly upgradeable firmware, so it keeps getting more powerful over time.

Requirements

  • MetaWear board
  • Apple ID, you can now get started for free! Once you are ready to submit an App to the App Store, you need a paid Apple Developer Account.
  • Device running iOS 14.0 or later with Bluetooth 4.0/5.0 (iOS 13+, XCODE12+, BLE5.0 recommended)

REQUIREMENT NOTES
The iOS simulator doesn’t support Bluetooth 4.0/5.0, so test apps must be run on a real iOS device which requires a developer account. Bluetooth 4.0 available on iPhone 4S+, iPad 3rd generation+, or iPod Touch 5th generation.

BLUETOOTH IS NOT SUPPORTED IN THE SIMULATOR

License

See the License

Support

Reach out to the community if you encounter any problems, or just want to chat :)

Getting Started

Pre-Installation

Xcode

You need to be profficient with Xcode development to use these APIs.

Swift

Our APIs are written and supported in Swift.

CocoaPods

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 79 thousand libraries and is used in over 3 million apps. CocoaPods can help you scale your projects elegantly.

CocoaPods is built with Ruby and is installable with the default Ruby available on macOS. We recommend you use the default ruby.

Using the default Ruby install can require you to use sudo when installing gems. Further installation instructions are in the guides.

sudo gem install cocoapods

Installation

MetaWear is available through CocoaPods. To install it, simply add the following line to your Podfile:

Then list the dependencies in a text file named Podfile in your Xcode project directory:

platform :ios, '14.0'
use_frameworks!
target 'MyApp' do
    // LOCAL
    pod "MetaWear", :subspecs => ['UI', 'AsyncUtils', 'DFU']
    // COCOA POD
    pod "MetaWear"
    // COCOA POD RELEASE SPECIFIC
    pod "MetaWear", '~> '4.0.2'
end

Tip: CocoaPods provides a pod init command to create a Podfile with smart defaults. You should use it.

Now you can install the dependencies in your project:

pod install

It might be good to update:

pod update

Make sure to always open the Xcode workspace instead of the project file when building your project:

open App.xcworkspace

Now you can import your dependencies e.g.:

#import MetaWear

Usage

Require the metawear package

import MetaWear
import MetaWearCpp

Call Swift APIs:

device.flashLED(color: .green, intensity: 1.0)

Or direct CPP SDK calls:

var pattern = MblMwLedPattern(high_intensity: 31,
                              low_intensity: 31,
                              rise_time_ms: 0,
                              high_time_ms: 2000,
                              fall_time_ms: 0,
                              pulse_duration_ms: 2000,
                              delay_time_ms: 0,
                              repeat_count: 0xFF)
mbl_mw_led_stop_and_clear(device.board)
mbl_mw_led_write_pattern(device.board, &pattern, color)
mbl_mw_led_play(device.board)

Or a mix of both as you can see in the example below.

Example

Here is a walkthrough to showcase a very basic connect and toggle LED operation.

MetaWearScanner.shared.startScan(allowDuplicates: true) { (device) in
    // We found a MetaWear board, see if it is close
    if device.rssi.intValue > -50 {
        // Hooray! We found a MetaWear board, so stop scanning for more
        MetaWearScanner.shared.stopScan()
        // Connect to the board we found
        device.connectAndSetup().continueWith { t in
            if let error = t.error {
                // Sorry we couldn't connect
                print(error)
            } else {
                // Hooray! We connected to a MetaWear board, so flash its LED!
                var pattern = MblMwLedPattern()
                mbl_mw_led_load_preset_pattern(&pattern, MBL_MW_LED_PRESET_PULSE)
                mbl_mw_led_stop_and_clear(device.board)
                mbl_mw_led_write_pattern(device.board, &pattern, MBL_MW_LED_COLOR_GREEN)
                mbl_mw_led_play(device.board)
            }
        }
    }
}

Tutorials

Tutorials can be found here.

metawear-sdk-ios-macos-tvos's People

Contributors

andraskadar avatar importryan avatar lkasso avatar sschiffli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metawear-sdk-ios-macos-tvos's Issues

Bookmark "downloadLogAndStopLoggingAsync" method in Objective C giving an error ?

`[[[self.device.accelerometer.dataReadyEvent downloadLogAndStopLoggingAsync:YES progressHandler:^(float number) {

}] success:^(NSArray<MBLAccelerometerData *> * _Nonnull array) {
    
}] failure:^(NSError * _Nonnull error) {
    
}];`

The above code is giving the error "No visible @interface for 'BFTask<NSArray<MBLAccelerometerData *> *>' declares the selector 'success:'". Please suggest the correct method to use in Objective C

Apple Notification Center Service (ANCS)

Hi,

The version 3 does not have any ANCS code. Are you planning to bring this functionality back?
The version develop2.0 has some code, but it does not work. It never finish the programming sequence when using the device.ancs object.

Best regards,

Clément

Data stability

Good evening, we've changed to the new 3.0 SDK and the transmission of the sensor fusion data seems to be unstable. After a couple of seconds (or minutes, it's kind of random) the data stops transmitting to the mbl_mw_datasignal_subscribe method. Is there any other config we're missing? We've checked all the information provided by the documentation, both iOS and CPP. Thanks.

Thread dump on calling MBLMetaWearManager.shared()

I am creating a CLI Application, that will run for MACOSX.
I want to connect to the MetaWear sensors to just log data to a file.

I am following the guide on here: https://mbientlab.com/iosdocs/latest/metawear_manager.html

If I instantiate a manager class, and attempt a connection alike this, I get a Thread dump stating:

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

i.e The following line will cause a Thread dump above:

MBLMetaWearManager.shared();

My main class:

import Foundation

let runLoop = RunLoop.current;
let distantFuture = Date.distantFuture;

print("### we are in the create");
let starter = MetaWearStarter();
print("### we are after the create");

while (runLoop.run(mode: RunLoopMode.defaultRunLoopMode, before:    distantFuture)){
    print("### listening for a metawear device");
}

My MetaWearStarter class:

import Foundation

import MetaWear

class MetaWearStarter : NSObject {

    override init() {
        super.init();
        print("### we are in the init");
        startConnection();
    }

    func startConnection() {
        print("##### connection call was made");
        let manager = MBLMetaWearManager.shared();
        maanger.startScanForMetaWears() { array in
        print("### connection scan was complete")    
        // Hooray! We found a MetaWear board, so stop scanning for more
            MBLMetaWearManager.shared().stopScan()
            // Connect to the board we found
            if let device = array.first {
                device.connectAsync().success() { _ in
                    print("#### we connected to a device");
                    }.failure() { error in
                        print("### unable to connect");
                }
            }
        }
    }

}

I have a stack question opened here: https://stackoverflow.com/questions/46435965/metawear-cli-application-on-macosx

What exactly am I doing wrong in following the guide?

Data from Acc,Gyro,Magneto reports same timestamp.

Hi,

i've updated to 2.8.3 and found this weird issue. I'm tracking MBLAccelerometerData and it is reported with the same timestamp. (everytime 3 events with different data in row has same timestamp, then another 3 events has same timestamp).

Version 2.8.2 works just fine.

Feel free to contact me for more info if needed

option for static lib, with bitcode?

It would be great to have an option to build a static library with bitcode. The current framework is a dylib without bitcode; I'm not sure whether bitcode is possible in a dylib, but I was unable to get it to build with bitcode unless I switched to a static lib.

C functions can't be used from objective-C++ code

The C functions in MBLConstants.h can't be used from Objective-C++ code because when the header file is included by Objc-C++ code, it is assumed to have C++ linkage, but it is compiled with C linkage.

To fix this, the C functions could be declared like this:

#ifdef __cplusplus
extern "C"
#endif
NSString *MBLModelString(MBLModel model);

Notifications sent after unsubscribed when using periodicSample(ofEvent:)

When using periodicSample(ofEvent:) to control the frequency of events, notifications are still sent event after successfully unsubscribing.

To replicate this, using the StarterProject, change DeviceViewController line 59 from:

device.accelerometer?.dataReadyEvent.startNotificationsAsync

to

device.accelerometer?.dataReadyEvent.periodicSample(ofEvent: 2000).startNotificationsAsync

Is there something that I should be doing differently to unsubscribe from notifications when using a filter?

SDK bug

Hello. I am developing an iOS application that will receive data from your device's gyroscope. For this, I use your SDK. While developing the application, I encountered an error. When I'm connected to a device via my app, my app crashes if anyone else connects to the device. XCode complains on board property of MetaWear class: EXC_ BAD_ACCESS. Could you give me any advice or fix this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.