Hi, i have increment StackBuffersize to 600 the asyncstream of gsm serialnative to 200 and the asyncstream of webserver to 200 size bytes but the get request of the message to send with the GSM module is ok and all bytes are parsed, instead the send command for the gsm truncate the message and output this error, i think it's a buffer size error : "+CMS ERROR: invalid input value". The astream size buffer is 200 byte and i have set also delay time to 100ms? anyone can help me for this problem?
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			
			
				webserver with gsm module esp32:
			
		
		
		#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 600
#End Region
Sub Process_Globals
    'Private serial As SoftwareSerial
    Private retryEmptyMessages As Byte
    Private serialnative1 As Stream
    Private SMSSlot(4) As Byte
    Private astream As AsyncStreams
    Private ServerRequest As AsyncStreams
    Private EOL() As Byte = Array As Byte(13)
    Private wifi As ESP8266WiFi
    Public Socket1 As WiFiServerSocket
    Public Serial1 As Serial
    Private led As Pin
    Private PowerGSM As Pin
    Private timer1 As Timer
    Private timerLed As Timer
    Dim bc As ByteConverter
End Sub
Private Sub AppStart
    RunNative("SetIP", Null)
    
    
    
    
    Serial1.Initialize(115200)
    Log("AppStart")
    Init
    PowerGSM.Initialize(23,PowerGSM.MODE_OUTPUT)
    led.Initialize(13, led.MODE_OUTPUT)
    'led.DigitalWrite(True)
    PowerGSM.DigitalWrite(True)
    Delay(1000)
    timer1.Initialize("timer1_Tick", 10000)
    timerLed.Initialize("timerLed_Tick",1500)
    timer1.Enabled = True
    
    If wifi.Connect2("SYS-TECH","82s25e335h") Then
    
        Socket1.Initialize(8088,"Socket1_NewConnection")
        
        Socket1.Listen
        timerLed.Enabled=True
        Log(wifi.LocalIp)
        
        
    End If
    
    
End Sub
Sub Socket1_NewConnection(NewSocket As WiFiSocket)
    
    Log("Client Connesso")
    ServerRequest.Initialize(NewSocket.Stream,"ServerRequest_NewData","ServerRequest_Error")
    ServerRequest.WaitForMoreDataDelay=100
    ServerRequest.MaxBufferSize=256
    
End Sub
Sub timerLed_Tick
    led.DigitalWrite(XOR(led.DigitalRead,True))
    'Log(led.DigitalRead)
End Sub
Public Sub XOR(a As Boolean, b As Boolean) As Boolean
    Return a <> b
End Sub
Sub Timer1_Tick
    astream.Write("AT+CREG?").Write(EOL)
    
    
End Sub
Public Sub MessageArrived(msg() As Byte)
    If msg = "On" Then
    
    Else
        Log("error: ", msg)
    End If
End Sub
Public Sub Init()
    RunNative("SerialNative1", Null)
    
    
    astream.Initialize(serialnative1, "astream_NewData", Null)
    astream.WaitForMoreDataDelay = 100 'make sure that we receive full messages
    astream.MaxBufferSize=256
    astream.Write("AT+CMGF=1").Write(EOL)
    Delay(1000)
    
    astream.Write("AT+CNMI=2,1").Write(EOL) 'aBILITA EVENTI SMS
    
