[[2013b/MemberOnly/進行状況]] #include "sm.h"で使用してネ!!! /* sm.h */ /* 送信と確認 */ /* マスター用プログラム */ /* sendmsg(送信メッセージ,受信メッセージ) */ /****スレーブに送信メッセージを送信した後、受信メッセージを受け取るまで待機。 ****/ sub sendmsg(string msg,string rps) { SendRemoteString(1,0,msg); string rmsg = ""; while(rmsg == "") { ReceiveRemoteString(1,true,rmsg); TextOut(0,LCD_LINE1,"Wait until slave"); TextOut(0,LCD_LINE2,"completes tasks..."); Wait(1000); } ResetScreen(); } /* スレーブ用プログラム */ /* btcheck(接続ポート番号) */ /* 接続の確認。失敗した場合"Something wrong"を表示。 */ sub btcheck(int conn) { while(!BluetoothStatus(conn) == NO_ERR) { ResetScreen(); TextOut(0,LCD_LINE1,"Something wrong"); Wait(1000); } ResetScreen(); } /* receive("受信メッセージ") */ /* マスターからメッセージを受け取る。 */ sub receive(string rd) { string msg; while(msg != rd) { ReceiveRemoteString(0,true,msg); ResetScreen(); TextOut(0,LCD_LINE1,"Receiving..."); Wait(1000); } ResetScreen(); TextOut(0,LCD_LINE1,"I got it!!"); Wait(1000); ResetScreen(); } /* repond("送信メッセージ") */ /* 応答のメッセージをマスターに送信 */ sub respond(string reply) { SendResponseString(1,reply); ResetScreen(); TextOut(0,LCD_LINE1,"Responded"); Wait(1000); ResetScreen(); } (C) 2014 ONO