仕事
個人活動
http://tanaka733.net
https://www.nuget.org/profiles/tanaka_733/
https://github.com/tanaka-takayoshi
3か月に1回程度の勉強会中心のコミュニティ
めと #とは
iPhoneやiPadで使えるドン!可愛さと実用性を兼ね備えた
『太鼓の達人』専用Bluetoothコントローラ「太鼓とバチ」12月発売
なんでBluetooth?
マスター・スレイブ通信
リンク層プロトコル
ペアリング
プロファイル
サービスディスカバリ
BR/EDR (RFCOMM)
Bluetooth LTE (GATT)
詳細はブログに書いています
Texas Instrument
Bluetooth Low Energy(CC2541)SensorTag
温度センサ
湿度センサ
圧力センサ
加速度計
ジャイロスコープ
磁力計
RFCOMM Scenario: Send File as a Client(XAML)
RFCOMM Scenario: Receive File as a Server(XAML)
GATT Scenario: Retrieve Bluetooth LE Data(XAML)
GATT Scenario: Control a Bluetooth LE Thermometer Device(XAML)
Bluetooth for Windows Phone 8
【連載】Bluetooth LE (1) Bluetooth Low Energy の基礎
Bluetooth SMART デバイス(LE GATT Profile)と連携するWindows
Store Appsの開発
http://code.msdn.microsoft.com/windowsapps/Bluetooth-Rfcomm-Chat-
afcee559/view/Discussions#content
http://code.msdn.microsoft.com/windowsapps/Bluetooth-Generic-5a99ef95/
http://blogs.msdn.com/b/flecoqui/archive/2013/12/13/windows-store-and-
windows-phone-app-to-app-communication-over-bluetooth.aspx
http://msdn.microsoft.com/ja-jp/library/windows/apps/dn263090.aspx
<Capabilities>
<m2:DeviceCapability Name="bluetooth.rfcomm">
<m2:Device Id="any">
<m2:Function Type="serviceId:BEFB3B5F-C81D-48BB-8136-72E6BC3D0169"/>
</m2:Device>
</m2:DeviceCapability>
<m2:DeviceCapability Name="bluetooth.genericAttributeProfile">
<m2:Device Id="any">
<m2:Function Type="serviceId:f000aa00-0451-4000-b000-000000000000" />
<m2:Function Type="serviceId:f000aa10-0451-4000-b000-000000000000" />
</m2:Device>
</m2:DeviceCapability>
</Capabilities>
<Capabilities>
<m2:DeviceCapability Name="bluetooth.rfcomm">
<m2:Device Id="any">
<m2:Function Type="serviceId:BEFB3B5F-C81D-48BB-8136-72E6BC3D0169"/>
</m2:Device>
</m2:DeviceCapability>
<m2:DeviceCapability Name="bluetooth.genericAttributeProfile">
<m2:Device Id="any">
<m2:Function Type="serviceId:f000aa00-0451-4000-b000-000000000000" />
<m2:Function Type="serviceId:f000aa10-0451-4000-b000-000000000000" />
</m2:Device>
</m2:DeviceCapability>
</Capabilities>
https://github.com/tanaka-
takayoshi/BluetoothRfcommUniversalApp
//appxmanifet で指定したServiceUUIDを使う
rfcommProvider = await RfcommServiceProvider.CreateAsync(
RfcommServiceId.FromUuid(BluetoothServiceUuid));
//Socket作成して、Clientからの接続を待機
socketListener = new StreamSocketListener();
socketListener.ConnectionReceived += OnConnectionReceived;
await socketListener.BindServiceNameAsync(rfcommProvider.ServiceId.AsString(),
SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);
//SDPに設定する部分は略
//Advertising開始
rfcommProvider.StartAdvertising(socketListener);
//ペアリングされている端末を検出
PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
var Peers = await PeerFinder.FindAllPeersAsync();
//検出した端末から1台選択
var device =
(await BluetoothRfcommClient.GetListPairedDevices()).First();
socket = new StreamSocket();
await socket.ConnectAsync(
new HostName(device.HostName), BluetoothServiceName);
//Advertising停止
PeerFinder.Stop();
writer = new DataWriter(socket.OutputStream);
//送信するバイトの長さ+byte配列を書きこみ
writer.WriteUInt32((uint)Command.CommandLength);
writer.WriteBytes(Command.CommandBytes);
await writer.StoreAsync();
Bluetooth SMART デバイス(LE GATT Profile)と連携する
Windows Store Appsの開発
https://github.com/tanaka-takayoshi/TISensor.Rx
//SensorごとのUUIDを指定して端末を検出する
var selector = GattDeviceService.GetDeviceSelectorFromUuid(
new Guid(sensorServiceUuid));
var devices = await DeviceInformation.FindAllAsync(selector);
var device = devices.First();
//ID指定でサービスを作成
deviceService = await GattDeviceService.FromIdAsync(deviceInfo.Id);
//センサーを有効化 (センサーによっては書きこむ値が違う)
var configCharacteristic = deviceService.GetCharacteristics(
new Guid(sensorConfigUuid)).First();
await configCharacteristic.WriteValueAsync(new byte[] {1}.AsBuffer());
dataCharacteristic = deviceService.GetCharacteristics(
new Guid(sensorDataUuid)).First();
await dataCharacteristic.
WriteClientCharacteristicConfigurationDescriptorAsync(
GattClientCharacteristicConfigurationDescriptorValue.Notify);
dataCharacteristic.ValueChanged += (sender, args) =>
{
ReadRawData(args);
};
public IObservable<SensorRawValue> StartMonitor()
{
return
Observable.FromEventPattern<
TypedEventHandler<GattCharacteristic,
GattValueChangedEventArgs>,
GattValueChangedEventArgs>(
h => dataCharacteristic.ValueChanged += h,
h => dataCharacteristic.ValueChanged -= h)
.Select(p => ReadRawData(p.EventArgs));
}
using
20140802 Bluetooth を使って Universall App で大連携

20140802 Bluetooth を使って Universall App で大連携