Parcourir la source

sned set 버튼 추가 /Send Set 버튼 객체화

june9152 il y a 5 ans
Parent
commit
5268e18c68

+ 5 - 2
app/src/main/java/com/example/repeater/MainActivity.java

@@ -38,6 +38,9 @@ public class MainActivity extends AppCompatActivity implements Runnable,OnClickL
38 38
     public boolean isSend_Status() {
39 39
         return Send_Set;
40 40
     }
41
+    public void isSend_Set(boolean val) {
42
+        Send_Set = val;
43
+    }
41 44
     public static int DATA_TEST = 0;
42 45
     final private byte info_set = 1;
43 46
     final private byte rf_set = 2;
@@ -285,9 +288,9 @@ public class MainActivity extends AppCompatActivity implements Runnable,OnClickL
285 288
             case R.id.button_set:
286 289
                 /*Data Send 조건 */
287 290
                 if(isSend_Status() == true){
288
-                    Send_Set = false;
291
+                    isSend_Set(false);
289 292
                 }else{
290
-                    Send_Set = true;
293
+                    isSend_Set(true);
291 294
                 }
292 295
 
293 296
                 break;

+ 18 - 8
app/src/main/java/com/example/repeater/send.java

@@ -36,19 +36,29 @@ public class send extends TimerTask {
36 36
 
37 37
     }
38 38
     //byte[] data = {"abcdefghijklmnopqrxtuvwxyz"};
39
-    String data = "BLUECELL";
39
+    public String data = "BLUECELL";
40 40
     byte[] buffers = data.getBytes();
41
-
41
+    int test_i = 0;
42 42
     @Override
43 43
     public void run() {
44 44
         try {
45
-            String testdata = String.valueOf((this.mAcitivity).Send_Test());
46
-            Log.d("send.class / run", testdata);
47
-//            byteArrayOutputStream.write(data, 0, 5);
48
-//            dos.writeChars(testdata);
49 45
 
50
-            dos.write(buffers, 0, buffers.length);
51
-            Log.d("send.class / 메시지 전송", "성공");
46
+            if(this.mAcitivity.isSend_Status() == true) {
47
+                String testdata = String.valueOf((this.mAcitivity).Send_Test());
48
+                Log.d("send.class / run", testdata);
49
+                //            byteArrayOutputStream.write(data, 0, 5);
50
+                //            dos.writeChars(testdata);
51
+
52
+                //dos.write(buffers, 0, buffers.length);
53
+                dos.write(0xbe);
54
+
55
+                for(int i = 0; i < 50; i++)
56
+                    dos.write(i);
57
+
58
+
59
+                Log.d("send.class / 메시지 전송", "성공");
60
+                this.mAcitivity.isSend_Set(false);
61
+            }
52 62
         }catch(Exception e){
53 63
             Log.e("send.class / 전송 객체 초기화","실패");
54 64
         }