Lines 56-80 should go in a function defined in the `Devices` object: 

```js
var Devices = {
  SFR02: {
    initialize: function() {
       ... `this` refers to the Sonar instance...

       do lines 56-80
    }
  }
}
```

Then it's called from within `Sonar`: 

```js
Devices[opts.device].initialize.call(this);
```