#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
Public Serial1 As Serial
Private astream As AsyncStreams
Dim RECEIVE(10) As Byte
Private PIN2 As Pin
Private PIN4 As Pin
Private PIN5 As Pin
Private PIN6 As Pin
Private WIFI As ESP8266WiFi
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
astream.Initialize(Serial1.Stream, "Astream_NewData", "Astream_Error")
RECEIVE(0)=65
RECEIVE(1)=66
RECEIVE(2)=67
RECEIVE(3)=68
RECEIVE(4)=69
RECEIVE(5)=70
RECEIVE(6)=71
RECEIVE(7)=72
RECEIVE(8)=73
RECEIVE(9)=74
PIN2.Initialize(2,PIN2.MODE_OUTPUT)
PIN4.Initialize(4,PIN4.MODE_INPUT)
PIN5.Initialize(5,PIN4.MODE_INPUT)
PIN6.Initialize(6,PIN4.MODE_INPUT)
'AddLooper("Looper1")
WIFI.Disconnect
End Sub
Sub Astream_NewData (Buffer() As Byte)
Log("Received: ", Buffer)
If Buffer(0) =RECEIVE(0) And Buffer(0)=RECEIVE(0) And Buffer(0)=RECEIVE(0) And Buffer(0)=RECEIVE(0) Then
Log("COMMAND ONE RECEIVED")
PIN2.DigitalWrite(True)
Else If Buffer(0) =RECEIVE(1) And Buffer(0)=RECEIVE(1) And Buffer(0)=RECEIVE(1) And Buffer(0)=RECEIVE(1) Then
Log("COMMAND TWO RECEIVED")
PIN2.DigitalWrite(False)
Else If Buffer(0) =RECEIVE(2) And Buffer(0)=RECEIVE(2) And Buffer(0)=RECEIVE(2) And Buffer(0)=RECEIVE(2) Then
Log("COMMAND THREE RECEIVED")
Else If Buffer(0) =RECEIVE(3) And Buffer(0)=RECEIVE(3) And Buffer(0)=RECEIVE(3) And Buffer(0)=RECEIVE(3) Then
Log("COMMAND FOUR RECEIVED")
End If
End Sub
Sub AStream_Error
Log("error")
End Sub
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
Public Serial1 As Serial
Private astream As AsyncStreams
Dim RECEIVE(10) As Byte
Private PIN2 As Pin
Private PIN4 As Pin
Private PIN5 As Pin
Private PIN6 As Pin
Private WIFI As ESP8266WiFi
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
astream.Initialize(Serial1.Stream, "Astream_NewData", "Astream_Error")
RECEIVE(0)=65
RECEIVE(1)=66
RECEIVE(2)=67
RECEIVE(3)=68
RECEIVE(4)=69
RECEIVE(5)=70
RECEIVE(6)=71
RECEIVE(7)=72
RECEIVE(8)=73
RECEIVE(9)=74
PIN2.Initialize(2,PIN2.MODE_OUTPUT)
PIN4.Initialize(4,PIN4.MODE_INPUT)
PIN5.Initialize(5,PIN4.MODE_INPUT)
PIN6.Initialize(6,PIN4.MODE_INPUT)
'AddLooper("Looper1")
WIFI.Disconnect
End Sub
Sub Astream_NewData (Buffer() As Byte)
Log("Received: ", Buffer)
If Buffer(0) =RECEIVE(0) And Buffer(0)=RECEIVE(0) And Buffer(0)=RECEIVE(0) And Buffer(0)=RECEIVE(0) Then
Log("COMMAND ONE RECEIVED")
PIN2.DigitalWrite(True)
Else If Buffer(0) =RECEIVE(1) And Buffer(0)=RECEIVE(1) And Buffer(0)=RECEIVE(1) And Buffer(0)=RECEIVE(1) Then
Log("COMMAND TWO RECEIVED")
PIN2.DigitalWrite(False)
Else If Buffer(0) =RECEIVE(2) And Buffer(0)=RECEIVE(2) And Buffer(0)=RECEIVE(2) And Buffer(0)=RECEIVE(2) Then
Log("COMMAND THREE RECEIVED")
Else If Buffer(0) =RECEIVE(3) And Buffer(0)=RECEIVE(3) And Buffer(0)=RECEIVE(3) And Buffer(0)=RECEIVE(3) Then
Log("COMMAND FOUR RECEIVED")
End If
End Sub
Sub AStream_Error
Log("error")
End Sub