関西支部android勉強会(ロボットxnfc)
DESCRIPTION
TRANSCRIPT
Re:Kayo-System Co.,Ltd.
Twitter @yokmamaNow Loading. Please Wait ...
ロボット x NFC「日本Androidの会 関西支部勉強会 - わたし、気になります!」場所:ECCコンピュータ専門学校 日時:2012/09/01
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
自己紹介氏名 :寺園聖文(てらぞの まさふみ)
肩書 :株式会社Re:Kayo-System 代表取締役社長
活動拠点 :神戸近郊~日本→海外行きたい
著書 :「10日でおぼえるAndroidアプリ開発入門教室」著(翔泳社)
「HTML5によるAndroidアプリ開発入門」監修(日経BP)
アプリ :「JUST PLAYER」「Skip Memo」「ふりがなオートマチック」等
好きなもの:アニメ、決して萌えじゃない、見てるけど、あくまで研究の一環
嫌いなもの:とくになし
最近のテーマ:電子工作、運動すること、英語
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
NFCとロボット
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
NFCとは
•近距離無線通信の名称• Android2.3で実装された• ICOCA、SUICAので使われている
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
AndroidのNFCでできる事①
Tag
IDカードもどき、カード判定
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
AndroidのNFCでできる事②
NDEF NDEF
NDEF
磁気カードもどき
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
AndroidのNFCでできる事③
NDEF
NDEF
P2P通信もどき
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
AndroidのNFCでできる事④
Tag
カード通信ライト
NfcFNfcANfcBNfcV
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
NFCとその他の違いNFC QR 磁気カード 紙カード
読み取り 専用リーダー カメラ+機器 専用リーダー 目
書き込み 専用ライター 不可 専用ライター 手
速度 ◯ ☓ ◎ ◯
可搬性 ◎ ◎ ◯ ☓
コスト ☓ ◎ ◯ ◎
セキュリティー ◎ ☓ ◯ ☓
大きさ ◎ ☓ ☓ ☓
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
NFCとその他の違いNFC QR 磁気カード 紙カード
読み取り 専用リーダー カメラ+機器 専用リーダー 目
書き込み 専用ライター 不可 専用ライター 手
速度 ◯ ☓ ◎ ◯
可搬性 ◎ ◎ ◯ ☓
コスト ☓ ◎ ◯ ◎
セキュリティー ◎ ☓ ◯ ☓
大きさ ◎ ☓ ☓ ☓
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
書き込みしてなんぼ
僕の見解
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
さて本題
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
ロボット X NFC
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
DroidRobo01制作:cattaka_net
AndroidからADKを用いてロボットの手足目を制御する。
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
NFCでどうかする
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
NFCのカードをかざすことで規定のモーションをするのではつまらん
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
書き込みしてなんぼ
僕の見解
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
LedArmWheel
LedArmWheel
LedArmWheel
LedArmWheel
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
Demo
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
プログラム解説
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
private IntentFilter[] nfcfilters = new IntentFilter[] { new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED) };
private String[][] nfctechLists = new String[][] { new String[] { Ndef.class.getName() }, new String[] { NdefFormatable.class.getName() } };
@Override protected void onPause() { super.onPause(); nfcadapter.disableForegroundDispatch(this); }
@Override protected void onResume() { super.onResume(); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()), 0); nfcadapter.enableForegroundDispatch(this, pendingIntent, nfcfilters, nfctechLists); }
Filter設定
ForegroundDispach
Filter Type
Tech Type
NFCの有効化
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
if (Arrays.asList(tag.getTechList()).contains(NdefFormatable.class.getName())) { NdefFormatable ndef = NdefFormatable.get(tag); try { if (!ndef.isConnected()) { ndef.connect(); } ndef.format(createNdefMessage()); Toast.makeText(this, "Write Success.", Toast.LENGTH_SHORT).show(); } finally { ndef.close(); } } else if (Arrays.asList(tag.getTechList()).contains(Ndef.class.getName())) { Ndef ndef = Ndef.get(tag); try { if (!ndef.isConnected()) { ndef.connect(); } if(ndef.isWritable()){ ndef.writeNdefMessage(createNdefMessage()); Toast.makeText(this, "Write Success.", Toast.LENGTH_SHORT).show(); } else{ Toast.makeText(this, "Writing is not supported", Toast.LENGTH_SHORT).show(); } } finally { ndef.close(); } }
TechTypeによる処理の分岐 @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); String action = intent.getAction(); if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) { Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); writeNdefMotionTag(tag); } }
受信
分岐
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
書込処理
private NdefMessage createNdefMessage() throws IOException { byte[] mimeBytes = "application/jp.co.kayo.android.droiddancermotionwriter".getBytes(Charset.forName("US-ASCII")); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); byte[] header = new byte[2]; header[0] = new Integer(seekBar1.getProgress()).byteValue(); header[1] = new Integer(items.size()).byteValue(); bytes.write(header); for(MotionItem item : items){ byte[] data = new byte[6]; data[0] = new Integer(item.isLed()?1:0).byteValue(); data[1] = new Integer(item.getArmleft()).byteValue(); data[2] = new Integer(item.getArmright()).byteValue(); data[3] = new Integer(item.getRotleft()).byteValue(); data[4] = new Integer(item.getRotright()).byteValue(); data[5] = new Integer(item.getTime()).byteValue(); bytes.write(data); } NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeBytes, new byte[0], bytes.toByteArray()); return new NdefMessage(new NdefRecord[]{record}); }
Header:Rep 8bitSize 8bit
Data:LED 8bitARM_L 8bitARM_R 8bitROT_L 8bitROT_R 8bitTIME 8bit
Data:LED 8bitARM_L 8bitARM_R 8bitROT_L 8bitROT_R 8bitTIME 8bit
Data:LED 8bitARM_L 8bitARM_R 8bitROT_L 8bitROT_R 8bitTIME 8bit
Data:LED 8bitARM_L 8bitARM_R 8bitROT_L 8bitROT_R 8bitTIME 8bit
・・・
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
https://github.com/yokmama/adkworks
ソースコード
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
考察
https://github.com/yokmama/adkworks
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
https://github.com/yokmama/adkworks
NFCTagを使うことで複雑なロジックを隠蔽化し誰でもタッチするだけでActionを起こすこ
とができる。
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
https://github.com/yokmama/adkworks
しかし、今のままではだめ
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
https://github.com/yokmama/adkworks
対象の機器毎にタグを作るアプリを選ばないといけないため、タグがガラパゴス
になっている。
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
https://github.com/yokmama/adkworks
そこで考えてみた
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
https://github.com/yokmama/adkworks
NFCTagのデータ・フォーマットを規定化し、Tagへの書込読込処理をオープンにし、
タグに対応した機器は、コマンドやパラメータを公開してはどうか?
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
https://github.com/yokmama/adkworks
NFCTagの規格に従い各メーカーは対応する電気製品を
作ってくれれば、汎用的なNFCTagを作成するアプリを作れるはずだ。
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
実はTAGの規格はある
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
TNFとRTDTNF:Type Name Field
TNF_ABSOLUTE_URITNF_EMPTYTNF_EXTERNAL_TYPETNF_MIME_MEDIATNF_UNCHANGEDTNF_UNKNOWNTNF_WELL_KNOWN
RTD : Record Type DefinitionRTD_TEXT RTD_URI RTD_SMART_POSTER RTD_ALTERNATIVE_CARRIER RTD_HANDOVER_CARRIER RTD_HANDOVER_REQUEST RTD_HANDOVER_SELECT
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
しかしこれは不十分なのだ
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
課題•一方通行•複数アプリケーション•パラメータのフォーマットがない•送受信データの圧縮技術•送信データの妥当性チェック•etc,etc
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
クラウドサービス
デバイス デバイス デバイス デバイス
WAN
NFCTag
SmartPhone,PC
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
https://github.com/yokmama/adkworks
学習机にタグ
冷蔵庫にタグ
電子レンジにタグ
今日の宿題が画面にでてくる。宿題がおわったらもう一度タグにタッチする
タグから子供がタッチしたことがわかるので、誰々ようのおやつをナビし、温め
時間をタグに書き込む
冷蔵庫から書かれたタグから、電子レンジの時間を設定する
12年8月30日木曜日
Re:Kayo-System Co.,Ltd.
ご清聴ありがとうございました。
https://github.com/yokmama/adkworks
12年8月30日木曜日