2017年11月22日 星期三

[C#] async與await

看了之後,終於有點了解

async & await 的前世今生
http://www.cnblogs.com/jesse2013/p/async-and-await.html

2017年11月2日 星期四

[LinkIt One]Bluebooth SPP 連線&傳輸

網路上找的小程式
#include <LBT.h>
#include <LBTServer.h>

#define btName "BT_SPP"

int i=0;

void setup() {
  // put your setup code here, to run once:
Serial.begin( 9600 );
while(!Serial);

pinMode(13,OUTPUT);

if(!LBTServer.begin((uint8_t*)btName))
{
  Serial.print("Fail to start BT\n");
  return;
}
Serial.print("BT server is started\n");

for(int i=0;i<3;i++)
{
  digitalWrite(13,HIGH);
  delay(300);
  digitalWrite(13,LOW);
  delay(300);
}
}

void loop() {
  // put your main code here, to run repeatedly:
uint8_t buf[64];
int bytesRead;

if(LBTServer.connected())
{
   
   bytesRead = LBTServer.readBytes(buf, 1);
   if(bytesRead)
   {
      Serial.printf("RECV DATA:%x\n",buf[0]); 
   }
   else
   {
      Serial.print("Connected\n"); 
   }
}
else
{
  Serial.printf("Not connected:%d\n",i++);
  LBTServer.accept(5);
}



將之前的 PC程式,修改client 端:
//PC write
 buffer[0] = 0x05;
perStream.Write(buffer, 0, 1);

感動勒....有通聯