Skip to content

Pb 833 documentation of pybytes library api #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

alipsilv
Copy link
Contributor

This PR contains Pybytes API library documentation

@alipsilv alipsilv requested a review from lilycey January 17, 2020 17:07
- pybytes/api/send_signal
---

Send signal to the given pin.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's replace the word pin with signal_number.

I know that in the code the parameter name is still named pin. But it can confuse users, it does not have anything common with hardware pins on a device

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe, in the future, it's worth to change the parameter name from pin to signal_number

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please exchange the pin parameter to signal_number on this page.

Yes, I think it is a good idea to change the parameter name in the code. Please do it now, and create PR in pybytes-devices repository

Comment on lines 23 to 30
**Example**
----
`pybytes.update_config(key=None, value=None, permanent=True, silent=False, reconnect=False)`

**Success Response**
----

TBD test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's write some good example here, please. And complete the response

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not see the difference between pybytes.update_config and pybytes.set_config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pybytes.update_config(key="network_preferences", value="wifi", permanent=True, silent=False, reconnect=False)

Screenshot 2020-01-22 at 21 15 24

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works I've just updated wifi password. Please use this as an example in docs.
Also, write a Success response. thanks

>>> pybytes.print_config()
wifi = {'ssid': 'Pycom', 'password': 'PyE!ndh0ven#'}
cfg_msg = Pybytes configuration read from /flash/pybytes_config.json
wlan_antenna = 0
ota_server = {'port': 443, 'domain': 'software.pycom.io'}
server = mqtt.pybytes.pycom.io
ssl = False
lte = {'apn': 'soracom.io', 'cid': 1, 'reset': False, 'carrier': 'standard', 'band': 99, 'type': 'IP'}
device_id = 9305509f-4ea8-4d6b-824f-539c39e7ddf2
network_preferences = ['lte', 'wifi']
pybytes_autostart = True
dump_ca = False
username = [email protected]
>>>
>>>
>>> pybytes.update_config(key="wifi", value={'password': 'Pa$$w0rd'}, permanent=True, silent=False, reconnect=False)
Pybytes configuration written to /flash/pybytes_config.json
>>>
>>>
>>> pybytes.print_config()
wifi = {'ssid': 'Pycom', 'password': 'Pa$$w0rd'}
cfg_msg = Pybytes configuration read from /flash/pybytes_config.json
wlan_antenna = 0
ota_server = {'port': 443, 'domain': 'software.pycom.io'}
server = mqtt.pybytes.pycom.io
ssl = False
lte = {'apn': 'soracom.io', 'cid': 1, 'reset': False, 'carrier': 'standard', 'band': 99, 'type': 'IP'}
device_id = 9305509f-4ea8-4d6b-824f-539c39e7ddf2
network_preferences = ['lte', 'wifi']
pybytes_autostart = True
dump_ca = False
username = [email protected]
>>>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok it should work if a key you're trying to update is an object. if you have lte object in your confing, this should work:

pybytes.update_config(key="lte", value={'band': 99}, permanent=True, silent=False, reconnect=False)

I think it does not work on arrays like network_preferences
I wrote a ticket for this bug and assigned it to you. Thank you
https://pycomiot.atlassian.net/browse/PB-861

- pybytes/api/write_config
---

Write device configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look at this method and it is the private method which sneaked to public API
It will write config from self.__conf to a file

Let's remove this method from documentation

- pybytes/api/write_config
---

Write device configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look at this method and it is the private method which sneaked to public API
It will write config from self.__conf to a file

Let's remove this method from documentation

Copy link
Contributor

@jirkadev jirkadev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor

@lilycey lilycey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few changes for readability (please also double check the 0-99 debugging level)

aliases:
---

To test Pybytes library API, connect your device to Pymakr and call the methods listed below.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1st comment: To test the Pybytes library API, connect your device to Pymakr and call the methods listed below.

---

To test Pybytes library API, connect your device to Pymakr and call the methods listed below.
You can use Pybytes library API in your MicroPython project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd comment: You can use the Pybytes library API in your MicroPython project.



### Debugging
If you are facing any issues try to enable debugging.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3rd comment: Enable debugging if you are having any issues. There are multiple debug levels, the lowest is 0 which is for warnings only and 99 is the highest used and will print more debugging messages.


### Debugging
If you are facing any issues try to enable debugging.
There are multiple debug levels, 0 is warnings only, 99 is currently the highest used).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4th comment: ( I have just moved this sentence into the 3rd comment, so you can delete it)


**Success Response**
----
After sleep, device reconnect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5th comment: After deepsleep, the device reconnects.

- pybytes/api/set_custom_message_callback
---

Send custom message callback.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7th comment: Sends custom message callback.

- pybytes/api/start
---

Starts Pybytes library.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8th comment: Opens the Pybytes library.

- pybytes/api/read_config
---

Reads configuration from the given file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reads the configuration from the given file.

- pybytes/api/connect_wifi
---

Initialize watchdog for WiFi and LTE connection.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialize watchdog for the WiFi and LTE connection.

- pybytes/api/print_config
---

Prints current configuration in the terminal.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prints the current configuration in the terminal.

@alipsilv alipsilv merged commit c6a895a into development-publish Jan 28, 2020
@gijsio gijsio deleted the pb-833-documentation-of-pybytes-library-api branch July 20, 2020 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants