iOS Question B4i Beta 5.5 Debug Issue

Discussion in 'iOS Questions' started by techknight, Jan 14, 2019 at 2:10 PM.

  1. techknight

    techknight Well-Known Member Licensed User

    For some reason I am having some weird issues with the debugger of the beta.

    This code worked fine prior to installing the beta, even in debug mode:

    Code:
    Sub ScanForDevices
        
    Dim servicelist, devices As List
        
    Dim sheet As ActionSheet
        servicelist.Initialize
        devices.Initialize
        HD.ProgressDialogHide
        HD.ProgressDialogShow(
    "Searching for Devices, Please Wait.")
        ScanningMode = 
    True 'Scanning only
        DiscoveryMode = False 'No discovery until connecting.
        ScanCancelled = False
        FoundDevices.Initialize
        FoundDevices.Clear
        servicelist.Add(BLEMasterService)
        manager.Scan2(servicelist, 
    True)
        ScanTimer.Enabled = 
    True
     
        
    Do Until ScanCancelled = True
            
    Wait For Device_Detected (ReturnCode As Int) 'Wait for any devices to be discovered.
            If ReturnCode = 0 Then 'We continue to scan and add adapters.
                HD.ProgressDialogShow("Searching for Devices. (" & FoundDevices.Size & " Found)") <-- This never executes or updates.
                devices.Clear
                
    For Each Key As String In FoundDevices.Keys
                    
    Dim DeviceInfo As Device
                    DeviceInfo.Initialize
                    DeviceInfo = FoundDevices.Get(Key)
                    devices.Add(DeviceInfo.Name & 
    " " & GetBars(CalculateSignalLevel(DeviceInfo.RSSI, 5)))
                    
    #IF DEBUG
                        Log(DeviceInfo) <--- This works in debug, sometimes.
                    
    #End If
                
    Next
            
    Else 'The scan has been completed or cancelled.
                ScanCancelled = True
                ScanningMode = 
    False
                manager.StopScan
                
    Exit
            
    End If
        
    Loop
        HD.ProgressDialogHide <--- This never gets reached, 
    or the code below it.
        
    Log("Scan Complete")

        sheet.Initialize(
    "sheet""Available Devices""","", devices)
        sheet.Show(Main.page1.RootPanel)
    '    Wait For sheet_Click (Result As String)
    '    Log(Result)
     
    End Sub

    Sub ScanTimer_Tick
        ScanTimer.Enabled = 
    False
        
    CallSub2(Me, "Device_Detected"1'Call our event to exit the loop on scan complete. (to prevent a "potential" memory leak from an unresolved Wait For. I feel better this way.)
    End Sub


    Sub Manager_DeviceFound (Name As StringId As String, AdvertisingData As Map, RSSI As Double)
        
    Dim UniqueID As String
        
    If AdvertisingData.ContainsKey("kCBAdvDataManufacturerData") = True Then 'Make sure only our programmed devices can be discovered.
            UniqueID = AdvertisingData.Get("kCBAdvDataManufacturerData")
            UniqueID = 
    Regex.Replace("[^0-9A-Fa-f]+", UniqueID, "").ToUpperCase
        
    End If
        
    If ScanningMode = True And UniqueID = "XXXXXXXXXX" Then 'We are scanning for valid devices. Add them one at a time into our list of available connections.
            If FoundDevices.ContainsKey(Id) = False Then 'If the discovered device is not already in the list, then we add it and move on.
                Dim DetectedDevice As Device
                DetectedDevice.ID = 
    Id
                DetectedDevice.Name = Name
                DetectedDevice.RSSI = RSSI
                FoundDevices.Put(
    Id, DetectedDevice)
                
    CallSub2(Me, "Device_Detected"0'Call our Wait For event to add any new entries into the selection list. 0 means scan continue.
            End If
        
    Else If UniqueID = "XXXXXXXXXX" And SelectedDevice.ID = Id Then 'We have discovered our device
            DiscoveryMode = True
            manager.StopScan 
    'Stop our scan since we found the device we are looking for.
            manager.Connect(Id'Connect to our device.
        End If
    End Sub
    But now with 5.5 Beta installed, its hit or miss. Mostly miss. itll pop up the Searching dialog, but then nothing happens after that outside of the log print.

    I commented above in the code where the trouble spots are. Its really hit or miss, I am chasing my tail because I think its a code issue. So i change some code, it works. then try it again, it quits working.

    If I compile in release mode, the code works every time.

    thoughts?
     
    Last edited: Jan 14, 2019 at 2:19 PM
  2. Erel

    Erel Administrator Staff Member Licensed User

    Why aren't you showing the dialog before the Wait For line?

    I cannot say what is wrong here. You need to try to reproduce it in a small project. Based on your description I guess that it will work if you clean the project before running it.
     
  3. techknight

    techknight Well-Known Member Licensed User

    I do show the dialog before the wait for. I just "update" the dialog afterwords. Cleaning the project does not help. Only building in release mode that everything works. Also everything was working prior to installing 5.5 so I am not sure what the differences are internally.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Try to reproduce it in a small project. If it is not possible you can send me the complete project and I'll try it.
     
  5. techknight

    techknight Well-Known Member Licensed User

    I can do that. Its very intermittent. Towards the end of the day yesterday, it was magically working fine. Go figure.
     
  6. techknight

    techknight Well-Known Member Licensed User

    Where do I send it? support? Thanks.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    Always use CallSubDelayedX when you want to raise an event that should be caught with Wait For. Otherwise it might be lost.
     
  8. techknight

    techknight Well-Known Member Licensed User

    Never heard of that function. Trying to search it up to see its function, but cant find anything.

    Actually, that function doesnt exist. turns RED.
     
  9. OliverA

    OliverA Well-Known Member Licensed User

    Short for this group of functions:
    CallSubDelayed
    CallSubDelayed2
    CallSubDelayed3
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice