UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

HM11 Class

Module: hm11

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.
hm11.jpg

Methods

HM11

(
  • uart
)
Number

HM11 object constructor

Parameters:

  • uart Number

    Default UART to use (0 or 1)

Returns:

Number:

dataAvailable

(
  • millis
)
Boolean

Checks to see if there is data available for reading

Parameters:

  • millis Number

    Number of milliseconds to wait; 0 means no waiting

Returns:

Boolean:

True if there is data available for reading

readData

(
  • buffer
  • len
)
Number

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 String

    Buffer to hold the data read

  • len Number

    Length of the buffer

Returns:

Number:

Number of bytes read

writeData

(
  • buffer
  • len
)
Number

Writes the data in the buffer to the device

Parameters:

  • buffer String

    Buffer to hold the data read

  • len Number

    Length of the buffer

Returns:

Number:

Number of bytes written

setupTty

(
  • baud
)
Boolean

Sets up proper tty I/O modes and the baud rate. For this device, the default baud rate is 9,600 (B9600).

Parameters:

  • baud Speed_t

    Desired baud rate.

Returns:

Boolean:

True if successful