//KOD wykonywany na wcisniecie przycisku w aplikacji - to dziala
private void button_send_Click(object sender, RoutedEventArgs e)
{
string command;
short kp,kd,w1,w2,w3,w4;
if (!short.TryParse(textBox_kp.Text, out kp))
kp = 0;
if (!short.TryParse(textBox_kd.Text, out kd))
kd = 0;
if (!short.TryParse(textBox_W1.Text, out w1))
w1 = 0;
if (!short.TryParse(textBox_W2.Text, out w2))
w2 = 0;
if (!short.TryParse(textBox_W3.Text, out w3))
w3 = 0;
if (!short.TryParse(textBox_W4.Text, out w4))
w4 = 0;
command = ":#" + kp + "," + kd + "," + w1 + "," + w2 + "," + w3 + "," + w4 + ";";
blue.Send(command);
if(!blue.polaczono)
{
myRectangle.Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 155, 0, 0));
MessageBox.Show("Brak połączenia bluetooth");
}
}
//********************METODY DO WYSYLANIA DANYCH Z APLIKACJI WINDOWS PHONE**********************
public async void Send(string WhatToSend)
{
if (!polaczono)
{
return; // Stop
}
else
{
var datab = GetBufferFromByteArray(UTF8Encoding.UTF8.GetBytes(WhatToSend));
try
{
await BTSock.OutputStream.WriteAsync(datab); // Wysłanie zmiennej typu string jako ciąg bajtów
}
catch (Exception ex)
{
MessageBox.Show("Nie udało się wysłać wiadomości: n" + ex.Message);
}
}
} //Metoda do wysyłania zmiennej typu string
public async void Send(byte[] array)
{
if (!polaczono)
{
// MessageBox.Show("Brak połaczenie, nie udało się wysłać");
return; // Stop
}
else
{
var datab = GetBufferFromByteArray(array);
try
{
await BTSock.OutputStream.WriteAsync(datab); // Wysłanie ciągu bajtów
}
catch (Exception ex)
{
MessageBox.Show("Nie udało się wysłać wiadomości: n" + ex.Message);
}
}
} //Metoda do ciągu bajtów
//********************** Task do odbioru danych *********************************
public async Task<string> DoCommand()
{
StringBuilder strBuilder = new StringBuilder();
using (StreamSocket BTSock = new StreamSocket())
{
using (DataReader reader = new DataReader(BTSock.InputStream))
{
reader.InputStreamOptions = InputStreamOptions.Partial;
await reader.LoadAsync(8192);
while (reader.UnconsumedBufferLength > 0)
{
strBuilder.Append(reader.ReadString(reader.UnconsumedBufferLength));
await reader.LoadAsync(8192);
}
reader.DetachStream();
}
}
return (strBuilder.ToString());
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}