SignalHandler 11
Signal - 11
Stack Trace: (
"0 Atlas SOS SignalHandler + 80",
"1 libsystem_platform.dylib 0x00000001ef828d9c AF56B99B-9ABB-3DC7-B85E-F74352F87B30 + 28060",
"2 Atlas SOS -[B4ICommon CallSub4::::] + 336",
"3 Atlas SOS -[B4ICommon CallSub2::::] + 372",
"4 Atlas SOS -[ResumableSub_b4xloadingindicator_MainLoop resume::] + 1220",
"5 Atlas SOS __21-[B4ICommon Sleep:::]_block_invoke + 60",
"6 libdispatch.dylib ECEF88A0-245A-33C1-823D-3160E1F3D674 + 397976",
"7 libdispatch.dylib ECEF88A0-245A-33C1-823D-3160E1F3D674 + 24616",
"8 libdispatch.dylib ECEF88A0-245A-33C1-823D-3160E1F3D674 + 93540",
"9 libdispatch.dylib ECEF88A0-245A-33C1-823D-3160E1F3D674 + 64452"
)
SignalHandler 11
Signal - 11
Stack Trace: (
"0 Atlas SOS SignalHandler + 80",
"1 libsystem_platform.dylib 0x00000001dff08d9c B4042AE8-5313-3145-93B9-B171F93814A8 + 28060",
"2 Atlas SOS __21-[B4ICommon Sleep:::]_block_invoke + 60",
"3 libdispatch.dylib 03AD11F9-67AE-3219-ACA3-DF0A9AF629D4 + 397976",
"4 libdispatch.dylib 03AD11F9-67AE-3219-ACA3-DF0A9AF629D4 + 24616",
"5 libdispatch.dylib 03AD11F9-67AE-3219-ACA3-DF0A9AF629D4 + 93540",
"6 libdispatch.dylib 03AD11F9-67AE-3219-ACA3-DF0A9AF629D4 + 64452",
"7 CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 633240",
"8 CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 609784",
"9 CoreFoundation CFRunLoopRunSpecific + 572"
)
Why not: Main.Show_Busy(False) ?callsub2(Main,"show_busy",False)
-[__NSCFString addObject:]: unrecognized selector sent to instance 0x28232e2b0
Stack Trace: (
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 1161532
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 174432
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 1171332
CoreFoundation _CF_forwarding_prep_0 + 92
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 7744
Atlas SOS +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
Atlas SOS -[B4I raiseEvent:event:params:] + 548
Atlas SOS __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
libdispatch.dylib 03AD11F9-67AE-3219-ACA3-DF0A9AF629D4 + 393904
libdispatch.dylib 03AD11F9-67AE-3219-ACA3-DF0A9AF629D4 + 397976
libdispatch.dylib 03AD11F9-67AE-3219-ACA3-DF0A9AF629D4 + 64736
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 633240
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 609784
CoreFoundation CFRunLoopRunSpecific + 572
GraphicsServices GSEventRunModal + 160
UIKitCore 950536E0-E3E0-3B3B-B173-BB8D185B2352 + 11731664
UIKitCore UIApplicationMain + 164
Atlas SOS main + 112
libdyld.dylib B6D35F8F-B651-3B36-972B-14B32251C4CF + 4416
)
Sub show_busy(pBusy As Boolean)
pvBusyVisible = pBusy
' // https://www.b4x.com/android/forum/threads/app-unexpected-crash-very-little-to-go-on.135269/#post-855522
' Try
' If pBusy Then
' pvBusy.show
' Else
' ' // rest color
' pvBusy.hide
' End If
' Catch
' mod_functions.writelog($"main::show_busy, pBusy=${pBusy}, error - ${LastException.message}"$)
' End Try
End Sub
Sub tmrAppForeground_tick
manage_indicators
End sub
Sub manage_indicators
' // Comms busy Indicator - Green
If pvBusyVisible Then
If Not(pvBusy.mBase.Visible) Then
pvBusy.show
End If
Else
If pvBusy.mBase.Visible Then
pvBusy.Hide
End If
End If
End Sub
SignalHandler 11
Signal - 11
Stack Trace: (
"0 Atlas SOS SignalHandler + 80",
"1 libsystem_platform.dylib 0x00000001dff08d9c B4042AE8-5313-3145-93B9-B171F93814A8 + 28060",
"2 libobjc.A.dylib 2E8A4074-A51D-31B4-A6B0-B120BCB4E21F + 152476",
"3 libobjc.A.dylib objc_autoreleasePoolPop + 208",
"4 CoreFoundation _CFAutoreleasePoolPop + 28",
"5 CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 629876",
"6 CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 609852",
"7 CoreFoundation CFRunLoopRunSpecific + 572",
"8 GraphicsServices GSEventRunModal + 160",
"9 UIKitCore 950536E0-E3E0-3B3B-B173-BB8D185B2352 + 11731664"
)
SignalHandler 11
Signal - 11
Stack Trace: (
"0 Atlas SOS SignalHandler + 80",
"1 libsystem_platform.dylib 0x00000001dff08d9c B4042AE8-5313-3145-93B9-B171F93814A8 + 28060",
"2 CoreGraphics CGDataProviderRetainBytePtr + 152",
"3 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 189868",
"4 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 194380",
"5 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 198208",
"6 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 1508720",
"7 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 755076",
"8 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 930504",
"9 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 935216"
)
10/20/2021 08:50:06.654 - Atlas iSOS - main::BarButton_Click, TPA_ACTIVE.active=0
10/20/2021 08:50:10.431 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:50:11.468 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:50:12.436 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201050&&2021/10/200850 Test▼353837081304527♦
10/20/2021 08:50:17.452 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:50:17.453 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 1
10/20/2021 08:50:17.457 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:50:18.499 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:50:19.468 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201050&&2021/10/200850 Test▼353837081304527♦
10/20/2021 08:50:21.382 - Atlas iSOS - Battery state: Charging, level: 71%
10/20/2021 08:50:24.494 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:50:24.495 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 2
10/20/2021 08:50:24.503 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:50:25.538 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:50:26.507 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201050&&2021/10/200850 Test▼353837081304527♦
10/20/2021 08:50:31.529 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:50:31.530 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 3
10/20/2021 08:50:31.535 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:50:32.627 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:50:33.544 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201050&&2021/10/200850 Test▼353837081304527♦
10/20/2021 08:50:38.560 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:50:38.561 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 4
10/20/2021 08:50:38.567 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:50:39.606 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:50:40.574 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201050&&2021/10/200850 Test▼353837081304527♦
10/20/2021 08:50:45.595 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:50:45.596 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 5
10/20/2021 08:50:45.604 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:50:46.645 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:50:47.612 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201050&&2021/10/200850 Test▼353837081304527♦
10/20/2021 08:50:52.625 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:50:52.626 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 6
10/20/2021 08:50:52.637 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:50:53.677 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:50:54.649 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201050&&2021/10/200850 Test▼353837081304527♦
SignalHandler 11
10/20/2021 08:50:59.674 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:50:59.675 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 7
10/20/2021 08:50:59.681 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:51:00.708 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:51:01.684 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201050&&2021/10/200850 Test▼353837081304527♦
10/20/2021 08:51:06.699 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:51:06.700 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 8
10/20/2021 08:51:06.707 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:51:07.742 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:51:08.716 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201050&&2021/10/200850 Test▼353837081304527♦
10/20/2021 08:51:13.733 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:51:13.734 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 9
10/20/2021 08:51:13.739 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:51:14.776 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:51:15.749 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201050&&2021/10/200850 Test▼353837081304527♦
SignalHandler 11
Signal - 11
Stack Trace: (
"0 Atlas SOS SignalHandler + 80",
"1 libsystem_platform.dylib 0x00000001dff08d9c B4042AE8-5313-3145-93B9-B171F93814A8 + 28060",
"2 CoreGraphics CGDataProviderRetainBytePtr + 152",
"3 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 189868",
"4 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 194380",
"5 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 198208",
"6 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 1508720",
"7 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 755076",
"8 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 930504",
"9 QuartzCore CA5D4F2E-278A-3CCF-AB0A-A320377A3183 + 935216"
)
10/20/2021 08:21:28.836 - Atlas iSOS - main::BarButton_Click, TPA_ACTIVE.active=0
10/20/2021 08:21:30.181 - Atlas iSOS - Battery state: Charging, level: 71%
10/20/2021 08:21:33.086 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:21:34.119 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:21:35.092 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201021&&2021/10/200821 Test▼353837081304527♦
10/20/2021 08:21:40.111 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:21:40.112 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 1
10/20/2021 08:21:40.117 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:21:41.160 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:21:42.130 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201021&&2021/10/200821 Test▼353837081304527♦
10/20/2021 08:21:47.140 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:21:47.141 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 2
10/20/2021 08:21:47.145 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:21:48.185 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:21:49.151 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201021&&2021/10/200821 Test▼353837081304527♦
10/20/2021 08:21:54.172 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:21:54.173 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 3
SignalHandler 11
Signal - 11
Stack Trace: (
"0 Atlas SOS SignalHandler + 80",
"1 libsystem_platform.dylib 0x00000001dff08d9c B4042AE8-5313-3145-93B9-B171F93814A8 + 28060",
"2 libobjc.A.dylib 2E8A4074-A51D-31B4-A6B0-B120BCB4E21F + 152476",
"3 libobjc.A.dylib objc_autoreleasePoolPop + 208",
"4 CoreFoundation _CFAutoreleasePoolPop + 28",
"5 CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 629876",
"6 CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 609852",
"7 CoreFoundation CFRunLoopRunSpecific + 572",
"8 GraphicsServices GSEventRunModal + 160",
"9 UIKitCore 950536E0-E3E0-3B3B-B173-BB8D185B2352 + 11731664"
)
10/20/2021 08:00:44.222 - Atlas iSOS - main::BarButton_Click, TPA_ACTIVE.active=0
10/20/2021 08:00:49.485 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:00:50.524 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:00:51.488 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201000&&2021/10/200800 Test▼353837081304527♦
10/20/2021 08:00:56.507 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:00:56.508 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 1
10/20/2021 08:00:56.514 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:00:57.554 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:00:58.526 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201000&&2021/10/200800 Test▼353837081304527♦
10/20/2021 08:01:03.541 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:01:03.542 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 2
10/20/2021 08:01:03.546 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:01:04.586 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:01:05.558 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201000&&2021/10/200800 Test▼353837081304527♦
10/20/2021 08:01:10.573 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:01:10.574 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 3
10/20/2021 08:01:10.577 - Atlas iSOS - cls_tpa_sender::Initialize
10/20/2021 08:01:11.616 - Atlas iSOS - cls_tpa_sender::socket_Connected, Connected = 1
10/20/2021 08:01:12.583 - Atlas iSOS - cls_tpa_sender::DATA TRANSMIT: ☻TPAON2021/10/201000&&2021/10/200800 Test▼353837081304527♦
10/20/2021 08:01:17.595 - Atlas iSOS - mod_tpa_process::tpa_new_completed() success=0
10/20/2021 08:01:17.596 - Atlas iSOS - mod_tpa_process::tpa_new_completed 0 4
-[__NSCFString addObject:]: unrecognized selector sent to instance 0x28232e2b0
Stack Trace: (
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 1161532
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 174432
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 1171332
CoreFoundation _CF_forwarding_prep_0 + 92
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 7744
Atlas SOS +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
Atlas SOS -[B4I raiseEvent:event:params:] + 548
Atlas SOS __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
libdispatch.dylib 03AD11F9-67AE-3219-ACA3-DF0A9AF629D4 + 393904
libdispatch.dylib 03AD11F9-67AE-3219-ACA3-DF0A9AF629D4 + 397976
libdispatch.dylib 03AD11F9-67AE-3219-ACA3-DF0A9AF629D4 + 64736
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 633240
CoreFoundation 5BBDEA97-01D2-30D8-8123-43118E96A409 + 609784
CoreFoundation CFRunLoopRunSpecific + 572
GraphicsServices GSEventRunModal + 160
UIKitCore 950536E0-E3E0-3B3B-B173-BB8D185B2352 + 11731664
UIKitCore UIApplicationMain + 164
Atlas SOS main + 112
libdyld.dylib B6D35F8F-B651-3B36-972B-14B32251C4CF + 4416
)
My uneducated guess is that somewhere you have an event sub or Wait For call, with a parameter with the wrong type.-[__NSCFString addObject:]: unrecognized selector sent to instance 0x28232e2b0
Ok, I will now check this in debug modeMy uneducated guess is that somewhere you have an event sub or Wait For call, with a parameter with the wrong type.
Can you post the code?I was Initializing the socket class (Dim ws_data As cls_sockets) after the socket was closed
Sub Class_Globals
Dim callback As Object
Dim event As String
Dim res As Boolean
Dim tmrHook As Timer
Dim comW As tComms
Dim ws_data As cls_sockets
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(callBackModule As Object,callBackEvent As String)
mod_functions.writelog("cls_tpa_sender::Initialize")
callback = callBackModule
event = callBackEvent
comW.Initialize
ws_data.Initialize(Me,"socket")
tmrHook.Initialize("tmrHook",1000)
tmrHook.Enabled = True
End Sub
Sub socket_failure(pEvent As String)
' // we need to re-init the socket as that is the way the socket control works.
ws_data.Initialize(Me,"socket")
comW.Initialize
res = False
mod_functions.writelog("cls_tpa_sender::socket_failure, " & pEvent )
End Sub
Sub socket_Connected(bConnected As Boolean)
mod_functions.writelog($"cls_tpa_sender::socket_Connected, Connected = ${bConnected}"$)
If Not(bConnected) Then
stop_service
End If
End Sub
Sub socket_DataArrival(sData As String)
Try
comW.buffer = comW.buffer & sData
mod_functions.writelog("cls_tpa_sender::socket_DataArrival, Server (" & Main.APPSET.RT_wifi.ws.host & ") Response (DATA) " & comW.buffer)
' // we have not sent a packet yet
If Not(Main.APPSET.RT_wifi.pkt_alert_sent) Then
mod_functions.writelog("cls_tpa_sender::socket_DataArrival, ignoring this data =>" & comW.buffer & "<=")
Return
End If
' // Alert paacket sent was acknowledged
If comW.buffer.Contains("$ok_data") Then
res = True
' // close the connection
mod_functions.writelog("cls_tpa_sender::socket Closed, Server (" & Main.APPSET.RT_wifi.ws.host & ")" )
ws_data.ws_close
' ws_data.Initialize(Me,"socket") <- Change to make it work
' comW.Initialize
' // reset flags
Main.APPSET.RT_wifi.pkt_alert = ""
Main.APPSET.RT_wifi.pkt_alert_pending = False
Main.APPSET.RT_wifi.pkt_alert_sent = False
stop_service
End If
Catch
mod_functions.writelog("cls_tpa_sender::socket_DataArrival, (" & sData & ") " & LastException.Message )
End Try
End Sub
Sub tmrHook_tick
If Main.APPSET.RT_wifi.pkt_alert = "" Then
mod_functions.writelog($"cls_tpa_sender::Main.APPSET.RT_wifi.pkt_alert is Empty"$)
stop_service
Return
End If
Try
' // get connection
If Not(ws_data.ws_isConnected) Then
If Not(comW.connectionRequested) Then
' // request a connection
comW.connectionRequested = True
comW.pktACK = True
ws_data.ws_connect(Main.APPSET.RT_wifi.ws.host,Main.APPSET.RT_wifi.ws.port,5000)
End If
End If
Catch
res = False
comW.responseTimeout = DateTime.now
mod_functions.writelog($"cls_tpa_sender::connectionRequested: error - ${LastException.Message}"$)
stop_service
Return
End Try
Try
' // got a connection
If ws_data.ws_isConnected Then
' // got data
If Main.APPSET.RT_wifi.pkt_alert <> "" Then
If comW.pktACK Then
' // send wifi data
comW.pktACK = False
Main.APPSET.RT_wifi.pkt_alert_sent = True
mod_functions.writelog("cls_tpa_sender::DATA TRANSMIT: " & Main.APPSET.RT_wifi.pkt_alert)
ws_data.ws_senddata(Main.APPSET.RT_wifi.pkt_alert)
comW.responseTimeout = DateTime.Now + (DateTime.TicksPerSecond * 5)
End If
End If
End If
Catch
res = False
comW.responseTimeout = DateTime.now
mod_functions.writelog($"cls_tpa_sender::DATA TRANSMIT: error - ${LastException.Message}"$)
stop_service
Return
End Try
' // we sent a packet
Try
If Main.APPSET.RT_wifi.pkt_alert_sent Then
' // we are waiting for a resposne
If comW.responseTimeout > 0 Then
' // did we time out
If comW.responseTimeout < DateTime.now Then
' // close the connection
ws_data.ws_close
' ws_data.Initialize(Me,"socket") <- Change to make it work
' comW.Initialize
'Main.APPSET.RT_wifi.pkt_alert = ""
Main.APPSET.RT_wifi.pkt_alert_sent = False
stop_service
End If
End If
End If
Catch
res = False
comW.responseTimeout = DateTime.now
mod_functions.writelog($"cls_tpa_sender::responseTimeout: error - ${LastException.Message}"$)
stop_service
Return
End Try
End Sub
Sub stop_service
mod_functions.writelog($"cls_tpa_sender::stop_service, calling ${event} with ${res}"$)
tmrHook.enabled = False
CallSubDelayed2(callback,event,res)
End Sub
'Class module
Sub Class_Globals
Private callback As Object
Private event As String
Private WS_SOCKET As Socket
Private WS_IO_ASTREAM As AsyncStreams
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(callBackModule As Object,callBackEvent As String)
callback = callBackModule
event = callBackEvent
WS_SOCKET.Initialize("ws_socket")
End Sub
Sub ws_socket_Connected(Connected As Boolean)As Boolean
Try
If Connected = True Then
If Not(WS_IO_ASTREAM.IsInitialized ) Then
WS_IO_ASTREAM.Initialize(WS_SOCKET.InputStream,WS_SOCKET.OutputStream,"wsStream")
End If
Else
If SubExists(callback, event & "_failure",1) Then
CallSub2(callback, event & "_failure",LastException.Message)
End If
End If
If SubExists(callback, event & "_Connected",1) Then
CallSub2(callback, event & "_Connected",Connected)
End If
Catch
If SubExists(callback, event & "_socket_failure",1) Then
CallSub2(callback, event & "_failure",LastException.Message)
End If
End Try
Return Connected
End Sub
Sub wsStream_NewData (Buffer() As Byte)
Dim wsData As String
wsData = BytesToString(Buffer, 0, Buffer.Length, "ASCII")
If SubExists(callback, event & "_DataArrival",1) Then
CallSub2(callback, event & "_DataArrival",wsData)
End If
End Sub
Sub wsStream_Terminated()
ws_close
End Sub
Sub ws_connect(pHost As String, pPort As Int, pTimeout As Int)
'Log($"ws_connect() ${pHost} ${pPort} ${pTimeout} "$)
If Not(WS_SOCKET.IsInitialized) Then
WS_SOCKET.Initialize("ws_socket")
End If
WS_SOCKET.Connect(pHost,pPort,pTimeout)
End Sub
Sub ws_close()
Try
'// close the data stream
'mod_functions.writelog("cls_sockets::ws_close() Closing AsyncStream")
WS_IO_ASTREAM.Close
'mod_functions.writelog("cls_sockets::ws_close() Re-initialising Socket")
WS_SOCKET.Initialize("")
If SubExists(callback, event & "_Closed",0) Then
CallSub(callback, event & "_Closed")
End If
Catch
mod_functions.writelog("cls_sockets::ws_close() error - " & LastException.Message)
End Try
End Sub
Sub ws_isConnected() As Boolean
Return WS_SOCKET.Connected
End Sub
Sub ws_isInitialised() As Boolean
Return WS_SOCKET.IsInitialized
End Sub
Sub is_buffer_empty() As Boolean
If WS_IO_ASTREAM.IsInitialized Then
If WS_IO_ASTREAM.OutputQueueSize = 0 Then
Return True
Else
Return False
End If
Else
Return True
End If
End Sub
Sub getBufferSize() As Long
If WS_IO_ASTREAM.IsInitialized Then
Return WS_IO_ASTREAM.OutputQueueSize
Else
Return -1
End If
End Sub
Sub ws_senddata(pData As String)
Dim Buffer() As Byte
If Not(ws_isConnected) Then
Return
End If
Try
If Not(WS_IO_ASTREAM.IsInitialized) Then
WS_IO_ASTREAM.Initialize(WS_SOCKET.InputStream,WS_SOCKET.OutputStream,"wsStream")
End If
Buffer = pData.GetBytes("windows-1255")
If Not(WS_IO_ASTREAM.Write(Buffer)) Then
If SubExists(callback, event & "_failure",1) Then
CallSub2(callback, event & "_failure",LastException.Message)
End If
End If
Catch
Log(LastException.Message)
End Try
End Sub
Ok, point taken, I will close this thread, all seems to be ok now.It is safer to Dim the variable again before you call Initialize.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?