Skip to content

Commit

Permalink
Implementation of internal Quectel command for setting network prefer…
Browse files Browse the repository at this point in the history
…ences (#490)

* implementation of internal Quectel command for setting network preferences

* fix in build_command_string

---------

Co-authored-by: wojdan <[email protected]>
  • Loading branch information
piotrwojdan and wojdan authored Dec 4, 2023
1 parent a26e00f commit 2ed5f77
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## moler 2.17.0
* Implementation of internal Quectel command for setting network preferences

## moler 2.16.0
* Tests on Python 3.12
* Warning for Pythons 2.7 -3.6 (support will be removed soon)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![image](https://img.shields.io/badge/pypi-v2.16.0-blue.svg)](https://pypi.org/project/moler/)
[![image](https://img.shields.io/badge/pypi-v2.17.0-blue.svg)](https://pypi.org/project/moler/)
[![image](https://img.shields.io/badge/python-2.7%20%7C%203.6%20%7C%203.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue.svg)](https://pypi.org/project/moler/)
[![Build Status](https://travis-ci.org/nokia/moler.svg?branch=master)](https://travis-ci.org/nokia/moler)
[![Coverage Status](https://coveralls.io/repos/github/nokia/moler/badge.svg?branch=master)](https://coveralls.io/github/nokia/moler?branch=master)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
author = 'Nokia'

# The short X.Y version
version = '2.16.0'
version = '2.17.0'
# The full version, including alpha/beta/rc tags
release = 'stable'

Expand Down
7 changes: 7 additions & 0 deletions docs/source/moler.cmd.at.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ moler.cmd.at.quectel\_lock\_nr\earfcn module
:undoc-members:
:show-inheritance:

moler.cmd.at.quectel\_network\_preferences module
--------------------------------------

.. automodule:: moler.cmd.at.quectel_network_preferences
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------
Expand Down
69 changes: 69 additions & 0 deletions moler/cmd/at/quectel_network_preferences.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
"""
AT+QNWPREFCFG="{config_option}",(option_value)[:(option_value)]
AT commands specification:
google for: Quectel RG50xQRM5xxQ (R11 release and later)
This is internal Quectel AT command
(always check against the latest vendor release notes)
"""

__author__ = 'Piotr Wojdan'
__copyright__ = 'Copyright (C) 2023, Nokia'
__email__ = '[email protected]'

from moler.cmd.at.genericat import GenericAtCommand


class QuectelNetworkPreferences(GenericAtCommand):
"""
Command to set configuration for network searching preferences. Example outputs:
AT+QNWPREFCFG= "mode_pref",LTE
OK
AT+QNWPREFCFG= "mode_pref",LTE:NR5G
OK
"""
def __init__(self, config_option, option_value, connection=None, prompt=None, newline_chars=None, runner=None):
"""
Quectel UE set parameter in configuration for network searching preferences.
:param config_option: parameter name to be set
:param option_value: value to be set
:param connection: Moler connection to device, terminal when command is executed.
:param prompt: prompt where we start from.
:param newline_chars: Characters to split local lines - list.
:param runner: Runner to run command.
"""
super(QuectelNetworkPreferences, self).__init__(connection, operation="execute", prompt=prompt,
newline_chars=newline_chars, runner=runner)
self.ret_required = False
self.config_option = config_option
self.option_value = option_value

def build_command_string(self):
command_prefix = 'AT+QNWPREFCFG='
return '{}"{}",{}'.format(command_prefix, self.config_option, self.option_value)


# -----------------------------------------------------------------------------
# Following documentation is required for library CI.
# It is used to perform command self-test.
#
# Moreover, it documents what will be COMMAND_RESULT when command
# is run with COMMAND_KWARGS on COMMAND_OUTPUT data coming from connection.
#
# When you need to show parsing of multiple outputs just add suffixes:
# COMMAND_OUTPUT_suffix
# COMMAND_KWARGS_suffix
# COMMAND_RESULT_suffix
# -----------------------------------------------------------------------------

COMMAND_OUTPUT_option = """
AT+QNWPREFCFG="nr5g_band",66
OK
"""

COMMAND_KWARGS_option = {'config_option': 'nr5g_band', 'option_value': '66'}

COMMAND_RESULT_option = {}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name='moler', # Required
version='2.16.0', # Required
version='2.17.0', # Required
description='Moler is library to help in building automated tests', # Required
long_description=long_description, # Optional
long_description_content_type='text/markdown', # Optional (see note above)
Expand Down

0 comments on commit 2ed5f77

Please sign in to comment.