Bluetooth LE(BLE)を使用してAndroid経由でIntel Edisonに接続する

こんにちは、Habr! 本日は、低コストでバッテリー寿命が短いため、商用製品と純粋なアマチュア製品の両方に応用できる低電力BluetoothテクノロジーであるBLEについて説明します。 これらの要因により、BLEは、Android OSを実行するスマートフォンまたはタブレットを、開発者向けのIntelボードに基づくプロジェクト(EdisonまたはGalileo)に接続するための優れた選択肢になります。







以下に提案する記事のタスクは、例として、Intel EdisonプラットフォームとBluetoothバージョン4.0のAndroidデバイスを使用して、BLEプロトコルを使用してハードウェアを接続するためのコードを記述する方法を示すことです。 すぐに使用できる無料のソフトウェアと低コストのハードウェアコンポーネントのみを使用します。



予想通り、理論から始めましょう。



BLEとは?



私たちは知り合いになります:BLEテクノロジー、それはBluetooth LEでもあります。 フルネームはBluetooth Low Energy (またはBluetooth Smart)です。 Bluetooth Special Interest GroupBluetooth SIG )によって開発および配布されたワイヤレスパーソナルデータネットワークテクノロジー。 Bluetooth LEは、医療およびホームエンターテイメント、スポーツおよび体育、車での使用を目的としています。



Bluetooth LEは、2006年にNokia(コードネームWibree)によって初めて導入されまし 。 Bluetooth標準では、2010年にBluetooth 4.0のバージョンで登場しました。



BLEを使用すると、標準のBluetooth接続よりもはるかに少ない電力でデバイスを満足させることができます。 同時に、通常の機能の約半分である約15メートルの距離で、通常の機能のほとんどを提供します。 Bluetooth LEデバイスは、バッテリーを交換したり再充電したりすることなく、長年使用できます。 Estimoteデバイスのように、ビーコンはすでに最大3(3!)年間バッテリーで実行できます。





出版物の主人公はIntel Edisonですが、Intel Galileoには多くのことが当てはまります。 IoTプロジェクトでは、Seeve Studio Groveシステムの物理センサーとコントロールを使用します。 すなわち:





鉄のいくつかのニュアンス:



  1. エントリーレベルのグローブキット(スターターキット)はIntel Galileoプラットフォーム用に設計されていますが、Edisonでも非常にうまく機能します。 もちろん、Groveコンポーネントを個別に購入することもできますが、既製のキットを使用する方が経済的です。
  2. Androidの私のLenovoタブレットがプロジェクトで使用されましたが、このOSバージョン4.3以上を実行するBluetooth 4.0をサポートする他のデバイスでも動作するはずです。
  3. Androidデバイス(およびこの記事)であるIntel Edisonのコードは、Dell XPS12ラップトップで作成されました。 MacまたはLinuxシステムでの開発も可能です。


ソフトウェア



いくつかの無料プログラムを使用しました-この例を再現するには、それらもインストールする必要があります。





上記のソフトウェアはすべてWindowsおよびLinuxで使用できますが、この記事ではWindowsの例を理解します。



鉄に近づく



»Intel Edison



Intel Edisonは、一連の低コストの多目的コンピュータープラットフォームの最初の製品です。 このプラットフォームは、IoTプロジェクトを迅速かつ簡単にプロトタイプ化すると同時に、プロジェクトを商用化するための製品を提供するように設計されています。



Intel Edisonの「心臓部」はIntelの22nmチップベースのシステムであり、500 MHzで動作するデュアルコアAtomプロセッサが含まれています。 このSoCの小さなフォームファクターには、40ピンGPIOインターフェイス、1 GBのLPDDR3クラスRAM、4 GBのeMMCストレージ、デュアル機能Wi-Fi + Bluetoothモジュールが含まれます。 このプラットフォームは、本格的なLinuxカーネルを使用しており、すべてのジュース(Edisonに組み込まれている)を絞り出すには、低レベルのコードを記述する必要があります。



しかし、Linux on Edisonには、Arduinoの能力でLinuxプログラムを実行する機能も含まれています。 簡単に言えば、これは、おなじみのArduinoスケッチを作成し、Edisonで実行できることを意味します。 それが私たちのすることです。



