-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
179 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 20.8b1 | ||
rev: 22.3.0 | ||
hooks: | ||
- id: black | ||
args: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
MAJOR_VERSION = 0 | ||
MINOR_VERSION = 29 | ||
MINOR_VERSION = 30 | ||
PATCH_VERSION = "0" | ||
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" | ||
__version__ = f"{__short_version__}.{PATCH_VERSION}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# flake8: noqa | ||
from . import application, backup, dump, ncp, network | ||
from . import application, backup, dump, ncp, network, stream, tone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import asyncio | ||
import logging | ||
import time | ||
|
||
import click | ||
|
||
from . import util | ||
from .main import main | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
@main.command() | ||
@click.option( | ||
"-c", "--channel", type=click.IntRange(11, 26), metavar="CHANNEL", required=True | ||
) | ||
@click.option( | ||
"-p", "--power", type=click.IntRange(-100, 20), metavar="POWER", required=True | ||
) | ||
@click.pass_context | ||
def stream(ctx, channel, power): | ||
"""Transmit random stream of characters on CHANNEL with POWER (in dBm).""" | ||
loop = asyncio.get_event_loop() | ||
try: | ||
loop.run_until_complete(_stream(ctx, channel, power)) | ||
except KeyboardInterrupt: | ||
start_time = ctx.obj.get("start_time", None) | ||
if start_time: | ||
duration = time.time() - start_time | ||
click.echo( | ||
"\nStreamed on channel %d for %0.2fs" % (channel, duration), err=True | ||
) | ||
finally: | ||
if "ezsp" in ctx.obj: | ||
s = ctx.obj["ezsp"] | ||
loop.run_until_complete(s.mfglibStopStream()) | ||
loop.run_until_complete(s.mfglibEnd()) | ||
s.close() | ||
|
||
|
||
async def _stream(ctx, channel, power): | ||
s = await util.setup(ctx.obj["device"], ctx.obj["baudrate"]) | ||
ctx.obj["ezsp"] = s | ||
|
||
v = await s.mfglibStart(False) | ||
util.check(v[0], "Unable to start mfglib") | ||
|
||
v = await s.mfglibSetChannel(channel) | ||
util.check(v[0], "Unable to set channel") | ||
|
||
v = await s.mfglibSetPower(0, power) | ||
util.check(v[0], "Unable to set power") | ||
|
||
v = await s.mfglibStartStream() | ||
util.check(v[0], "Unable to start stream") | ||
click.echo("Started transmitting random stream of characters", err=True) | ||
ctx.obj["start_time"] = time.time() | ||
while True: | ||
await asyncio.sleep(3600) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import asyncio | ||
import logging | ||
import time | ||
|
||
import click | ||
|
||
from . import util | ||
from .main import main | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
@main.command() | ||
@click.option( | ||
"-c", "--channel", type=click.IntRange(11, 26), metavar="CHANNEL", required=True | ||
) | ||
@click.option( | ||
"-p", "--power", type=click.IntRange(-100, 20), metavar="POWER", required=True | ||
) | ||
@click.pass_context | ||
def tone(ctx, channel, power): | ||
"""Transmit continuous unmodulated tone on CHANNEL with POWER (in dBm).""" | ||
loop = asyncio.get_event_loop() | ||
try: | ||
loop.run_until_complete(_tone(ctx, channel, power)) | ||
except KeyboardInterrupt: | ||
start_time = ctx.obj.get("start_time", None) | ||
if start_time: | ||
duration = time.time() - start_time | ||
click.echo( | ||
"\nStreamed on channel %d for %0.2fs" % (channel, duration), err=True | ||
) | ||
finally: | ||
if "ezsp" in ctx.obj: | ||
s = ctx.obj["ezsp"] | ||
loop.run_until_complete(s.mfglibStopTone()) | ||
loop.run_until_complete(s.mfglibEnd()) | ||
s.close() | ||
|
||
|
||
async def _tone(ctx, channel, power): | ||
s = await util.setup(ctx.obj["device"], ctx.obj["baudrate"]) | ||
ctx.obj["ezsp"] = s | ||
|
||
v = await s.mfglibStart(False) | ||
util.check(v[0], "Unable to start mfglib") | ||
|
||
v = await s.mfglibSetChannel(channel) | ||
util.check(v[0], "Unable to set channel") | ||
|
||
v = await s.mfglibSetPower(0, power) | ||
util.check(v[0], "Unable to set power") | ||
|
||
v = await s.mfglibStartTone() | ||
util.check(v[0], "Unable to start tone") | ||
click.echo("Started transmitting unmodulated tone", err=True) | ||
ctx.obj["start_time"] = time.time() | ||
while True: | ||
await asyncio.sleep(3600) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters