A Arturs Member Licensed User Longtime User Nov 7, 2015 #1 Hi I am trying to manage Serial,Bluetooth,AsyncStreamsText in service module. Bluetooth,AsyncStreamText work well but I have a problem with serial. When a connection is estabilshed the Serial_connected event is not called . I do not have any ideas what I do wrongly. Code: Copy Sub serial1_Connected (Success As Boolean) Log("the event was called") End Sub Cannot the serial object work in service module ? Code: Copy Sub Service_Create 'This is the program entry point. 'This is a good place to load resources that are not specific to a single activity. admin.Initialize("admin") serial1.Initialize("serial1") foundDEvices.Initialize End Sub Regards Artur Last edited: Nov 7, 2015
Hi I am trying to manage Serial,Bluetooth,AsyncStreamsText in service module. Bluetooth,AsyncStreamText work well but I have a problem with serial. When a connection is estabilshed the Serial_connected event is not called . I do not have any ideas what I do wrongly. Code: Copy Sub serial1_Connected (Success As Boolean) Log("the event was called") End Sub Cannot the serial object work in service module ? Code: Copy Sub Service_Create 'This is the program entry point. 'This is a good place to load resources that are not specific to a single activity. admin.Initialize("admin") serial1.Initialize("serial1") foundDEvices.Initialize End Sub Regards Artur
Erel B4X founder Staff member Licensed User Longtime User Nov 8, 2015 #2 Can you post the full service code? Upvote 0
A Arturs Member Licensed User Longtime User Nov 8, 2015 #3 Tomarrow I spent many hours to solve my problem but without success so I decided to change some part of my code and use your solution from File Transfer (very good example) https://www.b4x.com/android/forum/t...nd-and-receive-files-with-asyncstreams.30493/ but I have one question related to your code In Main File you use StateChanged Event Code: Copy Sub Admin_StateChanged (NewState As Int, OldState As Int) UpdateUI End Sub but In Service Module the same Event Code: Copy Sub admin_StateChanged (NewState As Int, OldState As Int) If NewState = admin.STATE_ON Then serial1.Listen2("na", uuid) End Sub In which mode your service mode works ? Which Event will have higher priority ? Which will be first ? i mean service in foregroundmode Regards Artur Upvote 0
Tomarrow I spent many hours to solve my problem but without success so I decided to change some part of my code and use your solution from File Transfer (very good example) https://www.b4x.com/android/forum/t...nd-and-receive-files-with-asyncstreams.30493/ but I have one question related to your code In Main File you use StateChanged Event Code: Copy Sub Admin_StateChanged (NewState As Int, OldState As Int) UpdateUI End Sub but In Service Module the same Event Code: Copy Sub admin_StateChanged (NewState As Int, OldState As Int) If NewState = admin.STATE_ON Then serial1.Listen2("na", uuid) End Sub In which mode your service mode works ? Which Event will have higher priority ? Which will be first ? i mean service in foregroundmode Regards Artur
Erel B4X founder Staff member Licensed User Longtime User Nov 8, 2015 #4 Please start a new thread for a new question. Upvote 0