Swiift SDK v3 Docs

This discussion was created from comments split from: Firmware v1.4.1.


  • Docs for iOS v3.1.6 seems incomplete on website online since the new firmware is available, and I feel worried as a part of my code is still in objc...
    Will there be a new MetaWearApiTest project soon available for this new SDK.
    Before upgrading it could be very usefull to check major differences.

  • edited August 4

    What is incomplete about the documentation?

    Refer to the Swift Starter Project for a working app.

  • Starter Projetc is really to minimalist to get a good idea of how to write an optimized code with iOS and it is quite discouraging.

    As provided before, to get the possibility to use a complete example of functions was great and the best way to do as you want (https://github.com/mbientlab/MetaWear-SampleApp-iOS) ! Could it be possible to get an update version of this full app (last commit is 22 dec 2017 ; not so far...)

    If you really want us to use your last optimized API why letting us guess how to do from C++ ? Until now, I was really so happy to get support on iOS... Is it a voluntary change of strategy to leave iOS ? is MetaBase supposed to be the only "true" app ?

    Regarding a working app, mines are already online on the app store just waiting for an activation code to connect three metamotion-r.
    Functionally it is working well and only bluetooth 5 will be able to help for a better connectivity (particularly outdoors).
    I even took time to send you a long email about my complete project...

    And as you know, since march, I am working on my business plan and a first order of one thousand sensors ; but with this new firmware It seems compromised for september. I just do hope that this firmware will lead soon to the possibility to get bluetooth 5 which will be a real new feature...

    Thanks for your help and attention

  • The iOS v3 documentation clearly states:

    This is a thin wrapper around the MetaWear C++ API so you will find the C++ documentation and API reference useful

    Have you reviewed the C++ documentation? If not, then of course the start project is going to feel foreign and unhelpful as the api has completely changed. If so, then post what is unclear about the C++ sdk, and we can address them.

    If you are uncomfortable with using the v3 release, then stick with v2, however, new features most likely will not be back-ported so you should update your code when appropriate or convenient.

  • Thanks Eric for your answer but yes, unfortunately, I had already read the new v3 documentation before posting, but I feel completely lost with the thin wrapper C++ and I understand that there is no more support for "pure" iOS...

    Regarding these two old iOS functions which were so simples to get gyro rotations values, I am now unable to find how to do in Swift (i.e. just start and stop gyro).

        let gyroBMI160 = self.device.gyro as! MBLGyroBMI160
        gyroBMI160.fullScaleRange = .range2000
        gyroBMI160.sampleFrequency = 100
        device.gyro!.packedDataReadyEvent?.startNotificationsAsync { (obj, error) in
            if let obj = obj {
            //and here, juste code to affect obj.x, obj.y and obj.z values to local variables.

    I just read and read again the docs for c++ (https://mbientlab.com/cppdocs/latest/gyro.html) and I feel completely desperate...
    The code look like Swift but impossible to use it "like that" and clearly I understand nothing to the way to declare "rot_handler" and "rot_rate" in Swift...

    Here is the code I try to insert in the startup project ; for configuring it seems ok, but for sampling I do not understand how to convert C++ code to Swift.

        mbl_mw_gyro_bmi160_set_odr(self.device.board, MBL_MW_GYRO_BMI160_ODR_100Hz);
        mbl_mw_gyro_bmi160_set_range(self.device.board, MBL_MW_GYRO_BMI160_RANGE_2000dps);

    _** static auto rot_handler = [](void* context, const MblMwData* data) {
    // Cast value to MblMwCartesianFloat*
    auto rot_rate = (MblMwCartesianFloat*)data->value;
    printf("(%.3fdps, %.3fdps, %.3fdps)\n", rot_rate->x, rot_rate->y, rot_rate->z);
    auto state_signal = mbl_mw_gyro_bmi160_get_rotation_data_signal(self.device.board);
    mbl_mw_datasignal_subscribe(state_signal, nullptr, rot_handler);**_


    Could it be possible to get the correct syntaxe for Swift regarding the declaration of rot_handler, state_signal for a correct use with mbl_mw_datasignal_subscribe.

    Thanks in advance

  • Wrap your code with code tags so it renders correctly on the forum.

    See how this unit test sets up an accelerometer stream:

  • Great !!!
    Many thanks for the link ! I was really not far, but I believe that I would have turn around for hours without your help as I am really not friend with wrapper, bridge and pointers...
    Thanks again !

Sign In or Register to comment.