Giter VIP home page Giter VIP logo

pynus's Introduction

pynus

NUS client for Nordic nRF based systems

Example of cross platform data transmission between Nordic UART Service (NUS) and Python using the Bleak Project and Adafruit nrf52 Libraries

Overview

This program establish connection with nRF micro using BLE NUS protocol then you can send data between your PC and the board like normal terminal.

This program was tested using pinewatch as nRF micro and arch linux + python 3.10 on PC side. Pinewatch was flashed using ztime (https://github.com/AlexXZero/ztime) firmware. On the python side, the Bluetooth Low Energy platform Agnostic Klient for Python (Bleak) project is used for Cross Platform Support.

Usage

During this test keys Shift+D were pressed three times. ztime should answered using line "D:NI\r\n" since 'D' character accepted:

ztime test code:

static ssize_t ble_nus_write_handler(struct bt_conn *conn, const struct bt_gatt_attr *attr,
                                     const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
{
  for (uint16_t i = 0; i < len; i++) {
    switch (buf[i]) {
    case 'D':
      ble_nus_write("D:NI\r\b", 6);
      break;
    default:
      // TODO
      break;
    }
  }
  return len;
}

PC Output:

$ ./pynus.py -a C4:AB:AD:F1:CC:33
Connected: <coroutine object BleakClientBlueZDBus.connect at 0x7fd6f42ee810>
D:NI
D:NI
D:NI
Disconnect.
/usr/lib/python3.10/asyncio/events.py:80: RuntimeWarning: coroutine 'BleakClientBlueZDBus.connect' was never awaited
  self._context.run(self._callback, *self._args)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Note: This software is not intended for use on the territory of the Russian Federation and the Republic of Belarus. Any problems, up to and including damage to the device on which this software is running, are the responsibility of the user of this device.

pynus's People

Contributors

alexxzero avatar

Stargazers

David J. Kordsmeier avatar

Watchers

 avatar

pynus's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.