Bluetooth 接続したいので、技適を通っている Bluetooth モジュールを考える。ちょうど BLE Nano という製品が技適を通っていて mbed 対応だったため、これをメインMCUとして使用することとした。 mbed で公式にサポートされているUSBボードと比べて圧倒的に小さく、ライターとともに購入してもなお安いというのもあった。ただし BLE Nano は名前の通り Blueooth LE (4.0) のモジュールなので、多少の不安はあった。
消費電力削減のためハード設計の段階で MCP23017 の割込み生成を使うこととした。MCP23017 側でピン変更を検知した場合 INT ピンを通じて BLE Nano 側に割込みを発生させる。MCP23017 は2つ使うが、割込み生成は1つで良いので、割込みピンを BLE Nano 側でプルアップし、2つのMCP23017はオープンドレインで割込みを生成するように設定する。
Apple Magic Keyboard (Wireless Keyboard ではなく) は BLE 接続らしいけど、どうなってるのかよくわからない。DeviceInformationService で PnP ID を偽称してみたりしてみたけど、うまく認識しなかった。このキーボード、思いのほか高価なので試しに買ってみて調べるみたいなこともできずモヤモヤした。
BLE と Windows
Windows とのペアリングは非常にスムーズで問題がなかった。ちゃんとキーボードとして認識されるし、OS X よりマトモ。ただ Windows でもバッテリーステータスを確認する方法がわからなかった。
BLE と Android
さすがにスマフォは BLE の対応がしっかりしていて、まともにペアリングできるし、ちゃんと使える。
nRF Connect で GATT 情報を見ると OS X 上で LightBlue を使って見るよりも多くの情報を得られる。BLE に関してはスマフォも活用してデバッグしたほうが捗る。
vfprintf.c:(.text.__ssputs_r+0x46): undefined reference to `__wrap__malloc_r'
vfprintf.c:(.text.__ssputs_r+0x66): undefined reference to `__wrap__realloc_r'
vfprintf.c:(.text.__ssputs_r+0x72): undefined reference to `__wrap__free_r'
The watchdog must be configured before it is started. After it is started, the watchdog’s configuration registers, which comprises registers CRV, RREN, and CONFIG, will be blocked for further configuration.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.HumanInterfaceDevice;
using Windows.Devices.Enumeration;
// WindowsRuntimeSystemExtensions could not be found
// using WindowsRuntimeSystemExtensions.AsTask;
namespace Foo
{
class Program
{
const UInt16 USAGE_PAGE = 0x01; // Generic Desktop Ctrls
const UInt16 USAGE_ID = 0x06; // Keyboard
static void Main(string[] args)
{
Task.Factory.StartNew(async () =>
{
await new Program().run();
})
.Unwrap()
.Wait();
}
private async Task run()
{
var selector = HidDevice.GetDeviceSelector(USAGE_PAGE, USAGE_ID);
var devices = await DeviceInformation.FindAllAsync(selector);
Console.WriteLine("%s", devices);
}
}
}
Could not install package 'System.Runtime.WindowsRuntime 4.0.11'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
========== Finished ==========
Switching Boot Modes The initial boot mode is set by PSKEY_INITIAL_BOOTMODE. If this PS Key is set to 2 (HID proxy mode), CSR8510 A10 enumerates as USB HID device.
When the PC boots with its operating system and Bluetooth host stack, the Bluetooth host stack may reboot the CSR8510 A10 in mode 0 (standard HCI operation). In this mode, the Bluetooth Host Stack handles the HID device functions.
Note: Switching from HID to HCI is allowed in both HID Boot Protocol Mode and HID Report Protocol Mode configuration. In HID Report Protocol Mode, the USB report descriptors should include the feature report to accept the USB Set Feature request to accept the command from the host.
Beagle Bone Black は TI の ARM SoC である AM3359AZCZ100 がメインCPUの、Raspberry Pi に似たカードサイズ Linux コンピュータです。GPIO が豊富にあり、これに Machinekit をインストールすることで、単体でCNCコントローラにできます。
パラレルポートに依存した環境構築というのは今時ちょっとやる気が起きませんし、パラレルポートが増設可能なフル装備の Linux コンピュータを組み立てようと思うと結構コストがかかります。Beagle Bone だと単体で役目を果たすことができます。
Raspberry Pi ではダメなのか? という疑問があるかと思いますが、実は BBB にあって Raspberry Pi にはない重要な機能があります。それが PRU (Programmable Real-time Unit) です。
3D CAD をやってみて、やはりプログラミングを先にいろいろやっていて良かったと感じる。仕事で「プログラミングできて良かった」と思うことは極めて稀だが、趣味でいろんなことをしてみると全く「プログラミングをできて良かった」と思うことが多い。拘束とは制約プログラミングだと気付ければ難しいことが一切なくなり、便利さだけが理解できる。
街には「地域ぐるみでなくそう路上喫煙」とか旗が立ってたりするが、喫煙者はすぐそばで路上喫煙をする。彼らは文字が読めないので仕方がない。対応策が間違っているのだ。喫煙者はなぜか人間として扱われているが、識字率99%以上のこの国で文字が読めないので、初等教育も受けていないことは明白であり、人間のような姿に見える他の生物である。JT とかいう独占企業があってモラルを啓蒙して「おれは悪くない」アピールをしているが、そもそも人間ではない生物にはモラルなどなく、判断能力のないそれに、中毒症状をいいことに薬物を売りつけるのが JT であって、今すぐにでも滅びなければならない。