I am trying to develop a BLE application in SwiftUI to control an Arduino connected via serial to a HM-10 module, and are having some issues updating Published vars with data being sent from my Arduino via HM-10, and also perhaps timing issues setting my isConnected Boolean variable, and possibly timing when setting my characteristic notify subscription up, and this is a particular issue when setting up Bluetooth pairing when connecting to my module.
Im after some specialist help, and due to the application requiring my HM-10 module to be present locally to interact with, and also requiring the application to run live on my phone whilst debugging in Xcode, I was wondering if I could set up a Team viewer session / other screen sharing mechanism and perhaps a phone call same time to help me with my issues please?
My Arduino does send packets of Bluetooth Serial information periodically, however I’m having problems filling my Published variables with this received information before my view loads.
While routines are blocking when used in .onAppear, and Timers aren’t working particularly well, and I need the serial data to set up my view, so I need some help to write some code in my view that will wait for this information before creating my view.
The biggest issue is that code in .onAppear seems to run before my corebluetooth is actually set up, so trying to use this to capture my serial data into my PublishedVars results in errors due to there being no data available.
My view relies on my published vars having data available to display things like sliders, and as such my view appears without my sliders.
I need to find a way to run some code on my view so that when bleMabanager.decodedJSON.indices.contains(0) is true, it’ll then loop through and populate my publishedvars with data either before my view loads, or after (as an update).
Really struggling with this, so would really appreciate some help.