AI2 Component  (Version nb184)
BluetoothConnectionBase.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2009-2011 Google, All Rights reserved
3 // Copyright 2011-2012 MIT, All rights reserved
4 // Released under the Apache License, Version 2.0
5 // http://www.apache.org/licenses/LICENSE-2.0
6 
7 package com.google.appinventor.components.runtime;
8 
20 
21 import android.util.Log;
22 
23 import java.io.BufferedInputStream;
24 import java.io.BufferedOutputStream;
25 import java.io.ByteArrayOutputStream;
26 import java.io.IOException;
27 import java.io.InputStream;
28 import java.io.OutputStream;
29 import java.io.UnsupportedEncodingException;
30 import java.nio.ByteOrder;
31 import java.util.ArrayList;
32 import java.util.List;
33 
40 @SimpleObject
43 
44  protected final String logTag;
45  private final List<BluetoothConnectionListener> bluetoothConnectionListeners =
46  new ArrayList<BluetoothConnectionListener>();
47 
48  private ByteOrder byteOrder;
49  private String encoding;
50  private byte delimiter;
51  protected boolean disconnectOnError;
52  protected boolean secure;
53 
54  private Object connectedBluetoothSocket;
55  private InputStream inputStream;
56  private OutputStream outputStream;
57  private final int sdkLevel;
58 
62  protected BluetoothConnectionBase(ComponentContainer container, String logTag) {
63  this(container.$form(), logTag, SdkLevel.getLevel());
65  }
66 
67  private BluetoothConnectionBase(Form form, String logTag, int sdkLevel) {
68  super(form);
69  this.logTag = logTag;
70  this.sdkLevel = sdkLevel;
71  this.disconnectOnError = false;
72 
73  HighByteFirst(false); // Lego Mindstorms NXT is low-endian, so false is a good default.
74  CharacterEncoding("UTF-8");
75  DelimiterByte(0);
76  Secure(true);
77  }
78 
82  protected BluetoothConnectionBase(OutputStream outputStream, InputStream inputStream) {
83  this((Form) null, (String) null, SdkLevel.LEVEL_ECLAIR_MR1);
84  this.connectedBluetoothSocket = "Not Null";
85  this.outputStream = outputStream;
86  this.inputStream = inputStream;
87  }
88 
94  void addBluetoothConnectionListener(BluetoothConnectionListener listener) {
95  bluetoothConnectionListeners.add(listener);
96  }
97 
103  void removeBluetoothConnectionListener(BluetoothConnectionListener listener) {
104  bluetoothConnectionListeners.remove(listener);
105  }
106 
107  private void fireAfterConnectEvent() {
108  for (BluetoothConnectionListener listener : bluetoothConnectionListeners) {
109  listener.afterConnect(this);
110  }
111  }
112 
113  private void fireBeforeDisconnectEvent() {
114  for (BluetoothConnectionListener listener : bluetoothConnectionListeners) {
115  listener.beforeDisconnect(this);
116  }
117  }
118 
122  public final void Initialize() {
123  }
124 
125  @SimpleEvent(description = "The BluetoothError event is no longer used. " +
126  "Please use the Screen.ErrorOccurred event instead.",
127  userVisible = false)
128  public void BluetoothError(String functionName, String message) {
129  }
130 
131  protected void bluetoothError(String functionName, int errorNumber, Object... messageArgs) {
132  form.dispatchErrorOccurredEvent(this, functionName, errorNumber, messageArgs);
133  }
134 
141  @SimpleProperty(description = "Whether Bluetooth is available on the device",
142  category = PropertyCategory.BEHAVIOR)
143  public boolean Available() {
144  Object bluetoothAdapter = BluetoothReflection.getBluetoothAdapter();
145  if (bluetoothAdapter != null) {
146  return true;
147  }
148  return false;
149  }
150 
156  @SimpleProperty(description = "Whether Bluetooth is enabled",
157  category = PropertyCategory.BEHAVIOR)
158  public boolean Enabled() {
159  Object bluetoothAdapter = BluetoothReflection.getBluetoothAdapter();
160  if (bluetoothAdapter != null) {
161  if (BluetoothReflection.isBluetoothEnabled(bluetoothAdapter)) {
162  return true;
163  }
164  }
165  return false;
166  }
167 
168  protected final void setConnection(Object bluetoothSocket) throws IOException {
169  connectedBluetoothSocket = bluetoothSocket;
170  inputStream = new BufferedInputStream(
171  BluetoothReflection.getInputStream(connectedBluetoothSocket));
172  outputStream = new BufferedOutputStream(
173  BluetoothReflection.getOutputStream(connectedBluetoothSocket));
174  fireAfterConnectEvent();
175  }
176 
180  @SimpleFunction(description = "Disconnect from the connected Bluetooth device.")
181  public final void Disconnect() {
182  if (connectedBluetoothSocket != null) {
183  fireBeforeDisconnectEvent();
184  try {
185  BluetoothReflection.closeBluetoothSocket(connectedBluetoothSocket);
186  Log.i(logTag, "Disconnected from Bluetooth device.");
187  } catch (IOException e) {
188  Log.w(logTag, "Error while disconnecting: " + e.getMessage());
189  }
190  connectedBluetoothSocket = null;
191  }
192  inputStream = null;
193  outputStream = null;
194  }
195 
200  description = "On devices with API level 14 (LEVEL_ICE_CREAM_SANDWICH) or higher, " +
201  "this property returned is accurate. But on old devices with API level lower than 14, " +
202  "it may not return the current state of connection(e.g., it might be disconnected but you " +
203  "may not know until you attempt to read/write the socket.")
204  public final boolean IsConnected() {
205  if (sdkLevel >= SdkLevel.LEVEL_ICE_CREAM_SANDWICH) {
206  return (connectedBluetoothSocket != null && BluetoothReflection.isBluetoothSocketConnected(connectedBluetoothSocket));
207  } else {
208  return (connectedBluetoothSocket != null);
209  }
210  }
211 
212  protected boolean DisconnectOnError() {
213  return disconnectOnError;
214  }
223  description = "Whether to invoke SSP (Simple Secure Pairing), which is supported on " +
224  "devices with Bluetooth v2.1 or higher. When working with embedded Bluetooth devices, " +
225  "this property may need to be set to False. For Android 2.0-2.2, this property setting " +
226  "will be ignored.")
227  public boolean Secure() {
228  return secure;
229  }
230 
237  defaultValue = "True")
239  public void Secure(boolean secure) {
240  this.secure = secure;
241  }
242 
252  public boolean HighByteFirst() {
253  return byteOrder == ByteOrder.BIG_ENDIAN;
254  }
255 
264  defaultValue = "False")
266  public void HighByteFirst(boolean highByteFirst) {
267  byteOrder = highByteFirst ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
268  }
269 
274  @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_STRING, defaultValue = "UTF-8")
276  public void CharacterEncoding(String encoding) {
277  try {
278  // Check whether the new encoding is supported.
279  "check".getBytes(encoding);
280  this.encoding = encoding;
281  } catch (UnsupportedEncodingException e) {
282  bluetoothError("CharacterEncoding",
284  }
285  }
286 
291  public String CharacterEncoding() {
292  return encoding;
293  }
294 
303  defaultValue = "0")
305  public void DelimiterByte(int number) {
306  String functionName = "DelimiterByte";
307  int n = number;
308  byte b = (byte) n;
309  n = n >> 8;
310  if (n != 0 && n != -1) {
311  bluetoothError(functionName,
313  return;
314  }
315  delimiter = b;
316  }
317 
324  public int DelimiterByte() {
325  return delimiter;
326  }
327 
333  @SimpleFunction(description = "Send text to the connected Bluetooth device.")
334  public void SendText(String text) {
335  byte[] bytes;
336  try {
337  bytes = text.getBytes(encoding);
338  } catch (UnsupportedEncodingException e) {
339  Log.w(logTag, "UnsupportedEncodingException: " + e.getMessage());
340  bytes = text.getBytes();
341  }
342  write("SendText", bytes);
343  }
344 
345  // TODO(lizlooney) - The following three methods take a number as a String parameter so that the
346  // user can easily enter hex numbers as 0x12AB. After the blocks editor allows numbers to be
347  // entered as hex, we can change String to int/long.
348 
359  @SimpleFunction(description = "Send a 1-byte number to the connected Bluetooth device.")
360  public void Send1ByteNumber(String number) {
361  String functionName = "Send1ByteNumber";
362  int n;
363  try {
364  n = Integer.decode(number);
365  } catch (NumberFormatException e) {
366  bluetoothError(functionName,
368  return;
369  }
370  byte b = (byte) n;
371  n = n >> 8;
372  if (n != 0 && n != -1) {
373  bluetoothError(functionName,
375  return;
376  }
377  write(functionName, b);
378  }
379 
390  @SimpleFunction(description = "Send a 2-byte number to the connected Bluetooth device.")
391  public void Send2ByteNumber(String number) {
392  String functionName = "Send2ByteNumber";
393  int n;
394  try {
395  n = Integer.decode(number);
396  } catch (NumberFormatException e) {
397  bluetoothError(functionName,
399  return;
400  }
401  byte[] bytes = new byte[2];
402  if (byteOrder == ByteOrder.BIG_ENDIAN) {
403  bytes[1] = (byte) (n & 0xFF); // low byte
404  n = n >> 8;
405  bytes[0] = (byte) (n & 0xFF); // high byte
406  } else {
407  bytes[0] = (byte) (n & 0xFF); // low byte
408  n = n >> 8;
409  bytes[1] = (byte) (n & 0xFF); // high byte
410  }
411  n = n >> 8;
412  if (n != 0 && n != -1) {
413  bluetoothError(functionName,
415  return;
416  }
417  write(functionName, bytes);
418  }
419 
430  @SimpleFunction(description = "Send a 4-byte number to the connected Bluetooth device.")
431  public void Send4ByteNumber(String number) {
432  String functionName = "Send4ByteNumber";
433  long n;
434  try {
435  n = Long.decode(number);
436  } catch (NumberFormatException e) {
437  bluetoothError(functionName,
439  return;
440  }
441  byte[] bytes = new byte[4];
442  if (byteOrder == ByteOrder.BIG_ENDIAN) {
443  bytes[3] = (byte) (n & 0xFF); // low byte
444  n = n >> 8;
445  bytes[2] = (byte) (n & 0xFF);
446  n = n >> 8;
447  bytes[1] = (byte) (n & 0xFF);
448  n = n >> 8;
449  bytes[0] = (byte) (n & 0xFF); // high byte
450  } else {
451  bytes[0] = (byte) (n & 0xFF); // low byte
452  n = n >> 8;
453  bytes[1] = (byte) (n & 0xFF);
454  n = n >> 8;
455  bytes[2] = (byte) (n & 0xFF);
456  n = n >> 8;
457  bytes[3] = (byte) (n & 0xFF); // high byte
458  }
459  n = n >> 8;
460  if (n != 0 && n != -1) {
461  bluetoothError(functionName,
463  return;
464  }
465  write(functionName, bytes);
466  }
467 
478  @SimpleFunction(description = "Send a list of byte values to the connected Bluetooth device.")
479  public void SendBytes(YailList list) {
480  String functionName = "SendBytes";
481  Object[] array = list.toArray();
482  byte[] bytes = new byte[array.length];
483  for (int i = 0; i < array.length; i++) {
484  // We use Object.toString here because the element might be a String or it might be some
485  // numeric class.
486  Object element = array[i];
487  String s = element.toString();
488  int n;
489  try {
490  n = Integer.decode(s);
491  } catch (NumberFormatException e) {
492  bluetoothError(functionName,
494  return;
495  }
496  bytes[i] = (byte) (n & 0xFF);
497  n = n >> 8;
498  if (n != 0 && n != -1) {
499  bluetoothError(functionName,
501  return;
502  }
503  }
504  write(functionName, bytes);
505  }
506 
513  protected void write(String functionName, byte b) {
514  if (!IsConnected()) {
515  bluetoothError(functionName,
517  return;
518  }
519 
520  try {
521  outputStream.write(b);
522  outputStream.flush();
523  } catch (IOException e) {
524  Log.e(logTag, "IO Exception during Writing" + e.getMessage());
525  if (disconnectOnError) {
526  Disconnect();
527  }
528  bluetoothError(functionName,
530  }
531  }
532 
539  protected void write(String functionName, byte[] bytes) {
540  if (!IsConnected()) {
541  bluetoothError(functionName,
543  return;
544  }
545 
546  try {
547  outputStream.write(bytes);
548  outputStream.flush();
549  } catch (IOException e) {
550  Log.e(logTag, "IO Exception during Writing" + e.getMessage());
551  if (disconnectOnError) {
552  Disconnect();
553  }
554  bluetoothError(functionName,
556  }
557  }
558 
562  @SimpleFunction(description = "Returns an estimate of the number of bytes that can be " +
563  "received without blocking")
564  public int BytesAvailableToReceive() {
565  String functionName = "BytesAvailableToReceive";
566  if (!IsConnected()) {
567  bluetoothError(functionName,
569  return 0;
570  }
571 
572  try {
573  return inputStream.available();
574  } catch (IOException e) {
575  Log.e(logTag, "IO Exception during Getting Receive Availability " + e.getMessage());
576  if (disconnectOnError) {
577  Disconnect();
578  }
579  bluetoothError(functionName,
581  return 0;
582  }
583  }
584 
593  @SimpleFunction(description = "Receive text from the connected Bluetooth device. " +
594  "If numberOfBytes is less than 0, read until a delimiter byte value is received.")
595  public String ReceiveText(int numberOfBytes) {
596  byte[] bytes = read("ReceiveText", numberOfBytes);
597  try {
598  if (numberOfBytes < 0) {
599  // bytes contains a trailing delimiter byte that we ignore when converting to String.
600  return new String(bytes, 0, bytes.length - 1, encoding);
601  } else {
602  return new String(bytes, encoding);
603  }
604  } catch (UnsupportedEncodingException e) {
605  Log.w(logTag, "UnsupportedEncodingException: " + e.getMessage());
606  return new String(bytes);
607  }
608  }
609 
613  @SimpleFunction(description = "Receive a signed 1-byte number from the connected " +
614  "Bluetooth device.")
616  byte[] bytes = read("ReceiveSigned1ByteNumber", 1);
617  if (bytes.length != 1) {
618  return 0; // an error occurred
619  }
620 
621  return bytes[0];
622  }
623 
627  @SimpleFunction(description = "Receive an unsigned 1-byte number from the connected " +
628  "Bluetooth device.")
630  byte[] bytes = read("ReceiveUnsigned1ByteNumber", 1);
631  if (bytes.length != 1) {
632  return 0; // an error occurred
633  }
634 
635  return bytes[0] & 0xFF;
636  }
637 
641  @SimpleFunction(description = "Receive a signed 2-byte number from the connected " +
642  "Bluetooth device.")
644  byte[] bytes = read("ReceiveSigned2ByteNumber", 2);
645  if (bytes.length != 2) {
646  return 0; // an error occurred
647  }
648 
649  if (byteOrder == ByteOrder.BIG_ENDIAN) {
650  return (bytes[1] & 0xFF) | (bytes[0] << 8);
651  } else {
652  return (bytes[0] & 0xFF) | (bytes[1] << 8);
653  }
654  }
655 
659  @SimpleFunction(description = "Receive a unsigned 2-byte number from the connected " +
660  "Bluetooth device.")
662  byte[] bytes = read("ReceiveUnsigned2ByteNumber", 2);
663  if (bytes.length != 2) {
664  return 0; // an error occurred
665  }
666 
667  if (byteOrder == ByteOrder.BIG_ENDIAN) {
668  return (bytes[1] & 0xFF) | ((bytes[0] & 0xFF) << 8);
669  } else {
670  return (bytes[0] & 0xFF) | ((bytes[1] & 0xFF) << 8);
671  }
672  }
673 
677  @SimpleFunction(description = "Receive a signed 4-byte number from the connected " +
678  "Bluetooth device.")
679  public long ReceiveSigned4ByteNumber() {
680  byte[] bytes = read("ReceiveSigned4ByteNumber", 4);
681  if (bytes.length != 4) {
682  return 0; // an error occurred
683  }
684 
685  if (byteOrder == ByteOrder.BIG_ENDIAN) {
686  return (bytes[3] & 0xFF) |
687  ((bytes[2] & 0xFF) << 8) |
688  ((bytes[1] & 0xFF) << 16) |
689  (bytes[0] << 24);
690  } else {
691  return (bytes[0] & 0xFF) |
692  ((bytes[1] & 0xFF) << 8) |
693  ((bytes[2] & 0xFF) << 16) |
694  (bytes[3] << 24);
695  }
696  }
697 
701  @SimpleFunction(description = "Receive a unsigned 4-byte number from the connected " +
702  "Bluetooth device.")
704  byte[] bytes = read("ReceiveUnsigned4ByteNumber", 4);
705  if (bytes.length != 4) {
706  return 0; // an error occurred
707  }
708 
709  if (byteOrder == ByteOrder.BIG_ENDIAN) {
710  return (bytes[3] & 0xFFL) |
711  ((bytes[2] & 0xFFL) << 8) |
712  ((bytes[1] & 0xFFL) << 16) |
713  ((bytes[0] & 0xFFL) << 24);
714  } else {
715  return (bytes[0] & 0xFFL) |
716  ((bytes[1] & 0xFFL) << 8) |
717  ((bytes[2] & 0xFFL) << 16) |
718  ((bytes[3] & 0xFFL) << 24);
719  }
720  }
721 
732  @SimpleFunction(description = "Receive multiple signed byte values from the connected " +
733  "Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value " +
734  "is received.")
735  public List<Integer> ReceiveSignedBytes(int numberOfBytes) {
736  byte[] bytes = read("ReceiveSignedBytes", numberOfBytes);
737  List<Integer> list = new ArrayList<Integer>();
738  for (int i = 0; i < bytes.length; i++) {
739  int n = bytes[i];
740  list.add(n);
741  }
742  return list;
743  }
744 
755  @SimpleFunction(description = "Receive multiple unsigned byte values from the connected " +
756  "Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value " +
757  "is received.")
758  public List<Integer> ReceiveUnsignedBytes(int numberOfBytes) {
759  byte[] bytes = read("ReceiveUnsignedBytes", numberOfBytes);
760  List<Integer> list = new ArrayList<Integer>();
761  for (int i = 0; i < bytes.length; i++) {
762  int n = bytes[i] & 0xFF;
763  list.add(n);
764  }
765  return list;
766  }
767 
778  protected final byte[] read(String functionName, int numberOfBytes) {
779  if (!IsConnected()) {
780  bluetoothError(functionName,
782  return new byte[0];
783  }
784 
785  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
786 
787  if (numberOfBytes >= 0) {
788  // Read <numberOfBytes> bytes.
789  byte[] bytes = new byte[numberOfBytes];
790  int totalBytesRead = 0;
791  while (totalBytesRead < numberOfBytes) {
792  try {
793  int numBytesRead = inputStream.read(bytes, totalBytesRead, bytes.length - totalBytesRead);
794  if (numBytesRead == -1) {
795  bluetoothError(functionName,
797  break;
798  }
799  totalBytesRead += numBytesRead;
800  } catch (IOException e) {
801  Log.e(logTag, "IO Exception during Reading " + e.getMessage());
802  if (disconnectOnError) {
803  Disconnect();
804  }
805  bluetoothError(functionName,
807  break;
808  }
809  }
810  buffer.write(bytes, 0, totalBytesRead);
811  } else {
812  // Read one byte at a time until a delimiter byte is read.
813  while (true) {
814  try {
815  int value = inputStream.read();
816  if (value == -1) {
817  bluetoothError(functionName,
819  break;
820  }
821  buffer.write(value);
822  if (value == delimiter) {
823  break;
824  }
825  } catch (IOException e) {
826  Log.e(logTag, "IO Exception during Reading " + e.getMessage());
827  if (disconnectOnError) {
828  Disconnect();
829  }
830  bluetoothError(functionName,
832  break;
833  }
834  }
835  }
836 
837  return buffer.toByteArray();
838  }
839 
840  // OnDestroyListener implementation
841 
842  @Override
843  public void onDestroy() {
844  prepareToDie();
845  }
846 
847  // Deleteable implementation
848 
849  @Override
850  public void onDelete() {
851  prepareToDie();
852  }
853 
854  private void prepareToDie() {
855  if (connectedBluetoothSocket != null) {
856  Disconnect();
857  }
858  }
859 }
com.google.appinventor.components.runtime.BluetoothConnectionBase.HighByteFirst
boolean HighByteFirst()
Definition: BluetoothConnectionBase.java:252
com.google.appinventor.components.runtime.BluetoothConnectionBase.BytesAvailableToReceive
int BytesAvailableToReceive()
Definition: BluetoothConnectionBase.java:564
com.google.appinventor.components.runtime.util.YailList
Definition: YailList.java:26
com.google.appinventor.components.annotations.SimpleFunction
Definition: SimpleFunction.java:23
com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveSigned2ByteNumber
int ReceiveSigned2ByteNumber()
Definition: BluetoothConnectionBase.java:643
com.google.appinventor.components.runtime.BluetoothConnectionBase.write
void write(String functionName, byte b)
Definition: BluetoothConnectionBase.java:513
com.google.appinventor.components.runtime.BluetoothConnectionBase.Send2ByteNumber
void Send2ByteNumber(String number)
Definition: BluetoothConnectionBase.java:391
com.google.appinventor.components.runtime.Form.registerForOnDestroy
void registerForOnDestroy(OnDestroyListener component)
Definition: Form.java:817
com.google.appinventor.components.runtime.util.ErrorMessages
Definition: ErrorMessages.java:17
com.google.appinventor.components.runtime.util
-*- mode: java; c-basic-offset: 2; -*-
Definition: AccountChooser.java:7
com.google.appinventor.components.runtime.util.BluetoothReflection.closeBluetoothSocket
static void closeBluetoothSocket(Object bluetoothSocket)
Definition: BluetoothReflection.java:314
com.google.appinventor.components.runtime.BluetoothConnectionBase.logTag
final String logTag
Definition: BluetoothConnectionBase.java:44
com.google.appinventor.components.runtime.BluetoothConnectionBase.DelimiterByte
int DelimiterByte()
Definition: BluetoothConnectionBase.java:324
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_BLUETOOTH_UNABLE_TO_READ
static final int ERROR_BLUETOOTH_UNABLE_TO_READ
Definition: ErrorMessages.java:86
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_BLUETOOTH_COULD_NOT_DECODE_ELEMENT
static final int ERROR_BLUETOOTH_COULD_NOT_DECODE_ELEMENT
Definition: ErrorMessages.java:82
com.google.appinventor.components.annotations.DesignerProperty
Definition: DesignerProperty.java:25
com.google.appinventor.components.runtime.BluetoothConnectionBase.BluetoothError
void BluetoothError(String functionName, String message)
Definition: BluetoothConnectionBase.java:128
com.google.appinventor.components.runtime.util.BluetoothReflection.getOutputStream
static OutputStream getOutputStream(Object bluetoothSocket)
Definition: BluetoothReflection.java:301
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_BLUETOOTH_COULD_NOT_FIT_ELEMENT_IN_BYTE
static final int ERROR_BLUETOOTH_COULD_NOT_FIT_ELEMENT_IN_BYTE
Definition: ErrorMessages.java:83
com.google.appinventor.components.runtime.BluetoothConnectionBase.Available
boolean Available()
Definition: BluetoothConnectionBase.java:143
com.google.appinventor.components.common.PropertyTypeConstants.PROPERTY_TYPE_STRING
static final String PROPERTY_TYPE_STRING
Definition: PropertyTypeConstants.java:237
com.google.appinventor.components.runtime.util.BluetoothReflection.getBluetoothAdapter
static Object getBluetoothAdapter()
Definition: BluetoothReflection.java:44
com.google.appinventor.components.runtime.BluetoothConnectionBase.Send4ByteNumber
void Send4ByteNumber(String number)
Definition: BluetoothConnectionBase.java:431
com.google.appinventor.components
com.google.appinventor.components.common.PropertyTypeConstants.PROPERTY_TYPE_NON_NEGATIVE_INTEGER
static final String PROPERTY_TYPE_NON_NEGATIVE_INTEGER
Definition: PropertyTypeConstants.java:206
com.google.appinventor.components.runtime.util.BluetoothReflection
Definition: BluetoothReflection.java:29
com.google.appinventor.components.runtime.BluetoothConnectionBase.onDestroy
void onDestroy()
Definition: BluetoothConnectionBase.java:843
com.google.appinventor.components.runtime.BluetoothConnectionBase.IsConnected
final boolean IsConnected()
Definition: BluetoothConnectionBase.java:204
com.google.appinventor.components.common.PropertyTypeConstants.PROPERTY_TYPE_BOOLEAN
static final String PROPERTY_TYPE_BOOLEAN
Definition: PropertyTypeConstants.java:35
com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveSigned1ByteNumber
int ReceiveSigned1ByteNumber()
Definition: BluetoothConnectionBase.java:615
com.google.appinventor.components.runtime.BluetoothConnectionBase.Send1ByteNumber
void Send1ByteNumber(String number)
Definition: BluetoothConnectionBase.java:360
com.google.appinventor.components.annotations.SimpleEvent
Definition: SimpleEvent.java:20
com.google.appinventor.components.annotations.PropertyCategory.BEHAVIOR
BEHAVIOR
Definition: PropertyCategory.java:15
com.google.appinventor.components.runtime.BluetoothConnectionBase.Initialize
final void Initialize()
Definition: BluetoothConnectionBase.java:122
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_BLUETOOTH_COULD_NOT_FIT_NUMBER_IN_BYTE
static final int ERROR_BLUETOOTH_COULD_NOT_FIT_NUMBER_IN_BYTE
Definition: ErrorMessages.java:80
com.google.appinventor.components.runtime.BluetoothConnectionBase.disconnectOnError
boolean disconnectOnError
Definition: BluetoothConnectionBase.java:51
com.google.appinventor.components.runtime.BluetoothConnectionBase.Secure
boolean Secure()
Definition: BluetoothConnectionBase.java:227
com.google.appinventor.components.runtime.BluetoothConnectionBase.setConnection
final void setConnection(Object bluetoothSocket)
Definition: BluetoothConnectionBase.java:168
com.google.appinventor.components.runtime.BluetoothConnectionBase.SendBytes
void SendBytes(YailList list)
Definition: BluetoothConnectionBase.java:479
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_BLUETOOTH_COULD_NOT_DECODE
static final int ERROR_BLUETOOTH_COULD_NOT_DECODE
Definition: ErrorMessages.java:79
com.google.appinventor.components.runtime.util.BluetoothReflection.isBluetoothSocketConnected
static boolean isBluetoothSocketConnected(Object bluetoothSocket)
Definition: BluetoothReflection.java:275
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_BLUETOOTH_UNSUPPORTED_ENCODING
static final int ERROR_BLUETOOTH_UNSUPPORTED_ENCODING
Definition: ErrorMessages.java:88
com.google.appinventor.components.runtime.BluetoothConnectionBase.DelimiterByte
void DelimiterByte(int number)
Definition: BluetoothConnectionBase.java:305
com.google.appinventor.components.runtime.BluetoothConnectionBase.Enabled
boolean Enabled()
Definition: BluetoothConnectionBase.java:158
com.google.appinventor.components.runtime.BluetoothConnectionBase.Disconnect
final void Disconnect()
Definition: BluetoothConnectionBase.java:181
com.google.appinventor.components.runtime.BluetoothConnectionBase.secure
boolean secure
Definition: BluetoothConnectionBase.java:52
com.google.appinventor.components.runtime.AndroidNonvisibleComponent
Definition: AndroidNonvisibleComponent.java:17
com.google.appinventor.components.runtime.util.SdkLevel
Definition: SdkLevel.java:19
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_BLUETOOTH_UNABLE_TO_WRITE
static final int ERROR_BLUETOOTH_UNABLE_TO_WRITE
Definition: ErrorMessages.java:85
com.google.appinventor.components.runtime.util.SdkLevel.LEVEL_ICE_CREAM_SANDWICH
static final int LEVEL_ICE_CREAM_SANDWICH
Definition: SdkLevel.java:30
com.google.appinventor.components.runtime.BluetoothConnectionBase.CharacterEncoding
String CharacterEncoding()
Definition: BluetoothConnectionBase.java:291
com.google.appinventor.components.annotations.SimpleProperty
Definition: SimpleProperty.java:23
com.google.appinventor.components.runtime.BluetoothConnectionBase
Definition: BluetoothConnectionBase.java:41
com.google.appinventor.components.annotations.PropertyCategory
Definition: PropertyCategory.java:13
com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveUnsigned1ByteNumber
int ReceiveUnsigned1ByteNumber()
Definition: BluetoothConnectionBase.java:629
com.google.appinventor.components.runtime.BluetoothConnectionBase.write
void write(String functionName, byte[] bytes)
Definition: BluetoothConnectionBase.java:539
com.google.appinventor.components.runtime.ComponentContainer
Definition: ComponentContainer.java:16
com.google.appinventor.components.runtime.util.BluetoothReflection.isBluetoothEnabled
static boolean isBluetoothEnabled(Object bluetoothAdapter)
Definition: BluetoothReflection.java:63
com.google.appinventor.components.runtime.util.SdkLevel.getLevel
static int getLevel()
Definition: SdkLevel.java:45
com.google.appinventor.components.runtime
Copyright 2009-2011 Google, All Rights reserved.
Definition: AccelerometerSensor.java:8
com.google.appinventor.components.runtime.Component
Definition: Component.java:17
com.google.appinventor.components.runtime.BluetoothConnectionBase.DisconnectOnError
boolean DisconnectOnError()
Definition: BluetoothConnectionBase.java:212
com.google.appinventor.components.runtime.Deleteable
Definition: Deleteable.java:15
com.google.appinventor.components.common
Definition: ComponentCategory.java:7
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_BLUETOOTH_END_OF_STREAM
static final int ERROR_BLUETOOTH_END_OF_STREAM
Definition: ErrorMessages.java:87
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_BLUETOOTH_COULD_NOT_FIT_NUMBER_IN_BYTES
static final int ERROR_BLUETOOTH_COULD_NOT_FIT_NUMBER_IN_BYTES
Definition: ErrorMessages.java:81
com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveSignedBytes
List< Integer > ReceiveSignedBytes(int numberOfBytes)
Definition: BluetoothConnectionBase.java:735
com.google.appinventor.components.runtime.BluetoothConnectionBase.HighByteFirst
void HighByteFirst(boolean highByteFirst)
Definition: BluetoothConnectionBase.java:266
com.google.appinventor.components.runtime.Form.dispatchErrorOccurredEvent
void dispatchErrorOccurredEvent(final Component component, final String functionName, final int errorNumber, final Object... messageArgs)
Definition: Form.java:1011
com.google.appinventor.components.annotations.SimpleObject
Definition: SimpleObject.java:23
com.google.appinventor.components.runtime.BluetoothConnectionBase.SendText
void SendText(String text)
Definition: BluetoothConnectionBase.java:334
com.google
com
com.google.appinventor.components.runtime.BluetoothConnectionBase.read
final byte[] read(String functionName, int numberOfBytes)
Definition: BluetoothConnectionBase.java:778
com.google.appinventor.components.runtime.BluetoothConnectionBase.Secure
void Secure(boolean secure)
Definition: BluetoothConnectionBase.java:239
com.google.appinventor.components.runtime.ComponentContainer.$form
Form $form()
com.google.appinventor.components.runtime.BluetoothConnectionBase.onDelete
void onDelete()
Definition: BluetoothConnectionBase.java:850
com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveSigned4ByteNumber
long ReceiveSigned4ByteNumber()
Definition: BluetoothConnectionBase.java:679
com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveUnsignedBytes
List< Integer > ReceiveUnsignedBytes(int numberOfBytes)
Definition: BluetoothConnectionBase.java:758
com.google.appinventor.components.runtime.BluetoothConnectionBase.BluetoothConnectionBase
BluetoothConnectionBase(ComponentContainer container, String logTag)
Definition: BluetoothConnectionBase.java:62
com.google.appinventor.components.runtime.BluetoothConnectionBase.bluetoothError
void bluetoothError(String functionName, int errorNumber, Object... messageArgs)
Definition: BluetoothConnectionBase.java:131
com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveUnsigned2ByteNumber
int ReceiveUnsigned2ByteNumber()
Definition: BluetoothConnectionBase.java:661
com.google.appinventor.components.runtime.AndroidNonvisibleComponent.form
final Form form
Definition: AndroidNonvisibleComponent.java:19
com.google.appinventor.components.runtime.BluetoothConnectionBase.CharacterEncoding
void CharacterEncoding(String encoding)
Definition: BluetoothConnectionBase.java:276
com.google.appinventor.components.runtime.Form
Definition: Form.java:126
com.google.appinventor.components.runtime.util.BluetoothReflection.getInputStream
static InputStream getInputStream(Object bluetoothSocket)
Definition: BluetoothReflection.java:287
com.google.appinventor.components.runtime.BluetoothConnectionBase.BluetoothConnectionBase
BluetoothConnectionBase(OutputStream outputStream, InputStream inputStream)
Definition: BluetoothConnectionBase.java:82
com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveText
String ReceiveText(int numberOfBytes)
Definition: BluetoothConnectionBase.java:595
com.google.appinventor.components.common.PropertyTypeConstants
Definition: PropertyTypeConstants.java:14
com.google.appinventor.components.runtime.OnDestroyListener
Definition: OnDestroyListener.java:15
com.google.appinventor.components.annotations
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_BLUETOOTH_NOT_CONNECTED_TO_DEVICE
static final int ERROR_BLUETOOTH_NOT_CONNECTED_TO_DEVICE
Definition: ErrorMessages.java:84
com.google.appinventor
com.google.appinventor.components.runtime.BluetoothConnectionBase.ReceiveUnsigned4ByteNumber
long ReceiveUnsigned4ByteNumber()
Definition: BluetoothConnectionBase.java:703
com.google.appinventor.components.runtime.util.SdkLevel.LEVEL_ECLAIR_MR1
static final int LEVEL_ECLAIR_MR1
Definition: SdkLevel.java:24