Skip to content

Commit 5042981

Browse files
author
Vadim Zalyubovskiy
committed
RELEASE 1.0, bitches
1 parent d8f0d3b commit 5042981

File tree

10 files changed

+355
-309
lines changed

10 files changed

+355
-309
lines changed
0 Bytes
Binary file not shown.
560 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

.idea/workspace.xml

Lines changed: 322 additions & 302 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/ru/ya/kingofsystem/neurobot/Common.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public class Common {
99
private Common(){}
1010
private static BluetoothDevice mindWave, robot;
1111

12+
public static CharSequence headHost;
13+
1214
public static void setMindWave(BluetoothDevice mindWave) {
1315
Common.mindWave = mindWave;
1416
}

app/src/main/java/ru/ya/kingofsystem/neurobot/ConnectToDevices.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import android.widget.Toast;
1919

2020
import java.util.ArrayList;
21+
import java.util.concurrent.Callable;
2122

2223
/**
2324
* Created by tamtaradam on 27.08.15.
@@ -75,6 +76,7 @@ public void onDeviceChoosen(String mac, String name) {
7576
Toast.makeText(getApplicationContext(), getString(R.string.get_next_device),
7677
Toast.LENGTH_LONG).show();
7778
Common.setRobot(btAdapter.getRemoteDevice(mac));
79+
Common.headHost = ((TextView) findViewById(R.id.ip_addres)).getText();
7880
btAdapter.cancelDiscovery();
7981
Intent intent = new Intent(ConnectToDevices.this, ButtonControl.class);
8082
startActivity(intent);

app/src/main/java/ru/ya/kingofsystem/neurobot/RobotConnector.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@
1515
* Валька уебал все блютузники и теперь коннектимся через сеть
1616
*/
1717
public class RobotConnector implements Runnable{
18-
private String host;
18+
private CharSequence host;
1919
private int port;
2020
private Socket socket;
2121
private DataOutput out;
2222
private DataInput in;
23-
public RobotConnector(String host, int port) {
23+
public RobotConnector(CharSequence host, int port) {
2424
this.host = host;
2525
this.port = port;
2626
}
2727

2828
public RobotConnector() {
29-
this("192.168.0.177", 22288); // Я в депрессии и не буду делать автоматический поиск :(
29+
this(Common.headHost, 22288); // Я в депрессии и не буду делать автоматический поиск :(
3030
}
3131

3232
@Override
3333
public void run() {
3434
// FIXME: 06.09.15 Я пока не придумал, что арда нaм присылает, хотя я вру
3535
try {
3636
socket = new Socket();
37-
socket.connect(new InetSocketAddress(host, port));
37+
socket.connect(new InetSocketAddress(host.toString(), port));
3838
out = new DataOutputStream(socket.getOutputStream());
3939
in = new DataInputStream(socket.getInputStream());
4040
} catch (IOException e) {
@@ -45,7 +45,7 @@ public void run() {
4545

4646
public void sendData(String str) {
4747
try {
48-
out.writeChars(str+'\n');
48+
out.writeChars(str+'n');
4949
Log.d("RobotConnector", str);
5050
} catch (IOException | NullPointerException e) {
5151
e.printStackTrace();

app/src/main/res/layout/activity_start.xml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
android:layout_alignParentStart="true"
5252
android:layout_alignParentRight="true"
5353
android:layout_alignParentEnd="true"
54-
android:layout_below="@+id/textView3"
5554
android:layout_alignParentBottom="true"
56-
android:fillViewport="false">
55+
android:fillViewport="false"
56+
android:layout_below="@+id/ip_addres">
5757

5858
<LinearLayout
5959
android:orientation="vertical"
@@ -65,4 +65,25 @@
6565
</LinearLayout>
6666
</ScrollView>
6767

68+
<EditText
69+
android:layout_width="wrap_content"
70+
android:layout_height="wrap_content"
71+
android:id="@+id/ip_addres"
72+
android:layout_below="@+id/textView3"
73+
android:layout_alignLeft="@+id/btnDiscover"
74+
android:layout_alignStart="@+id/btnDiscover"
75+
android:layout_alignRight="@+id/btnDiscover"
76+
android:layout_alignEnd="@+id/btnDiscover" />
77+
78+
<TextView
79+
android:layout_width="wrap_content"
80+
android:layout_height="wrap_content"
81+
android:textAppearance="?android:attr/textAppearanceSmall"
82+
android:text="@string/head_ip"
83+
android:id="@+id/textView9"
84+
android:layout_alignBaseline="@+id/ip_addres"
85+
android:layout_alignBottom="@+id/ip_addres"
86+
android:layout_toLeftOf="@+id/ip_addres"
87+
android:layout_toStartOf="@+id/ip_addres" />
88+
6889
</RelativeLayout>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
<string name="blink_strength">Сила моргания: </string>
2121
<string name="sensitivy">Чувствительность: </string>
2222
<string name="bad_signal">Плохой сигнал с MindWave</string>
23+
<string name="head_ip">IP сервера: </string>
2324
</resources>

0 commit comments

Comments
 (0)