End Sub
'
'PhoneNumber - should start with + and include country code.
Private Sub SendSMS(phoneNumber() As Byte, message() As Byte) As Boolean
    Log(phoneNumber)
    Log(message)
    astream.Write("AT+CMGF=1").Write(EOL)
    Delay(1000)
    astream.Write("AT+CMGS=""").Write(phoneNumber).Write("""").Write(EOL)
    Delay(1000)
    astream.Write(ReplaceString(message,"%20"," ")).Write(Array As Byte(0x1a))
    'astream.Write(message).Write(Array As Byte(0x1a))
    
    
    Return True
    
End Sub
Sub AStream_NewData (Buffer() As Byte)
    
    
            Log(Buffer)
    If bc.IndexOf(Buffer, "+CMTI:") > -1 Then
        Dim i As Int = bc.IndexOf(Buffer, ",")
        Dim slot() As Byte = bc.SubString(Buffer, i + 1)
        bc.ArrayCopy(slot, SMSSlot)
        Log("SMS received, slot = ", SMSSlot)
        retryEmptyMessages = 0
        Delay(200)
        astream.Write("AT+CMGR=").Write(slot).Write(EOL)
        
        
    End If
    
    If bc.IndexOf(Buffer, "+CREG: 0,1") > -1 Or bc.IndexOf(Buffer, "+CREG: 0,5") > -1 Then
        Log("Registrato sulla rete GSM")
        timer1.Enabled=False
        astream.Write("AT+CMGF=1").Write(EOL)
        Delay(1000)
    Else
        Log("Not registered")
    End If
    
    
    
    If bc.IndexOf(Buffer, "+CMGR:") > -1 Then
        
        
            
            
                Dim counter As Int = 0
                For Each s() As Byte In bc.Split(Buffer, """")
                    If counter = 3 Then
                        Log("Inviato da: ", s)
                    Else If counter = 7 Then
                        Log("Data: ", s)
                    
                      Else If counter = 8 Then
            Log("Testo: ", s)
                    End If
                    counter = counter + 1
                Next
                Delay(100)
        astream.Write("AT+CMGD=").Write(SMSSlot).Write(EOL)
            End If
            
            
            
            
        
        
        
        
    
    
    
End Sub
Sub ServerRequest_NewData(Buffer() As Byte)
    Log("**************************")
    Log(Buffer)
    Log("**************************")
    If Socket1.Socket.Connected Then
        If bc.IndexOf(Buffer, "SEND") <> -1 Then
    
    Dim numero() As Byte
    Dim messaggio() As Byte
        ServerRequest.Write("HTTP/1.1 200").Write(CRLF)
        ServerRequest.Write("Content-Type: text/html").Write(CRLF).Write(CRLF)
        ServerRequest.Write("<html><body>ok</body></html>")
    
            
    
    
    
        Dim i1 As Int = 0
        Dim i2 As Int = 0
        For Each b1() As Byte In bc.Split(Buffer, " ")
            If i1 = 1 Then
                For Each b2() As Byte In bc.Split(b1,"$")
                    Select i2
                        Case 2
                            numero = bc.StringFromBytes(b2)
                        Case 3
                            messaggio = bc.StringFromBytes(b2)
                            Log("il messaggio inviato è: ")
                            Log(messaggio)
                    End Select
                    i2 = i2 + 1
                Next
                    
            End If
            i1 = i1 + 1
        Next
        
            Socket1.Socket.Stream.Flush
            Socket1.Socket.Close
        
        SendSMS(numero,messaggio)
        
        
        
        End If
        
End If
    
    
    Log("Socket Chiuso")
    Log(Buffer)
  
End Sub
Sub ServerRequest_Error
    Socket1.Listen
    
    Log("ERRORE LISTEN SOCKET")
    
    
End Sub
Public Sub ReplaceString(Original() As Byte, SearchFor() As Byte, ReplaceWith() As Byte) As Byte()
    'count number of occurrences
    Dim bc2 As ByteConverter
    Dim c As Int = 0
    Dim i As Int
    If SearchFor.Length <> ReplaceWith.Length Then
        i = bc2.IndexOf(Original, SearchFor)
        Do While i > -1
            c = c + 1
            i = bc2.IndexOf2(Original, SearchFor, i + SearchFor.Length)
        Loop
    End If
    Dim result(Original.Length + c * (ReplaceWith.Length - SearchFor.Length)) As Byte
    Dim prevIndex As Int = 0
    Dim targetIndex As Int = 0
    i = bc2.IndexOf(Original, SearchFor)
    Do While i > -1
        bc2.ArrayCopy2(Original, prevIndex, result, targetIndex, i - prevIndex)
        targetIndex = targetIndex + i - prevIndex
        bc2.ArrayCopy2(ReplaceWith, 0, result, targetIndex, ReplaceWith.Length)
        targetIndex = targetIndex + ReplaceWith.Length
        prevIndex = i + SearchFor.Length
        i = bc2.IndexOf2(Original, SearchFor, prevIndex)
    Loop
    If prevIndex < Original.Length Then
        bc2.ArrayCopy2(Original, prevIndex, result, targetIndex, Original.Length - prevIndex)
    End If
    Return result
End Sub
#if C
void SerialNative1(B4R::Object* unused){
::Serial1.begin(9600, SERIAL_8N1, 26, 27);
b4r_main::_serialnative1->wrappedStream = &::Serial1;
}
  void SetIP(B4R::Object* o) {
  IPAddress ip(192, 168, 1, 252); 
  IPAddress gateway(192, 168, 1, 1);
  IPAddress subnet(255, 255, 255, 0);
  IPAddress dns(192, 168, 1, 1);
  WiFi.config(ip, gateway, subnet, dns);
  }
#End If 
				 
 
		 
 
		 
 
		 
 
		 
 
		