How to use the rak811.Rak811EventError function in rak811

To help you get started, we’ve selected a few rak811 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AmedeeBulle / pyrak811 / tests / test_cli.py View on Github external
def test_send_error(runner, mock_rak811):
    mock_rak811.return_value.send.side_effect = Rak811EventError(5)
    p = PropertyMock(return_value=0)
    type(mock_rak811.return_value).nb_downlinks = p
    result = runner.invoke(cli, ['-v', 'send', '--binary', '01020211'])
    mock_rak811.return_value.send.assert_called_once_with(
        data=bytes.fromhex('01020211'),
        confirm=False,
        port=1
    )
    assert result.output == 'RAK811 event error 5: Tx timeout\n'
github AmedeeBulle / pyrak811 / tests / test_cli.py View on Github external
def test_txc_error(runner, mock_rak811):
    mock_rak811.return_value.txc.side_effect = Rak811EventError(5)
    result = runner.invoke(cli, ['-v', 'txc', 'Hello'])
    mock_rak811.return_value.txc.assert_called_once_with(
        data='Hello',
        cnt=1,
        interval=60
    )
    assert result.output == 'RAK811 event error 5: Tx timeout\n'
github AmedeeBulle / pyrak811 / tests / test_rak811.py View on Github external
def test_join_otaa_failure(mock_send, mock_events, lora):
    """Test join_abp command, failure."""
    with raises(Rak811EventError,
                match='4'):
        lora.join_otaa()
    mock_send.assert_called_once_with('join=otaa')
    mock_events.assert_called_once()
github AmedeeBulle / pyrak811 / tests / test_rak811.py View on Github external
def test_txc_error(mock_send, mock_events, lora):
    """Test LoraP2P send with error."""
    with raises(Rak811EventError,
                match='5'):
        lora.txc('Hello')
    mock_send.assert_called_once_with('txc=1,60000,48656c6c6f')
    mock_events.assert_called_once()
github AmedeeBulle / pyrak811 / tests / test_cli.py View on Github external
def test_join_otaa_event(runner, mock_rak811):
    mock_rak811.return_value.join_otaa.side_effect = Rak811EventError(4)
    result = runner.invoke(cli, ['-v', 'join-otaa'])
    mock_rak811.return_value.join_otaa.assert_called_once()
    assert result.output == 'RAK811 event error 4: Join failed\n'
github AmedeeBulle / pyrak811 / rak811 / cli.py View on Github external
def print_exception(e):
    """Print exception raised by the Rak811 library."""
    if isinstance(e, Rak811ResponseError):
        click.echo('RAK811 response error {}: {}'.format(e.errno, e.strerror))
    elif isinstance(e, Rak811EventError):
        click.echo('RAK811 event error {}: {}'.format(e.errno, e.strerror))
    elif isinstance(e, Rak811TimeoutError):
        click.echo('RAK811 timeout: {}'.format(e))
    else:
        click.echo('RAK811 unexpected exception {}'.format(e))