Hi All! I'm developing a commercial product and using B4A to communicate with a Microchip RN4020 BLE module / PIC microcontroller combo. The app is working well with one exception: it takes typically 10 to 15 seconds to connect, sometimes as long as 30 seconds, which of course is a product killer! Once it's connected everything works as expected. Not all Android devices have the problem. Details:
Samsung S3: Android 4.1, connects immediately.
Amazon Fire Hd: Android 5.1 (?), connects within a second or two.
Ellipsys tablet (Verizon): Android 6.1, has above mentioned delay problem.
Google Pixel: Android 7.1, also has above delay problem.
Here's the kicker: There are two Microchip BLE apps that connect very rapidly on all above devices. One is called MLDP (not on the app store, but Microchip site), and the other is called SmartDiscover (on the app store). Two other app store BLE utilities, nRF Connect and BLE Scanner also connect rapidly. This tells me I'm probably missing some important detail. I don't know much about BLE, my code is pieced together from app on this site. I can supply the MLDP Java source code if that helps someone!
Here's my RN4020 setup:
SF,2 // factory default
SP,7 // power to the max
SR,32004000 // auto advertise, enb mldp, peripheral, mldp,cts/rts, IOS, automldp
ST,0064,0002,0064 // setup IOS required timing
SN,ZWGDO-01 // friendly bluetooth name
R,1 // reset
wait 1.5 seconds
set MLDP/CMD pin to 1 // sets MLDP mode)
Here's a capture from the log (with my comments):
Scanning
Found: ZWGDO-01, 00:1E:C0:3F:6C:15, RSSI = -47, (MyMap) {1=[B@fe6490c, 7=[B@a96f255, 9=[B@2d9446a, 0=[B@d569d5b} (found my device immediately)
(This is where the long 10 to 30 second delay happens)
Discovering services.
Connected (once connected everything works well)
BT connected (log message from my code)
Setting descriptor. Success = true
writing descriptor: true
ID=00035b03-58e6-07dd-021a-08123a000301
ID=00035b03-58e6-07dd-021a-08123a000301
ID=00035b03-58e6-07dd-021a-08123a000301
ID=00035b03-58e6-07dd-021a-08123a000301
Msg received: Welcome! (log message from my code)
Disconnecting
writing descriptor: true
Disconnected
Connect duration = 24484 miliseconds
** Activity (main) Pause, UserClosed = true **
Disconnecting
I've attached a zip of a "RN4020 Chat app" I created that shows the problem. I sure hope someone can help!!
Samsung S3: Android 4.1, connects immediately.
Amazon Fire Hd: Android 5.1 (?), connects within a second or two.
Ellipsys tablet (Verizon): Android 6.1, has above mentioned delay problem.
Google Pixel: Android 7.1, also has above delay problem.
Here's the kicker: There are two Microchip BLE apps that connect very rapidly on all above devices. One is called MLDP (not on the app store, but Microchip site), and the other is called SmartDiscover (on the app store). Two other app store BLE utilities, nRF Connect and BLE Scanner also connect rapidly. This tells me I'm probably missing some important detail. I don't know much about BLE, my code is pieced together from app on this site. I can supply the MLDP Java source code if that helps someone!
Here's my RN4020 setup:
SF,2 // factory default
SP,7 // power to the max
SR,32004000 // auto advertise, enb mldp, peripheral, mldp,cts/rts, IOS, automldp
ST,0064,0002,0064 // setup IOS required timing
SN,ZWGDO-01 // friendly bluetooth name
R,1 // reset
wait 1.5 seconds
set MLDP/CMD pin to 1 // sets MLDP mode)
Here's a capture from the log (with my comments):
Scanning
Found: ZWGDO-01, 00:1E:C0:3F:6C:15, RSSI = -47, (MyMap) {1=[B@fe6490c, 7=[B@a96f255, 9=[B@2d9446a, 0=[B@d569d5b} (found my device immediately)
(This is where the long 10 to 30 second delay happens)
Discovering services.
Connected (once connected everything works well)
BT connected (log message from my code)
Setting descriptor. Success = true
writing descriptor: true
ID=00035b03-58e6-07dd-021a-08123a000301
ID=00035b03-58e6-07dd-021a-08123a000301
ID=00035b03-58e6-07dd-021a-08123a000301
ID=00035b03-58e6-07dd-021a-08123a000301
Msg received: Welcome! (log message from my code)
Disconnecting
writing descriptor: true
Disconnected
Connect duration = 24484 miliseconds
** Activity (main) Pause, UserClosed = true **
Disconnecting
I've attached a zip of a "RN4020 Chat app" I created that shows the problem. I sure hope someone can help!!