Edisonシステムの詳細については、IntelのWebサイトをご覧ください



»Arduinoボード



Intel Galileo用のArduinoボードは、2つの目的のために設計されています。 第一に、それはより大きなプロトタイピングプラットフォームであり、I / Oインターフェイスに簡単にアクセスできます。 次に、Arduinoと完全に互換性のあるコンピューティングプラットフォームがあります。 実際には、これは、Intel Edison(またはIntel Galileo)で標準のArduino拡張カードを使用できることを意味します。





ArduinoボードにインストールされたIntel Edison



»グローブスターターキットプラス



このキットの正式名称は「Grove Starter Kit Plus-Intel IoT Edition for Intel Galileo Gen 2 Developer Kit」です。 当初、このキットは第2世代Intel Galileoボード向けでした-幸いなことに、ArduinoボードはIntel Edisonとの完全な互換性も提供します。



このキットは、プロトタイピングを簡素化し、センサー、メカニズム、シールドを使用するように設計されています。 標準の4ピンインターフェイス上の互換性のあるArduinoモジュールが含まれています。 インターフェイスには、付属のケーブルを介してI / Oポートから電力が供給されます。 ケーブルをセンサーに接続することは非常に便利です。プロジェクト自体に対処し、これらの小さな配線をすべて理解しなくても、常に何かを修正したり、接続の極性を心配したりできます。 キット(およびその購入)の詳細については、Seeed Studio Webサイトをご覧ください



ところで、Groveスイートの作成者であるSeeed Studiosは、便利なオンラインリソースのコレクションを提供しています。 特に、 初心者向けスケッチブックシリーズを学習またはダウンロードするか、少なくともグローブをお気に入りに追加することをお勧めします。





Grove Starter Kit Plus-Intel Galileo Gen 2開発キット用Intel IoT Edition



»Grove BLE(V1)



Grove Bluetooth Low Energy v1モジュールを使用します。これはエントリーレベルのキットには含まれていませんが、ピンツーピンはGroveモジュールおよび接続ワイヤと互換性があります。 また、比較的安価なBLEモジュールでもあります。この記事の執筆時点では、これより安価なものは見つかりませんでした。



Grove BLE v1シールドの基盤は、このクラスのデバイス用のTexas Instrumentsの標準CC2540チップであり、同じマイクロチップが他の製品でも使用されています。 したがって、手元にTI CC2540に基づく別のBLEモジュールがある場合、さらに最小限の労力でサンプルコードをそれに適合させることができます。



Intel Edisonボードには、Wi-FiおよびBluetooth 4.0 / BLEをサポートするワイヤレスモジュールが既に組み込まれていますが、Grove BLEモジュールはハードウェアとソフトウェアの両方の設定を大幅に簡素化します。 Groveモジュールを使用すると、プロジェクトをIntel Galileoプラットフォームに簡単に適合させることもできます。





Grove BLE V1モジュール



メーカーのウェブサイトにあるGrove BLE v1モジュールの詳細。



Androidデバイスでのデバッグ



AndroidのBLEサポートは、バージョン4.3(APIレベル18)以降に登場しています。 したがって、BLEを使用するには、デバイスのAndroidバージョンが4.3以上である必要があります。 ここで Android BLEの詳細をご覧ください。



Android向けの開発をマスターするための最初のステップを踏む場合、まずタブレット/電話で開発者機能を有効にする必要があります。これらを使用すると、コードを実行およびデバッグできます。 開発者モードのアクティブ化は次のとおりです。設定を開き、メニューを一番下までスクロールし、「デバイスについて」項目を見つけて、ビルドバージョン番号を7(7)回クリックします。 これで、開発者モード(開発者オプション)が含まれていることが設定の下部に表示されます。 「USBデバッグ」ボックスをチェックすることを忘れないでください。 開発者モードの詳細については、 こちらをご覧ください。



ソフトウェアのインストール。 コーディングの準備をしてください!



»Intel Galileo向けArduino IDE



スケッチをIntel EdisonまたはGalileoにデプロイするには、特別に準備されたバージョンのArduino IDEをダウンロードする必要があります。 執筆時点では、現在のバージョンは1.5.3であり、ソースはhereです。



Intel Edisonのドライバー



Intel Edisonのドライバーは上記のリンクにあります。ドライバーもダウンロードしてインストールする必要があります。 これらは、ページの下部にあるカテゴリ「ソフトウェアとドライバー」-「ドライバーソフトウェア」にあります。 または、ここに直接リンクがあります (執筆時点では、ドライバーのバージョンは1.0.0でした)



さらに質問がある場合は、英語で書かれた優れた指示書-「 入門ガイド 」を強くお勧めします



Android Studio



Android Studioは、Android開発用の新しいJava IDEです。 このパッケージは、 IntelliJ IDEAに基づいて記述されています。 現時点では、パッケージのステータスはベータですが、非常に安定して機能し、機能は完全に提供されています。 Java(またはIntellliJ IDEA)のEclipse環境でAndorid-developmentを自信を持って作業している場合、Android Studioで作業する際に問題や問題はないはずです-トレーニング資料の重要なポイントを見てください。



Android StudioにAndroid SDK開発者向けのパッケージが含まれているため、インストール手順が大幅に簡素化されています。 ダウンロード、zipファイルの内容の解凍、およびBinフォルダーからstudio.exeインストーラーの起動が行われます。



Android Studioの詳細については、 こちらをご覧ください。



Android SDK



おそらく追加のSDKをダウンロードする必要があります。 これは、Android Studioインターフェースのツールバーにある「SDKマネージャー」ボタンを使用して行うのが最も便利です。 Android SDKの構成と構成は別の記事のトピックであるため、これについては詳しく説明しません。 追加のSDRの詳細は、 このページで選択します



Android SDKがシステムに既にインストールされている場合、Android Studioプラットフォームでは、ファイルシステム内の場所への正しいパスを指定できます。 Android Studioでこのメニューを呼び出すには、[ 設定 ] -> [プロジェクトのデフォルト]-> [プロジェクト構造 ]をクリックします。 表示されるウィンドウで、SDKを使用してフォルダーへのパスを指定できます。





Android StudioでSDKへのパスを指定する



Intel Edisonのテスト



ボードの機能(下記)に慣れる前に、プラットフォームがBlinkスケッチサンプルを正しく実行できることを確認することを強くお勧めします。 スケッチは、ダウンロード可能なアドオンArduino IDEに含まれています。 その場所: examples-> 01.Basics-> Blink(folder)



エジソンの開発者は、初心者向けのまともなガイドを用意しています。



永遠のHello World Classic for Android



Android Studioをインストールした後、プログラムで新しいプロジェクトを作成し、Androidデバイスで実行できることを確認してください。



  1. Androidデバイスをコンピューターに接続します。
  2. Android Studioを開きます。
  3. [新しいプロジェクト...]を選択します。
  4. 名前とパスを指定し、3回「次へ」をクリックします(API 15 /空のアクティビティ)。
  5. [完了]をクリックして、プロジェクトが作成されるのを待ちます(プロセスは20秒以上ストレッチできます)。
  6. ツールバーの緑色の再生アイコンをクリックします。
  7. デバイスを選択して「OK」をクリックします。


すべてが正しく行われた場合、「Hello world!」がデバイスの画面に表示されます。





Android Studio用Hello Worldアプリ



BLEはどのように機能しますか?



BLEの動作原理は、その名前:Low Energyで既に説明されています。 このプロトコルでは、必要に応じて短いパケットでデータを送信し、送信機をオフにします。 この原理を適用することにより、低消費電力が部分的に達成されます。 従来のBluetoothの古典的なタンデムの代わりに、BLEデバイスは、情報の送受信が必要な場合にのみ相互に通信します。



BLEプロトコルは、他のデバイスとの通信の原則に従って厳密に構造化されています。 最初に、デバイスはデータの送受信に利用可能なサービスを学習します。 これらのサービスの不可欠な部分は、将来の伝送のためにデータのタイプを決定する特性です。 明確にするために、特性には、データのタイプを判別するのに役立つ記述子が含まれる場合があります。 たとえば、「心拍数モニター」(心拍数モニター)と呼ばれるサービスを分析してみましょう。その特徴には、「心拍数測定」などがあります。



