Source code for pyupm_hm11

# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.





from sys import version_info
if version_info >= (2, 6, 0):
    def swig_import_helper():
        from os.path import dirname
        import imp
        fp = None
        try:
            fp, pathname, description = imp.find_module('_pyupm_hm11', [dirname(__file__)])
        except ImportError:
            import _pyupm_hm11
            return _pyupm_hm11
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_hm11', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_hm11 = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_hm11
del version_info
try:
    _swig_property = property
except NameError:
    pass  # Python < 2.2 doesn't have 'property'.


def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
    if (name == "thisown"):
        return self.this.own(value)
    if (name == "this"):
        if type(value).__name__ == 'SwigPyObject':
            self.__dict__[name] = value
            return
    method = class_type.__swig_setmethods__.get(name, None)
    if method:
        return method(self, value)
    if (not static):
        if _newclass:
            object.__setattr__(self, name, value)
        else:
            self.__dict__[name] = value
    else:
        raise AttributeError("You cannot add attributes to %s" % self)


def _swig_setattr(self, class_type, name, value):
    return _swig_setattr_nondynamic(self, class_type, name, value, 0)


def _swig_getattr_nondynamic(self, class_type, name, static=1):
    if (name == "thisown"):
        return self.this.own()
    method = class_type.__swig_getmethods__.get(name, None)
    if method:
        return method(self)
    if (not static):
        return object.__getattr__(self, name)
    else:
        raise AttributeError(name)

def _swig_getattr(self, class_type, name):
    return _swig_getattr_nondynamic(self, class_type, name, 0)


def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)

try:
    _object = object
    _newclass = 1
except AttributeError:
    class _object:
        pass
    _newclass = 0



def getVersion():
    return _pyupm_hm11.getVersion()
getVersion = _pyupm_hm11.getVersion

_pyupm_hm11.HM11_DEFAULT_UART_swigconstant(_pyupm_hm11)
HM11_DEFAULT_UART = _pyupm_hm11.HM11_DEFAULT_UART
[docs]class HM11(_object): """ API for the HM-11 4.0 Bluetooth Low Energy Module. ID: hm11 Name: Bluetooth Low Energy Module Other Names: Grove BLE Other Chips: HM-10, HM-12 Category: wifi Manufacturer: seeed Connection: uart Link:http://wiki.seeed.cc/Bluetooth_V4.0_HM_11_BLE_Module/ The driver was tested with the Grove BLE module. It's an HM-11 BLE 4.0 module based on a TI CC2541 chip. It operates using a standard 'AT' command set. See the datasheet for a full list of available commands and their possible responses: http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf It is connected via a UART at 9,600 baud. C++ includes: hm11.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, HM11, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, HM11, name) __repr__ = _swig_repr def __init__(self, uart): """ HM11(int uart) HM11 object constructor Parameters: ----------- uart: Default UART to use (0 or 1) """ this = _pyupm_hm11.new_HM11(uart) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_hm11.delete_HM11 __del__ = lambda self: None
[docs] def dataAvailable(self, millis): """ bool dataAvailable(unsigned int millis) Checks to see if there is data available for reading Parameters: ----------- millis: Number of milliseconds to wait; 0 means no waiting True if there is data available for reading """ return _pyupm_hm11.HM11_dataAvailable(self, millis)
[docs] def readData(self, buffer, len): """ int readData(char *buffer, int len) Reads any available data into a user-supplied buffer. Note: the call blocks until data is available for reading. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking. Parameters: ----------- buffer: Buffer to hold the data read len: Length of the buffer Number of bytes read """ return _pyupm_hm11.HM11_readData(self, buffer, len)
[docs] def writeData(self, buffer, len): """ int writeData(char *buffer, int len) Writes the data in the buffer to the device Parameters: ----------- buffer: Buffer to hold the data read len: Length of the buffer Number of bytes written """ return _pyupm_hm11.HM11_writeData(self, buffer, len)
[docs] def setupTty(self, *args): """ bool setupTty(speed_t baud=B9600) Sets up proper tty I/O modes and the baud rate. For this device, the default baud rate is 9,600 (B9600). Parameters: ----------- baud: Desired baud rate. True if successful """ return _pyupm_hm11.HM11_setupTty(self, *args)
HM11_swigregister = _pyupm_hm11.HM11_swigregister HM11_swigregister(HM11)
[docs]class charArray(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, charArray, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, charArray, name) __repr__ = _swig_repr def __init__(self, nelements): this = _pyupm_hm11.new_charArray(nelements) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_hm11.delete_charArray __del__ = lambda self: None def __getitem__(self, index): return _pyupm_hm11.charArray___getitem__(self, index) def __setitem__(self, index, value): return _pyupm_hm11.charArray___setitem__(self, index, value)
[docs] def cast(self): return _pyupm_hm11.charArray_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_hm11.charArray_frompointer if _newclass: frompointer = staticmethod(_pyupm_hm11.charArray_frompointer)
charArray_swigregister = _pyupm_hm11.charArray_swigregister charArray_swigregister(charArray) def charArray_frompointer(t): return _pyupm_hm11.charArray_frompointer(t) charArray_frompointer = _pyupm_hm11.charArray_frompointer # This file is compatible with both classic and new-style classes. cvar = _pyupm_hm11.cvar