# Class: PUPHub

## PUPHub

#### new PUPHub()

  The PUPHub is emitted if the discovered device is a Powered UP Hub.

  Source:
    - hubs/puphub.js, line 18

### Extends

- LPF2Hub
- Hub

### Members

#### <readonly> batteryLevel

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `batteryLevel` | number | Battery level of the hub (Percentage between 0-100)

  Inherited From:
    - BaseHub#batteryLevel
  Overrides:
    - Hub#batteryLevel
  Source:
    - hubs/basehub.js, line 138

#### <readonly> firmwareVersion

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `firmwareVersion` | string | Firmware version of the hub

  Inherited From:
    - BaseHub#firmwareVersion
  Overrides:
    - Hub#firmwareVersion
  Source:
    - hubs/basehub.js, line 110

#### <readonly> hardwareVersion

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `hardwareVersion` | string | Hardware version of the hub

  Inherited From:
    - BaseHub#hardwareVersion
  Overrides:
    - Hub#hardwareVersion
  Source:
    - hubs/basehub.js, line 117

#### <readonly> name

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `name` | string | Name of the hub

  Inherited From:
    - BaseHub#name
  Overrides:
    - Hub#name
  Source:
    - hubs/basehub.js, line 89

#### <readonly> ports

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `ports` | Array.<string> | Array of port names

  Inherited From:
    - BaseHub#ports
  Overrides:
    - Hub#ports
  Source:
    - hubs/basehub.js, line 103

#### <readonly> primaryMACAddress

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `primaryMACAddress` | string | Primary MAC address of the hub

  Inherited From:
    - BaseHub#primaryMACAddress
  Overrides:
    - Hub#primaryMACAddress
  Source:
    - hubs/basehub.js, line 124

#### <readonly> rssi

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `rssi` | number | Signal strength of the hub

  Inherited From:
    - BaseHub#rssi
  Overrides:
    - Hub#rssi
  Source:
    - hubs/basehub.js, line 145

#### <readonly> type

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `type` | string | Hub type

  Inherited From:
    - BaseHub#type
  Overrides:
    - Hub#type
  Source:
    - hubs/basehub.js, line 96

#### <readonly> uuid

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `uuid` | string | UUID of the hub

  Inherited From:
    - BaseHub#uuid
  Overrides:
    - Hub#uuid
  Source:
    - hubs/basehub.js, line 131

### Methods

#### connect()

  Connect to the Hub.

  Inherited From:
    - Hub#connect
  Overrides:
    - Hub#connect
  Source:
    - hubs/basehub.js, line 148

  ##### Returns:

  Resolved upon successful connect.

  Type
    Promise

#### createVirtualPort(firstPortName, secondPortName)

  Combines two ports with into a single virtual port.

  Note: The devices attached to the ports must be of the same device type.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `firstPortName` | string | First port name
  `secondPortName` | string | Second port name

  Inherited From:
    - LPF2Hub#createVirtualPort
  Overrides:
    - Hub#createVirtualPort
  Source:
    - hubs/lpf2hub.js, line 90

  ##### Returns:

  Resolved upon successful issuance of command.

  Type
    Promise

#### disconnect()

  Disconnect the Hub.

  Inherited From:
    - Hub#disconnect
  Source:
    - hubs/basehub.js, line 162

  ##### Returns:

  Resolved upon successful disconnect.

  Type
    Promise

#### getDeviceAtPort(portName)

  Retrieves the device attached to a given port.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `portName` | string | The name of the port to retrieve the device from.

  Inherited From:
    - Hub#getDeviceAtPort
  Source:
    - hubs/basehub.js, line 170

  ##### Returns:

  The device attached to the port.

  Type
    Device | undefined

#### getDevices()

  Retrieves all attached devices.

  Inherited From:
    - Hub#getDevices
  Source:
    - hubs/basehub.js, line 210

  ##### Returns:

  Array of all attached devices.

  Type
    Array.<Device>

#### getDevicesByType(deviceType)

  Retrieves an array of devices of the specified type.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `deviceType` | number | The device type to lookup.

  Inherited From:
    - Hub#getDevicesByType
  Source:
    - hubs/basehub.js, line 218

  ##### Returns:

  Array of all devices of the specified type.

  Type
    Array.<Device>

#### setName(name)

  Set the name of the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `name` | string | New name of the hub (14 characters or less, ASCII only).

  Inherited From:
    - LPF2Hub#setName
  Overrides:
    - Hub#setName
  Source:
    - hubs/lpf2hub.js, line 61

  ##### Returns:

  Resolved upon successful issuance of command.

  Type
    Promise

#### shutdown()

  Shutdown the Hub.

  Inherited From:
    - LPF2Hub#shutdown
  Overrides:
    - Hub#shutdown
  Source:
    - hubs/lpf2hub.js, line 53

  ##### Returns:

  Resolved upon successful disconnect.

  Type
    Promise

#### sleep(delay)

  Sleep a given amount of time.

  Note: This is a helper method to make it easier to add delays into a chain of commands.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `delay` | number | How long to sleep (in milliseconds).

  Inherited From:
    - Hub#sleep
  Source:
    - hubs/basehub.js, line 263

  ##### Returns:

  Resolved after the delay is finished.

  Type
    Promise

#### wait(commands)

  Wait until a given list of concurrently running commands are complete.

  Note: This is a helper method to make it easier to wait for concurrent commands to complete.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `commands` | Array.<Promise.<any>> | Array of executing commands.

  Inherited From:
    - Hub#wait
  Source:
    - hubs/basehub.js, line 276

  ##### Returns:

  Resolved after the commands are finished.

  Type
    Promise

#### waitForDeviceAtPort(portName)

  Retrieves the device attached to a given port, waiting until one is attached if there isn't one.

  Note: If a device is never attached, the returned promise may never resolve.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `portName` | string | The name of the port to retrieve the device from.

  Inherited From:
    - Hub#waitForDeviceAtPort
  Source:
    - hubs/basehub.js, line 185

  ##### Returns:

  Resolved once a device is attached, or resolved immediately if a device is already attached.

  Type
    Promise

#### waitForDeviceByType(deviceType)

  Retrieves the first device attached of the specified type, waiting until one is attached if there isn't one.

  Note: If a device is never attached, the returned promise may never resolve.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `deviceType` | number | The device type to lookup.

  Inherited From:
    - Hub#waitForDeviceByType
  Source:
    - hubs/basehub.js, line 227

  ##### Returns:

  Resolved once a device is attached, or resolved immediately if a device is already attached.

  Type
    Promise

### Events

#### attach

  Emits when a device is attached to the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Inherited From:
    - Hub#event:attach
  Source:
    - hubs/basehub.js, line 318

#### button

  Emits when a button is pressed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `button` | string |
  `state` | ButtonState |

  Inherited From:
    - LPF2Hub#event:button
  Overrides:
    - Hub#event:button
  Source:
    - hubs/lpf2hub.js, line 183

#### detach

  Emits when a device is detached from the Hub.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `device` | Device |

  Inherited From:
    - Hub#event:detach
  Source:
    - hubs/basehub.js, line 335

#### disconnect

  Emits when the hub is disconnected.

  Inherited From:
    - Hub#event:disconnect
  Source:
    - hubs/basehub.js, line 78

#### Search results