ほとんどのBluetooth LE APIを使用すると、ローカルデバイスを検索し、それらで利用可能なサービス、機能、および記述子を決定できます。



BLEプロトコルの重要な用語と概念



BLEプロトコルの主要な用語とその概念の簡単な概要をご紹介します。 BLEプロジェクトの作業を開始する前に、それぞれを理解する必要があります。



»共通属性プロファイル(GATT)



General Attribute Protocol(GATT)プロファイルは、Bluetooth Low Linkで「属性」と呼ばれる短いデータチャンクを送受信するための一般的な仕様を持つ必須プロファイルです。 現在のLEアプリケーションプロファイルはすべて、GATTに基づいています。 Institute for Standardization and Protocol Development-Bluetooth Special Interest Groupは、BLEデバイスのいくつかのプロファイルを既に定義しています。 これらのプロファイルは、デバイスの使用方法およびデバイスとの対話方法を説明する仕様です。



属性プロトコル(ATT)



属性プロトコル(ATT)-GATTに基づいています。 ATTは、BLEデバイス専用に設計された最適化されたプロトコルです。 ATTの原則は、できるだけ少ないバイトを送信することです。 各属性には、一意のユニバーサル識別子UUIDがあります。 これは、一意の情報を識別するために使用される標準化された128ビットの文字列IDです。 ATTとして送信される属性の形式には、特性とサービスの2つのタイプがあります。



»特徴



特性には、一意のパラメーターと記述子が含まれます。 記述子の数はゼロにすることができます。つまり、これは特性の必須部分ではありません。 記述子は、特性の値を記述します。



»記述子



記述子は、特性の値を記述する定義済みの属性です。 記述子は、完全に人間の言語による理解可能な記述の形式であり、測定単位を定義し、いくつかの有効な値を設定することもできます。



»サービス



サービスは特性の組み合わせです。 既存のGATTベースのプロファイルのリストは、 ここで表示できます



AndroidからIntel Edisonへのデータの送信



»必要なもの



この記事の残りの部分では、読者がIntel EdisonとAndroidの両方で構成された開発システムを持っていることを前提としています。 次の準備段階のリストを確認し、必要に応じて記事の前の部分に戻ることをお勧めします。







AndroidのBLE



完成したプロジェクトはGitHubでドラッグできますが、上記のリンクに基づいてコードを1行ずつ入力して、独自のプロジェクトを作成することをお勧めします。



»新しいプロジェクトを作成する



Android Studio(または選択した別のIDE)を開き、新しい空のAndroidアプリケーションを作成してBLEConnectを呼び出します。 最小SDKレベルがAPI 18以上に設定されていることを確認してください。そうでない場合、BLE用APIの使用は失敗します。





新しいAndroidアプリケーションの作成



次に、開いているAndroidManifest.xmlファイルのタグの上に追加します
   : 
      



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



, . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




  1. :



    <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






    » UI

    : . , ID TextView. activity_main.xml layout, TextView id mainText



    – .





    id TextView



    » MainActivity

    MainActivity. , , Android Studio . - :

    , Android- BLE; BLE-; Grove BLE ; ; ; , .

    , . .



    Class Level

    , BLE, . Grove BLE v1 ( TI CC2540 – ) , :



    CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





    » Status helper

    TextView, . - statusUpdate



    – , . UI, .



    » BLE-

    () Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



    , – getAdapter()



    . – getDefaultAdapter



    Bluetooth Manager.



    » BLE-

    . Bluetooth- startLeScan



    , .



    API , , , LeScanCallback



    . , . . .



    @Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





    »

    BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



    . ( ), BluetoothGattCallback



    , onConnectionStateChanged



    onServicesDiscovered



    .



    onConnectionStateChanged



    , , mBluetoothGatt.discoverServices()



    . .



    @Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





    , . .



    »

    - sendMessage



    . UDID setValue



    . , BluetoothGatt writeCharacteristic



    , .



    setValue



    . ; , BLE- , .



    Intel Edison.



    Intel Edison, Grove BLE

    . , Intel Edison Arduino.



    Grove, «» Arduino. , Grove BLE v1 UART.





    Intel Edison Grove Shield BLE





    – Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



    GitHub .



    IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



    Intel Edison. setup()



    , loop()



    . .



    »

    Grove BLE 9600 , . . AT- Grove BLE . setup()



    .



    , «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



    »

    – . read()



    , , print()



    .



    Edison , 9600 .





    Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



    Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



    GitHub , Grove LCD. , Grove 5, LCD- I2C.





    BLEConnect





    Arduino IDE Serial Monitor BLEConnect-





    Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



    !




  2. :



    <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






    » UI

    : . , ID TextView. activity_main.xml layout, TextView id mainText



    – .





    id TextView



    » MainActivity

    MainActivity. , , Android Studio . - :

    , Android- BLE; BLE-; Grove BLE ; ; ; , .

    , . .



    Class Level

    , BLE, . Grove BLE v1 ( TI CC2540 – ) , :



    CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





    » Status helper

    TextView, . - statusUpdate



    – , . UI, .



    » BLE-

    () Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



    , – getAdapter()



    . – getDefaultAdapter



    Bluetooth Manager.



    » BLE-

    . Bluetooth- startLeScan



    , .



    API , , , LeScanCallback



    . , . . .



    @Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





    »

    BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



    . ( ), BluetoothGattCallback



    , onConnectionStateChanged



    onServicesDiscovered



    .



    onConnectionStateChanged



    , , mBluetoothGatt.discoverServices()



    . .



    @Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





    , . .



    »

    - sendMessage



    . UDID setValue



    . , BluetoothGatt writeCharacteristic



    , .



    setValue



    . ; , BLE- , .



    Intel Edison.



    Intel Edison, Grove BLE

    . , Intel Edison Arduino.



    Grove, «» Arduino. , Grove BLE v1 UART.





    Intel Edison Grove Shield BLE





    – Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



    GitHub .



    IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



    Intel Edison. setup()



    , loop()



    . .



    »

    Grove BLE 9600 , . . AT- Grove BLE . setup()



    .



    , «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



    »

    – . read()



    , , print()



    .



    Edison , 9600 .





    Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



    Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



    GitHub , Grove LCD. , Grove 5, LCD- I2C.





    BLEConnect





    Arduino IDE Serial Monitor BLEConnect-





    Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



    !




  3. :



    <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






    » UI

    : . , ID TextView. activity_main.xml layout, TextView id mainText



    – .





    id TextView



    » MainActivity

    MainActivity. , , Android Studio . - :

    , Android- BLE; BLE-; Grove BLE ; ; ; , .

    , . .



    Class Level

    , BLE, . Grove BLE v1 ( TI CC2540 – ) , :



    CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





    » Status helper

    TextView, . - statusUpdate



    – , . UI, .



    » BLE-

    () Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



    , – getAdapter()



    . – getDefaultAdapter



    Bluetooth Manager.



    » BLE-

    . Bluetooth- startLeScan



    , .



    API , , , LeScanCallback



    . , . . .



    @Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





    »

    BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



    . ( ), BluetoothGattCallback



    , onConnectionStateChanged



    onServicesDiscovered



    .



    onConnectionStateChanged



    , , mBluetoothGatt.discoverServices()



    . .



    @Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





    , . .



    »

    - sendMessage



    . UDID setValue



    . , BluetoothGatt writeCharacteristic



    , .



    setValue



    . ; , BLE- , .



    Intel Edison.



    Intel Edison, Grove BLE

    . , Intel Edison Arduino.



    Grove, «» Arduino. , Grove BLE v1 UART.





    Intel Edison Grove Shield BLE





    – Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



    GitHub .



    IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



    Intel Edison. setup()



    , loop()



    . .



    »

    Grove BLE 9600 , . . AT- Grove BLE . setup()



    .



    , «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



    »

    – . read()



    , , print()



    .



    Edison , 9600 .





    Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



    Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



    GitHub , Grove LCD. , Grove 5, LCD- I2C.





    BLEConnect





    Arduino IDE Serial Monitor BLEConnect-





    Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



    !




  4. :



    <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






    » UI

    : . , ID TextView. activity_main.xml layout, TextView id mainText



    – .





    id TextView



    » MainActivity

    MainActivity. , , Android Studio . - :

    , Android- BLE; BLE-; Grove BLE ; ; ; , .

    , . .



    Class Level

    , BLE, . Grove BLE v1 ( TI CC2540 – ) , :



    CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





    » Status helper

    TextView, . - statusUpdate



    – , . UI, .



    » BLE-

    () Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



    , – getAdapter()



    . – getDefaultAdapter



    Bluetooth Manager.



    » BLE-

    . Bluetooth- startLeScan



    , .



    API , , , LeScanCallback



    . , . . .



    @Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





    »

    BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



    . ( ), BluetoothGattCallback



    , onConnectionStateChanged



    onServicesDiscovered



    .



    onConnectionStateChanged



    , , mBluetoothGatt.discoverServices()



    . .



    @Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





    , . .



    »

    - sendMessage



    . UDID setValue



    . , BluetoothGatt writeCharacteristic



    , .



    setValue



    . ; , BLE- , .



    Intel Edison.



    Intel Edison, Grove BLE

    . , Intel Edison Arduino.



    Grove, «» Arduino. , Grove BLE v1 UART.





    Intel Edison Grove Shield BLE





    – Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



    GitHub .



    IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



    Intel Edison. setup()



    , loop()



    . .



    »

    Grove BLE 9600 , . . AT- Grove BLE . setup()



    .



    , «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



    »

    – . read()



    , , print()



    .



    Edison , 9600 .





    Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



    Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



    GitHub , Grove LCD. , Grove 5, LCD- I2C.





    BLEConnect





    Arduino IDE Serial Monitor BLEConnect-





    Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



    !




  5. :



    <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






    » UI

    : . , ID TextView. activity_main.xml layout, TextView id mainText



    – .





    id TextView



    » MainActivity

    MainActivity. , , Android Studio . - :

    , Android- BLE; BLE-; Grove BLE ; ; ; , .

    , . .



    Class Level

    , BLE, . Grove BLE v1 ( TI CC2540 – ) , :



    CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





    » Status helper

    TextView, . - statusUpdate



    – , . UI, .



    » BLE-

    () Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



    , – getAdapter()



    . – getDefaultAdapter



    Bluetooth Manager.



    » BLE-

    . Bluetooth- startLeScan



    , .



    API , , , LeScanCallback



    . , . . .



    @Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





    »

    BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



    . ( ), BluetoothGattCallback



    , onConnectionStateChanged



    onServicesDiscovered



    .



    onConnectionStateChanged



    , , mBluetoothGatt.discoverServices()



    . .



    @Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





    , . .



    »

    - sendMessage



    . UDID setValue



    . , BluetoothGatt writeCharacteristic



    , .



    setValue



    . ; , BLE- , .



    Intel Edison.



    Intel Edison, Grove BLE

    . , Intel Edison Arduino.



    Grove, «» Arduino. , Grove BLE v1 UART.





    Intel Edison Grove Shield BLE





    – Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



    GitHub .



    IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



    Intel Edison. setup()



    , loop()



    . .



    »

    Grove BLE 9600 , . . AT- Grove BLE . setup()



    .



    , «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



    »

    – . read()



    , , print()



    .



    Edison , 9600 .





    Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



    Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



    GitHub , Grove LCD. , Grove 5, LCD- I2C.





    BLEConnect





    Arduino IDE Serial Monitor BLEConnect-





    Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



    !




  6. :



    <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






    » UI

    : . , ID TextView. activity_main.xml layout, TextView id mainText



    – .





    id TextView



    » MainActivity

    MainActivity. , , Android Studio . - :

    , Android- BLE; BLE-; Grove BLE ; ; ; , .

    , . .



    Class Level

    , BLE, . Grove BLE v1 ( TI CC2540 – ) , :



    CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





    » Status helper

    TextView, . - statusUpdate



    – , . UI, .



    » BLE-

    () Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



    , – getAdapter()



    . – getDefaultAdapter



    Bluetooth Manager.



    » BLE-

    . Bluetooth- startLeScan



    , .



    API , , , LeScanCallback



    . , . . .



    @Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





    »

    BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



    . ( ), BluetoothGattCallback



    , onConnectionStateChanged



    onServicesDiscovered



    .



    onConnectionStateChanged



    , , mBluetoothGatt.discoverServices()



    . .



    @Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





    , . .



    »

    - sendMessage



    . UDID setValue



    . , BluetoothGatt writeCharacteristic



    , .



    setValue



    . ; , BLE- , .



    Intel Edison.



    Intel Edison, Grove BLE

    . , Intel Edison Arduino.



    Grove, «» Arduino. , Grove BLE v1 UART.





    Intel Edison Grove Shield BLE





    – Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



    GitHub .



    IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



    Intel Edison. setup()



    , loop()



    . .



    »

    Grove BLE 9600 , . . AT- Grove BLE . setup()



    .



    , «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



    »

    – . read()



    , , print()



    .



    Edison , 9600 .





    Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



    Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



    GitHub , Grove LCD. , Grove 5, LCD- I2C.





    BLEConnect





    Arduino IDE Serial Monitor BLEConnect-





    Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



    !




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




   : 
      



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



, . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




   : 
      



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



, . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




   : 
      



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



, . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!




:



<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>






» UI

: . , ID TextView. activity_main.xml layout, TextView id mainText



– .





id TextView



» MainActivity

MainActivity. , , Android Studio . - :

, Android- BLE; BLE-; Grove BLE ; ; ; , .

, . .



Class Level

, BLE, . Grove BLE v1 ( TI CC2540 – ) , :



CHARACTERISTIC_TX = "0000ffe1-0000-1000-8000-00805f9b34fb" CHARACTERISTIC_RX = "0000ffe1-0000-1000-8000-00805f9b34fb"





» Status helper

TextView, . - statusUpdate



– , . UI, .



» BLE-

() Bluetooth , BLE . Bluetooth (BluetoothManager) getSystemService



, – getAdapter()



. – getDefaultAdapter



Bluetooth Manager.



» BLE-

. Bluetooth- startLeScan



, .



API , , , LeScanCallback



. , . . .



@Override public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { … }





»

BLE- /. TI CC2540 Grove BLE ID «0000ffe0-0000-1000-8000-00805f9b34fb». .



. ( ), BluetoothGattCallback



, onConnectionStateChanged



onServicesDiscovered



.



onConnectionStateChanged



, , mBluetoothGatt.discoverServices()



