Android Question BLE/Classic BT in one Android app

Discussion in 'Android Questions' started by niveasoft, Jun 12, 2018.

  1. niveasoft

    niveasoft Member Licensed User

    Hello.
    How we can scan and communicate with Classic BT and BLE in one app in the Android phone/device equipped with BT4.1 for example?

    Thing is about that I have IoT device that can be equipped with HM-10 for iOS and my application for it work fine, even that I must send about 50 bytes at one time. I simply collect them till CRLF is found and then begin parsing the data.
    But sometimes device can be equipped with HC-05 and my app for this device also work fine with AsyncStreams in the Android.
    I want to ask if someone can share some of ready to use solution for switching services (I use starter service like newest examples shows) to choose BLE/Classic.
    I`m not lazy. I`m working on that and want to learn from the better of me. Maybe I miss something and then please link me.
    Thanks in advance.
    BARTek

    EDIT:
    In my app I have:
    Public ManagerC As BluetoothManager
    Public ManagerB As BleManager2

    B for BLE, C for Classic so I think they can be somehow choosed.
     
    Last edited: Jun 12, 2018
  2. Erel

    Erel Administrator Staff Member Licensed User

    There is no relation between the two communication methods. To better organize your code you can implement each one in a different class.
     
  3. niveasoft

    niveasoft Member Licensed User

    I dont see it like that. I know restrictions of the BLE (max 20 bytes for example ) but I must migrate to HM-10 after app for iOS must be made.
    ..and it works fine. If my app, previously maked for AsyncStereams, works fine now with iOS then I want have app that can give choice -> we link with BLE or Classic.
    I dont have problem with "Name and Mac" and "Characteristic"
    I simply want to make a choice in the one app witch BT method I want to use because IoT devices can be equipped with HC-05 or HM-10 and then what :D
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Maybe I misunderstood your question.
    You don't need to do anything special. You should implement both features.

    I recommend you to implement each one in a different class.
     
  5. niveasoft

    niveasoft Member Licensed User

    Finally I got it and even want to record video how apps written in B4i and B4A can link, read, and write data into some device even together at once :D
    Android can handle BT Classic, BLE and MQTT where iOS BLE and MQTT.
    For myDevice I use some another language where I can use two Internet link (Wizznet and ESP8266) for communicate with VPS and even crypted remote upgrade is possible.
    This will be in on my wishlist because Im lovin BasicLanguage.

    Thank you for your time to answear and confirm that this can be done...and not give me example :p cause I learn a lot again.
     
    Erel likes this.
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