Can't connect to device: Assertion failed: (self.activateCount >= 0)

I am working on an iOS app and was able to easily connect to the devices until yesterday. 

Not sure what happened (and I am using a version of code which was working perfectly earlier) but getting the error below when I try to connect to the device. The template metawear app provided by you is working fine and connects to the device. 

"Assertion failed: (self.activateCount >= 0), function -[MBLRegister deactivateAsync]_block_invoke, file /Users/macbookpro/Desktop/ZFitnessTracker/METAWEAR_code/LATEST_Metawear_swift_edit/Pods/MetaWear/MetaWear/Classes/Core/MBLRegister.m, line 561."
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000}
span.s1 {font-variant-ligatures: no-common-ligatures}

Any tips on debugging this. 

Thanks, 

Comments

  • This is the code block with the issue: 






    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}
    p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #31595d; background-color: #ffffff}
    p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #4f8187; background-color: #ffffff}
    p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #78492a; background-color: #ffffff}
    span.s1 {color: #4f8187}
    span.s2 {color: #000000}
    span.s3 {color: #ba2da2}
    span.s4 {color: #272ad8}
    span.s5 {color: #31595d}
    span.s6 {color: #78492a}

    - (BFTask *)deactivateAsync

    {

        return [BFTask taskFromMetaWearWithBlock:^id{

            self.activateCount--;

            if (self.activateCount == 0) {

                activateTask = [[[self.module deactivateAsync] continueOnMetaWearWithSuccessBlock:^id _Nullable(BFTask * _Nonnull task) {

                    return [self performAsyncDeactivation];

                }] continueOnMetaWearWithBlock:^id _Nullable(BFTask * _Nonnull task) {

                    if (task.faulted) {

                        self.activateCount++;

                    }

                    return task;

                }];

            }

    #ifdef DEBUG

            assert(self.activateCount >= 0);

    #endif

            self.activateCount = MAX(self.activateCount, 0);

            return activateTask;

        }];

    }

  • edited January 2018
    I updated the firmware - and devices connect now  - weird. 
    Any ideas on why would this happen ? 
  • Ok.. the problem got fixed for a little bit and has reappeared :-/ 
  • What is your app doing?  If the template app is still working, perhaps something in your app is not properly using the iOS SDK.

    Some other users have had similar issues before, perhaps those threads can provide some insight.
  • Thanks Eric.  (Should've done that myself :) 


  • FYI: I couldn't really find a reason for the error - checked that streaming  and notification events were being properly added and removed.. so I fixed it by adding a check here: 


    return [BFTask taskFromMetaWearWithBlock:^id{

    ***** if (self.activateCount > 0 ) { ********

            self.activateCount--;



This discussion has been closed.