. .



@Override public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState) { … } @Override public void onServicesDiscovered (BluetoothGatt gatt, int status) { … }





, . .



»

- sendMessage



. UDID setValue



. , BluetoothGatt writeCharacteristic



, .



setValue



. ; , BLE- , .



Intel Edison.



Intel Edison, Grove BLE

. , Intel Edison Arduino.



Grove, «» Arduino. , Grove BLE v1 UART.





Intel Edison Grove Shield BLE





– Android Intel Edison. , . Serial Monitor, (IDE) Arduino.



GitHub .



IDE Intel Arduino . « SimpleSerial ». Arduino , Intel Edison . , Edison, Edison Grove BLE. UART microUSB, BLE UART Grove.



Intel Edison. setup()



, loop()



. .



»

Grove BLE 9600 , . . AT- Grove BLE . setup()



.



, «Serial» ( microUSB- UART), – «Serial1» (UART, Grove BLE).



»

– . read()



, , print()



.



Edison , 9600 .





Verify IDE Arduino ( ) . , Intel Edison ( ). – Android. Serial Monitor Arduino IDE ( ) – .



Android BLEConnect Intel Edison. Serial Monitor «Hello Grove BLE». - , , , Android. , , .



GitHub , Grove LCD. , Grove 5, LCD- I2C.





BLEConnect





Arduino IDE Serial Monitor BLEConnect-





Android, . Android BLE , UI . Arduino Time Library , . GitHub, – .



!







All Articles