|
<<
2015.2
>>
[nao-pon/blog] |
||||||
| 日 | 月 | 火 | 水 | 木 | 金 | 土 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 19 | 20 | 21 | |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Android アプリの Tasker でスリープ中で非通信時に、エアプレーンモードにしようと思い、ネットワーク通信量を計りたかったので、そんなタスクをつくってみた。
getNetKbps (3)
A1: If [ %par1 Set ] A2: Variable Set [ Name:%sec To:%par1 Do Maths:Off Append:Off ] A3: Else A4: Variable Set [ Name:%sec To:10 Do Maths:Off Append:Off ] A5: End If A6: Variable Set [ Name:%tx1 To:0 Do Maths:Off Append:Off ] A7: Variable Set [ Name:%rx1 To:0 Do Maths:Off Append:Off ] <check> A8: Run Shell [ Command:busybox ifconfig wlan0 Timeout (Seconds):0 Use Root:Off Store Output In:%res Store Errors In: Store Result In: ] A9: Variable Search Replace [ Variable:%res Search:(Rx bytes:)(\d+)(.*Tx bytes:)(\d+) Ignore Case:On Multi-Line:Off One Match Only:On Store Matches In: Replace Matches:On Replace With:|$2|$4| ] A10: [X] Flash [ Text:%res Long:Off ] A11: Variable Split [ Name:%res Splitter:| Delete Base:On ] A12: If [ %rx1 eq 0 ] A13: Variable Set [ Name:%rx1 To:%res2 Do Maths:Off Append:Off ] A14: Variable Set [ Name:%tx1 To:%res3 Do Maths:Off Append:Off ] A15: Wait [ MS:0 Seconds:%sec Minutes:0 Hours:0 Days:0 ] A16: Goto [ Type:Action Label Number:1 Label:check ] A17: Else A18: Variable Set [ Name:%bps To:((%res2-%rx1)+(%res3-%tx1))/%sec/1024 Do Maths:On Append:Off ] A19: [X] Flash [ Text:((%res2-%rx1)+(%res3-%tx1))/%sec Long:On ] A20: [X] Flash [ Text:%bps Long:Off ] A21: End If A22: Return [ Value:%bps Stop:On ]
デバグ用に Flash 入れて無効にしてあります。