Pro MicroをUSBキーボードとして使用する

TODO
Pro MicroをUSBキーボードとして使用する

HW

Pro Micro

参考

その他メモ

  • Windows7でPro MicroをUSB接続した場合に、ドライバのインストールが必要
  • ただし手順にある方法ではドライバを認識しなかったので、当該デバイスのハードウェアIDをsparkfun.infに追記してドライバを更新した

以下を追記

%DESCRIPTION%=DriverInstall, USB\VID_xxxx&PID_yyyy&REV_zzzz
%DESCRIPTION%=DriverInstall, USB\VID_xxxx&PID_yyyy

動作確認したスケッチ

#include <Keyboard.h>

void setup()
{
}

void loop()
{
  {
    Keyboard.print("sample");
    Keyboard.write('1');
    Keyboard.write('2');
    Keyboard.write('3');
    Keyboard.write('['); // for '@'
    Keyboard.write(KEY_RETURN);
    delay(5000);
  }
}

OpenWrtでパケットキャプチャ可能なリピータハブ

TODO
OpenWrtを有線リピータハブとして使用する。

HW

Buffalo WHR-G301N

参考

この手順書を途中まで進めることでリピータハブとして動作させる。
要点は

設定

/etc/config/network
config 'interface' 'loopback'
	option 'ifname' 'lo'
	option 'proto' 'static'
	option 'ipaddr' '127.0.0.1'
	option 'netmask' '255.0.0.0'

config 'interface' 'wan'
	option 'ifname' 'eth1'
	option 'proto' 'static'
	option 'ipaddr' '192.168.222.111'
	option 'netmask' '255.255.255.0'

config 'switch'
	option 'name' 'eth0'
	option 'reset' '1'
	option 'enable_vlan' '1'
	option 'enable_learning' '0'

/etc/config/firewall
以下を追記

#Allow SSH
config rule
	option src wan
	option proto tcp
	option dest_port ssh
	option target ACCEPT
/etc/init.d/network

以下を追加

boot() {の最後に
	/sbin/swconfig dev eth0 set enable_learning 0 # add
start() {の最後に
	/sbin/swconfig dev eth0 set enable_learning 0 # add
各種サービスの停止

LAN側のDHCPサーバの停止

/etc/init.d/dnsmasq stop
/etc/init.d/dnsmasq disable

Raspberry Pi Zero WでBluetooth

メモ

import evdev
from evdev import InputDevice, categorize, ecodes

devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
for device in devices:
    print(device.path, device.name, device.phys)

dev = evdev.InputDevice('/dev/input/event0')
print(dev)
dev.capabilities()
dev.capabilities(verbose=True)

for event in dev.read_loop():
    if event.type == ecodes.EV_KEY:
        print(categorize(event))
pi@raspberrypi:~/bluetooth_shutter $ python evdev_shutter.py
('/dev/input/event0', 'AB Shutter3       ', 'B8:27:EB:xx:xx:xx')
device /dev/input/event0, name "AB Shutter3       ", phys "B8:27:EB:xx:xx:xx"
key event at 1533192623.166096, 28 (KEY_ENTER), down
key event at 1533192623.203584, 115 (KEY_VOLUMEUP), down
key event at 1533192623.278570, 115 (KEY_VOLUMEUP), up
key event at 1533192623.353599, 28 (KEY_ENTER), up
key event at 1533192628.003608, 115 (KEY_VOLUMEUP), down
key event at 1533192628.256591, 115 (KEY_VOLUMEUP), hold

Raspberry Pi Zero WのSDイメージのバックアップ

Raspberry Piの本体を使用せずにPCでSDカードのイメージを

  • バックアップ
  • リストア

する場合のメモ。

  1. GParted Liveを使用してパーティションを(少し)縮小しておく
  2. Win32 Disk Imager を使用してSDカードから"Read"でイメージファイルを保存する
  3. Win32 Disk Imager を使用して(別の)SDカードに"Write"でイメージファイルを書き込む