GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Gobot
  • Docs
  • Platforms
  • Resources
  • News
  • Blog
  • Github
  • Getting Started
  • Classic Gobot
  • Master Gobot
  • Metal Gobot
  • Adding Hardware Support
  • CLI
  • Snapcraft

This view

  • Original page
  • New address

GeezerVison is showing gobot.io — Gobot Example - ble_multiple_generic

Index

/*
 How to run
 Pass the Bluetooth address or name as the first param:

        go run examples/ble_multiple_generic.go BB-1234 BB-1235

 NOTE: sudo is required to use BLE in Linux
*/

package main

import (
        "fmt"
        "os"

        "gobot.io/x/gobot"
        "gobot.io/x/gobot/api"
        "gobot.io/x/gobot/platforms/ble"
)

func NewSwarmBot(port string) *gobot.Robot {
        bleAdaptor := ble.NewClientAdaptor(port)
        access := ble.NewGenericAccessDriver(bleAdaptor)

        work := func() {
                fmt.Println("Device name:", access.GetDeviceName())
                fmt.Println("Appearance:", access.GetAppearance())
        }

        robot := gobot.NewRobot("bot "+port,
                []gobot.Connection{bleAdaptor},
                []gobot.Device{access},
                work,
        )

        return robot
}

func main() {
        master := gobot.NewMaster()
        api.NewAPI(master).Start()

        for _, port := range os.Args[1:] {
                bot := NewSwarmBot(port)
                master.AddRobot(bot)
        }

        master.Start()
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.