hi all,
I don't know how to explain this problem.
I need to write a characteristic of ESP32 chip via BLE.
I have two cases:
1) I need to write a letter, in particular "à"
2) I need to write hex FF
I use this code:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
on starter module code is:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Before start App I emptied characteristics (using nRF Connect app)
I have this log:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Then I read characteristics (via nRF Connect) and I found:
on C314: C3 A0 (two characters instead of 1 and à is 133 (hex 85))
on C315: empty
Where am I doing wrong?
			
			I don't know how to explain this problem.
I need to write a characteristic of ESP32 chip via BLE.
I have two cases:
1) I need to write a letter, in particular "à"
2) I need to write hex FF
I use this code:
			
				B4X:
			
		
		
		'    CHIAMATA BLUETOOTH C314_trasponder_index_06
    Main.chichiededellapedana="CicloCard"
    Log("ciclocard C314")
    Dim s As String ="à"
    CallSub2(Starter, "SendC314", s)
    Sleep(1000)
'    CHIAMATA BLUETOOTH C315_trasponder_index_07 id cliente
    Main.chichiededellapedana="CicloCard"
    Log("ciclocard C315")
    Dim s As String
    Dim bt1(4) As Byte
    bt1(0)=17
    bt1(1)=255
    bt1(2)=32
    bt1(3)=32
    s = BytesToString(bt1, 0, bt1.Length, "UTF-8")
    CallSub2(Starter, "SendC315", s)
			
				B4X:
			
		
		
		Public Sub SendC314(cmsg As String)
    LogColor("Dentro SendC314"&" Messaggio "&cmsg,Colors.red)
    qualecaratteristica = C314_trasponder_index_06
    SendTrasponder(cmsg.GetBytes("utf8"))
End Sub
Public Sub SendC315(cmsg As String)
    LogColor("Dentro SendC315"&" Messaggio "&cmsg,Colors.red)
    qualecaratteristica = C315_trasponder_index_07
    SendTrasponder(cmsg.GetBytes("utf8"))
End Sub
Public Sub SendTrasponder(msg() As Byte)
    Dim strmsg As String = BytesToString(msg, 0, msg.Length, "utf8")
    LogColor("Dentro SendTrasponder Blestate:"&BLEState&" Messaggio "&strmsg,Colors.red)
    messagesToSend.Add(TrimMessage(msg))
'    qualecaratteristica = C329_trasponder_index_31
    If messagesToSend.Size = 1 Then
        Do While messagesToSend.Size > 0
            Try
                manager.WriteData(ServiceId, qualecaratteristica, messagesToSend.Get(0))
            Catch
                FailedToSend
                Return
            End Try
            Wait For Manager_WriteComplete (Characteristic As String, Status As Int)
            If Status <> 0 Then
                FailedToSend
            End If
            If connected = False Or messagesToSend.Size = 0 Then Return
            messagesToSend.RemoveAt(0)
        Loop
    End If
End SubBefore start App I emptied characteristics (using nRF Connect app)
I have this log:
			
				B4X:
			
		
		
		ciclocard C314
Dentro SendC314 Messaggio à
Dentro SendTrasponder Blestate:1 Messaggio à
ciclocard C315
Dentro SendC315 Messaggio �
Dentro SendTrasponder Blestate:1 Messaggio �
Failed to send message. Disconnecting.Then I read characteristics (via nRF Connect) and I found:
on C314: C3 A0 (two characters instead of 1 and à is 133 (hex 85))
on C315: empty
Where am I doing wrong?
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
				 
 
		 
 
		 
 
		