Android Question Serial Port problem.

mrossen

Active Member
Licensed User
Longtime User
Hi,

I have a app using a service for bluetooth connection. It has been working since I made it about 2 years ago.

But now I experiece that on my 2 devices with android 4.4.2 it is not working correct any more.
I also have a device with android 2.3.5. This Work without problem.

I can connect without any problems in the app, but when I go the the home screen and then leave out of range or turn off/on my bluetooth device it will not reconnect.

I it seems like Serial.Listen not working/had permission to reconnect.

I think there maybe is some new admissions there had to be add.

Any one had any experience with this?

Code: Copy
Sub Service_Create

    Serial1.Initialize("Serial1")
    BluetoothAdmin1.Initialize("BluetoothAdmin1")
   
    Notification1.Initialize
    Notification1.Icon = "icon" 'use the application icon file for the notification
    Notification1.Light = False
    Notification1.Sound = False
    Notification1.Vibrate = False
    Notification1.SetInfo("Cruise E-Drive", Main.mtcruisedisconnected, Info)
       
    'Make sure that the process is not killed during the download
    Service.StartForeground(1, Notification1)
   
    If BluetoothAdmin1.IsEnabled = False Then
        BluetoothAdmin1.Enable
    Else
        Serial1.Listen 'listen for incoming connections
    End If

End Sub


Mogens
 
Are you calling Serial1.Listen in Serial Connected event?

Due to the code he posted i would say he does that in Service_Create
 
Upvote 0
OK, I tried that. That do not change anything.

Code: Copy
Sub Serial1_Connected (Success As Boolean)
   
    If Success Then
        Serial1.Listen 'listen for incoming connections
        BluetoothConnected
        BluetoothSend("*")
    Else
        Main.connected = False
        ToastMessageShow(Main.mtconnectionerror, False)
    End If
   
End Sub

Mogens
 
Upvote 0
Hi Again,

I have copy the log when I turn on the Bluetooth device,

Hope somebody can see something there can lead me to a solution.

To me it seems like it found my module (FAM03) but not connecting to it

Mogens

Code: Copy
btm_acl_removed
btm_bda_to_acl found
btm_acl_report_role_change
btm_acl_update_busy_level
BTM_BLI_ACL_DOWN_EVT
acl hci_handle=11 is_le_link=0 connectable_mode=0x0 link_role=0
before update p_dev_rec->sec_flags=0xbe
Bletooth link down
after update p_dev_rec->sec_flags=0xb8
btm_acl_resubmit_page
btm_sec_disconnected - Clearing Pending flag
btm_sec_disconnected() sec_req:x0  State: 0  reason:19 bda:001111280373 RName:FAM03
before Update sec_flags=0xb8
btm_ble_update_mode_operation adv_mode = 0
after Update sec_flags=0xb8
bta_dm_sm_execute event:0x8
btm_get_acl_disc_reason_code
L2CA_SetDesireRole() new:x1, disallow_switch:0
bta_dm_sm_execute event:0x8
btif_dm_upstreams_cback  ev: BTA_DM_LINK_DOWN_EVT
BTA_DM_LINK_DOWN_EVT. Sending BT_ACL_STATE_DISCONNECTED
HAL bt_hal_cbacks->acl_state_changed_cb
aclStateChangeCallback: State:DisConnected to Device:00:11:11:28:03:73
btif_dm_upstreams_cback  ev: BTA_DM_BUSY_LEVEL_EVT
a2dp busy level set to 0
BTM_GetNumLeLinks
btif_check_send_bt_off() btif_core_state= (2),ACL links = (0), LE links = 0
onReceive(context, Intent { act=android.bluetooth.device.action.ACL_DISCONNECTED flg=0x4000010 cmp=com.google.android.googlequicksearchbox/com.google.android.search.core.service.BluetoothConnectionReceiver (has extras) }, [BluetoothDevice: address=00:11:11:28:03:73, alias=null, name=FAM03, majorDeviceClass=512, deviceClass=524])
Bluetooth Device Name: FAM03
 
Upvote 0
Back
Top