iOS蓝牙设备CBCharacteristicPropertyIndi​​cate不获取数据

时间:2017-09-27 05:02:59

标签: ios objective-c bluetooth

蓝牙已成功连接。

致电 - public class TcpServer { private ServerThread thread; private boolean mRun = true; private boolean mEnd = false; public TcpServer() { thread = new ServerThread(); thread.start(); } private class ServerThread extends Thread { @Override public void run() { try { Boolean end = false; ServerSocket ss = new ServerSocket(TcpManager.SERVER_PORT); while (mRun) { //Server is waiting for client here, if needed Socket s = ss.accept(); BufferedReader input = new BufferedReader(new InputStreamReader(s.getInputStream())); //PrintWriter output = new PrintWriter(s.getOutputStream(), true); //Autoflush String st = input.readLine(); String remoteIP = s.getRemoteSocketAddress().toString(); int index = remoteIP.indexOf(":"); remoteIP = remoteIP.substring(1,index); Log.d("TCP READ", "TCP READ: " + st); if(st != null) listener.messageReceived(st, remoteIP); //output.println("Good bye and thanks for all the fish :)"); if(mEnd) { s.close(); mRun = false; } } ss.close(); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } //Declare the interface. The method messageReceived(String message) will must be implemented in the MyActivity //class at on asynckTask doInBackground public interface OnMessageReceived { public void messageReceived(String message, String ip); } private OnMessageReceived listener = null; public void SetMessageReceivedListener(OnMessageReceived listener) { this.listener = listener; } public void RemoveMessageReceivedListener() { this.listener = null; }

没有回调 - > (void)setNotifyValue:(BOOL)enabled forCharacteristic:(CBCharacteristic *)characteristic;

属性

|阅读|写|指示

0 个答案:

没有答案