diff --git a/go.mod b/go.mod index 7d3b886e3..d44240dc7 100644 --- a/go.mod +++ b/go.mod @@ -17,18 +17,21 @@ require ( github.com/mattn/go-isatty v0.0.9 // indirect github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab // indirect + github.com/muka/go-bluetooth v0.0.0-20200928120822-44d49b402aee // indirect github.com/nats-io/nats-server/v2 v2.1.0 // indirect github.com/nats-io/nats.go v1.8.1 - github.com/pkg/errors v0.8.1 + github.com/pkg/errors v0.9.1 github.com/raff/goble v0.0.0-20190909174656-72afc67d6a99 // indirect github.com/sigurn/crc8 v0.0.0-20160107002456-e55481d6f45c github.com/sigurn/utils v0.0.0-20190728110027-e1fefb11a144 // indirect - github.com/stretchr/testify v1.4.0 + github.com/sirupsen/logrus v1.7.0 // indirect + github.com/stretchr/testify v1.6.1 github.com/urfave/cli v1.22.1 github.com/veandco/go-sdl2 v0.3.3 go.bug.st/serial v1.0.0 gocv.io/x/gocv v0.21.0 - golang.org/x/crypto v0.0.0-20191001170739-f9e2070545dc // indirect - golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3 + golang.org/x/net v0.0.0-20200822124328-c89045814202 + golang.org/x/sys v0.0.0-20201024132449-ef9fd89ba245 // indirect periph.io/x/periph v3.6.2+incompatible + tinygo.org/x/bluetooth v0.1.1-0.20201022170447-266de9824a65 ) diff --git a/go.sum b/go.sum index 2e0733a90..5080c1bbe 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/JuulLabs-OSS/cbgo v0.0.2 h1:gCDyT0+EPuI8GOFyvAksFcVD2vF4CXBAVwT6uVnD9oo= +github.com/JuulLabs-OSS/cbgo v0.0.2/go.mod h1:L4YtGP+gnyD84w7+jN66ncspFRfOYB5aj9QSXaFHmBA= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40 h1:y4B3+GPxKlrigF1ha5FFErxK+sr6sWxQovRMzwMhejo= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= @@ -9,18 +11,26 @@ github.com/creack/goselect v0.1.1 h1:tiSSgKE1eJtxs1h/VgGQWuXUP0YS4CDIFMp6vaI1ls0 github.com/creack/goselect v0.1.1/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/donovanhide/eventsource v0.0.0-20171031113327-3ed64d21fb0b h1:eR1P/A4QMYF2/LpHRhYAts9wyYEtF7qNk/tVNiYCWc8= github.com/donovanhide/eventsource v0.0.0-20171031113327-3ed64d21fb0b/go.mod h1:56wL82FO0bfMU5RvfXoIwSOP2ggqqxT+tAfNEIyxuHw= github.com/eclipse/paho.mqtt.golang v1.2.0 h1:1F8mhG9+aO5/xpdtFkW4SxOJB67ukuDC3t2y2qayIX0= github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= +github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= +github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/go-ble/ble v0.0.0-20190521171521-147700f13610 h1:eWay3GzFqTJUEYN1BrbqdDTFeFUGmYLps8SQkn1D7Yo= github.com/go-ble/ble v0.0.0-20190521171521-147700f13610/go.mod h1:UMPB54/KFpdTdfH7Yovhk3J6kzgzE88e3QZi8cbayis= +github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= +github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/gobuffalo/uuid v2.0.5+incompatible h1:c5uWRuEnYggYCrT9AJm0U2v1QTG7OVDAvxhj8tIV5Gc= github.com/gobuffalo/uuid v2.0.5+incompatible/go.mod h1:ErhIzkRhm0FtRuiE/PeORqcw4cVi1RtSpnwYrxuvkfE= +github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME= +github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= @@ -29,6 +39,13 @@ github.com/hybridgroup/go-ardrone v0.0.0-20140402002621-b9750d8d7b78 h1:7of6LJZ4 github.com/hybridgroup/go-ardrone v0.0.0-20140402002621-b9750d8d7b78/go.mod h1:YllNbhGM1UEcySxCv1BWK5lre7QLmJJ+O0ADUOo2nbc= github.com/hybridgroup/mjpeg v0.0.0-20140228234708-4680f319790e h1:xCcwD5FOXul+j1dn8xD16nbrhJkkum/Cn+jTd/u1LhY= github.com/hybridgroup/mjpeg v0.0.0-20140228234708-4680f319790e/go.mod h1:eagM805MRKrioHYuU7iKLUyFPVKqVV6um5DAvCkUtXs= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= @@ -38,6 +55,12 @@ github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1f github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab h1:n8cgpHzJ5+EDyDri2s/GC7a9+qK3/YEGnBsd0uS/8PY= github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab/go.mod h1:y1pL58r5z2VvAjeG1VLGc8zOQgSOzbKN7kMHPvFXJ+8= +github.com/muka/go-bluetooth v0.0.0-20200619025933-f6113f7141c5 h1:xnTS/7y0g28W2SJeWNLMYTiTOmfW2P/YdPByoQnPvVo= +github.com/muka/go-bluetooth v0.0.0-20200619025933-f6113f7141c5/go.mod h1:yV39+EVOWdnoTe75NyKdo9iuyI3Slyh4t7eQvElUbWE= +github.com/muka/go-bluetooth v0.0.0-20200926181701-4ca7d8dd0ff5 h1:2n6xusPU4MxghLXhYNpGSYYov4AjnARQfA2xIPfqelA= +github.com/muka/go-bluetooth v0.0.0-20200926181701-4ca7d8dd0ff5/go.mod h1:dMCjicU6vRBk34dqOmIZm0aod6gUwZXOXzBROqGous0= +github.com/muka/go-bluetooth v0.0.0-20200928120822-44d49b402aee h1:viY7YR4j7hyLKFK9peIU+FysyOJ47ezp4oBwhiEW9Hk= +github.com/muka/go-bluetooth v0.0.0-20200928120822-44d49b402aee/go.mod h1:dMCjicU6vRBk34dqOmIZm0aod6gUwZXOXzBROqGous0= github.com/nats-io/jwt v0.3.0 h1:xdnzwFETV++jNc4W1mw//qFyJGb2ABOombmZJQS4+Qo= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/nats-server/v2 v2.1.0 h1:Yi0+ZhRPtPAGeIxFn5erIeJIV9wXA+JznfSxK621Fbk= @@ -50,8 +73,12 @@ github.com/nats-io/nkeys v0.1.0 h1:qMd4+pRHgdr1nAClu+2h/2a5F2TmKcCzjCDazVgRoX4= github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/paypal/gatt v0.0.0-20151011220935-4ae819d591cf/go.mod h1:+AwQL2mK3Pd3S+TUwg0tYQjid0q1txyNUJuuSmz8Kdk= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/raff/goble v0.0.0-20190909174656-72afc67d6a99 h1:JtoVdxWJ3tgyqtnPq3r4hJ9aULcIDDnPXBWxZsdmqWU= @@ -64,13 +91,23 @@ github.com/sigurn/crc8 v0.0.0-20160107002456-e55481d6f45c h1:hk0Jigjfq59yDMgd6bz github.com/sigurn/crc8 v0.0.0-20160107002456-e55481d6f45c/go.mod h1:cyrWuItcOVIGX6fBZ/G00z4ykprWM7hH58fSavNkjRg= github.com/sigurn/utils v0.0.0-20190728110027-e1fefb11a144 h1:ccb8W1+mYuZvlpn/mJUMAbsFHTMCpcJBS78AsBQxNcY= github.com/sigurn/utils v0.0.0-20190728110027-e1fefb11a144/go.mod h1:VRI4lXkrUH5Cygl6mbG1BRUfMMoT2o8BkrtBDUAm+GU= +github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= +github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/suapapa/go_eddystone v1.3.1/go.mod h1:bXC11TfJOS+3g3q/Uzd7FKd5g62STQEfeEIhcKe4Qy8= github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/veandco/go-sdl2 v0.3.3 h1:4/TirgB2MQ7oww3pM3Yfgf1YbChMlAQAmiCPe5koK0I= github.com/veandco/go-sdl2 v0.3.3/go.mod h1:FB+kTpX9YTE+urhYiClnRzpOXbiWgaU3+5F2AB78DPg= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.bug.st/serial v1.0.0 h1:ogEPzrllCsnG00EqKRjeYvPRsO7NJW6DqykzkdD6E/k= go.bug.st/serial v1.0.0/go.mod h1:rpXPISGjuNjPTRTcMlxi9lN6LoIPxd1ixVjBd8aSk/Q= gocv.io/x/gocv v0.21.0 h1:dVjagrupZrfCRY0qPEaYWgoNMRpBel6GYDH4mvQOK8Y= @@ -82,22 +119,53 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49N golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191001170739-f9e2070545dc h1:KyTYo8xkh/2WdbFLUyQwBS0Jfn3qfZ9QmuPbok2oENE= golang.org/x/crypto v0.0.0-20191001170739-f9e2070545dc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3 h1:6KET3Sqa7fkVfD63QnAM81ZeYg5n4HwApOJkufONnHA= golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 h1:ZBzSG/7F4eNKz2L3GE9o300RX0Az1Bw5HF7PDraD+qU= golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6 h1:DvY3Zkh7KabQE/kfzMvYvKirSiguP9Q/veMtkYyf0o8= +golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201024132449-ef9fd89ba245 h1:GGQcbpn3KsnwsPvzzr1mDsTriyvGNKi9eo2lG3N8YdM= +golang.org/x/sys v0.0.0-20201024132449-ef9fd89ba245/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200925191224-5d1fdd8fa346/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= periph.io/x/periph v3.6.2+incompatible h1:B9vqhYVuhKtr6bXua8N9GeBEvD7yanczCvE0wU2LEqw= periph.io/x/periph v3.6.2+incompatible/go.mod h1:EWr+FCIU2dBWz5/wSWeiIUJTriYv9v2j2ENBmgYyy7Y= +tinygo.org/x/bluetooth v0.1.0 h1:AtnJ/9BwunJTqI5ybv5L7sSwGsTSjxnEBrk7E47NNis= +tinygo.org/x/bluetooth v0.1.0/go.mod h1:677CMNsRMwSVGKUdr2oY3ILFWQEzzl7Hb3o+mnJ+dXo= +tinygo.org/x/bluetooth v0.1.1-0.20201022170447-266de9824a65 h1:Kxt57uJylzE4VVldfiKnleUMQM4HOcDzNkvPiDPDYqU= +tinygo.org/x/bluetooth v0.1.1-0.20201022170447-266de9824a65/go.mod h1:Rx8KLr5nmrJ4uUf4Fy14JIoV3pF9vvbQ0KCv/c+ELOo= +tinygo.org/x/drivers v0.13.0/go.mod h1:mShi1lpVtJFpApkZgwyrzDKHToeGfWIuB08utyHxZ7g= diff --git a/platforms/ble/battery_driver.go b/platforms/ble/battery_driver.go index 9abfb1722..c9240142d 100644 --- a/platforms/ble/battery_driver.go +++ b/platforms/ble/battery_driver.go @@ -2,6 +2,7 @@ package ble import ( "bytes" + "log" "gobot.io/x/gobot" ) @@ -49,7 +50,11 @@ func (b *BatteryDriver) Halt() (err error) { return } // GetBatteryLevel reads and returns the current battery level func (b *BatteryDriver) GetBatteryLevel() (level uint8) { var l uint8 - c, _ := b.adaptor().ReadCharacteristic("2a19") + c, err := b.adaptor().ReadCharacteristic("2a19") + if err != nil { + log.Println(err) + return + } buf := bytes.NewBuffer(c) val, _ := buf.ReadByte() l = uint8(val) diff --git a/platforms/ble/ble_client_adaptor.go b/platforms/ble/ble_client_adaptor.go index 34610fa9c..505c1c685 100644 --- a/platforms/ble/ble_client_adaptor.go +++ b/platforms/ble/ble_client_adaptor.go @@ -1,20 +1,20 @@ package ble import ( - "context" + "fmt" "log" - "strings" + "strconv" "sync" + "github.com/pkg/errors" "gobot.io/x/gobot" - blelib "github.com/go-ble/ble" - "github.com/pkg/errors" + "tinygo.org/x/bluetooth" ) -var currentDevice *blelib.Device +//var currentDevice *blelib.Device +var currentAdapter *bluetooth.Adapter var bleMutex sync.Mutex -var bleCtx context.Context // BLEConnector is the interface that a BLE ClientAdaptor must implement type BLEConnector interface { @@ -33,28 +33,29 @@ type BLEConnector interface { // ClientAdaptor represents a Client Connection to a BLE Peripheral type ClientAdaptor struct { - name string - address string - DeviceName string + name string + address string + AdapterName string - addr blelib.Addr - device *blelib.Device - client blelib.Client - profile *blelib.Profile + addr bluetooth.Address + adpt *bluetooth.Adapter + device *bluetooth.Device + characteristics map[string]bluetooth.DeviceCharacteristic connected bool ready chan struct{} withoutResponses bool } -// NewClientAdaptor returns a new ClientAdaptor given an address or peripheral name +// NewClientAdaptor returns a new ClientAdaptor given an address func NewClientAdaptor(address string) *ClientAdaptor { return &ClientAdaptor{ name: gobot.DefaultName("BLEClient"), address: address, - DeviceName: "default", + AdapterName: "default", connected: false, withoutResponses: false, + characteristics: make(map[string]bluetooth.DeviceCharacteristic), } } @@ -76,29 +77,52 @@ func (b *ClientAdaptor) Connect() (err error) { bleMutex.Lock() defer bleMutex.Unlock() - b.device, err = getBLEDevice(b.DeviceName) + // enable adaptor + b.adpt, err = getBLEAdapter(b.AdapterName) if err != nil { - return errors.Wrap(err, "can't connect to device "+b.DeviceName) + return errors.Wrap(err, "can't enable adapter "+b.AdapterName) } - var cln blelib.Client + // handle address + b.addr.Set(b.Address()) + + // scan for the address + ch := make(chan bluetooth.ScanResult, 1) + err = b.adpt.Scan(func(adapter *bluetooth.Adapter, result bluetooth.ScanResult) { + if result.Address.String() == b.Address() { + b.adpt.StopScan() + ch <- result + } + }) - cln, err = blelib.Connect(context.Background(), filter(b.Address())) if err != nil { - return errors.Wrap(err, "can't connect to peripheral "+b.Address()) + return err + } + + // wait to connect to peripheral device + select { + case result := <-ch: + b.device, err = b.adpt.Connect(result.Address, bluetooth.ConnectionParams{}) + if err != nil { + return err + } } - b.addr = cln.Addr() - b.address = cln.Addr().String() - b.SetName(cln.Name()) - b.client = cln + // b.SetName(cln.Name()) - p, err := b.client.DiscoverProfile(true) - if err != nil { - return errors.Wrap(err, "can't discover profile") + // get all services/characteristics + srvcs, err := b.device.DiscoverServices(nil) + for _, srvc := range srvcs { + chars, err := srvc.DiscoverCharacteristics(nil) + if err != nil { + log.Println(err) + continue + } + for _, char := range chars { + b.characteristics[char.UUID().String()] = char + } } - b.profile = p b.connected = true return } @@ -115,8 +139,7 @@ func (b *ClientAdaptor) Reconnect() (err error) { // Disconnect terminates the connection to the BLE peripheral. Returns true on successful disconnect. func (b *ClientAdaptor) Disconnect() (err error) { - b.client.CancelConnection() - return + return b.device.Disconnect() } // Finalize finalizes the BLEAdaptor @@ -132,13 +155,27 @@ func (b *ClientAdaptor) ReadCharacteristic(cUUID string) (data []byte, err error return } - uuid, _ := blelib.Parse(cUUID) + if len(cUUID) == 4 { + // convert to full uuid + uid, e := strconv.ParseUint("0x"+cUUID, 0, 16) + if e != nil { + return nil, e + } - if u := b.profile.Find(blelib.NewCharacteristic(uuid)); u != nil { - data, err = b.client.ReadCharacteristic(u.(*blelib.Characteristic)) + uuid := bluetooth.New16BitUUID(uint16(uid)) + cUUID = uuid.String() } - return + if char, ok := b.characteristics[cUUID]; ok { + buf := make([]byte, 255) + n, err := char.Read(buf) + if err != nil { + return nil, err + } + return buf[:n], nil + } + + return nil, fmt.Errorf("Unknown characteristic: %s", cUUID) } // WriteCharacteristic writes bytes to the BLE device for the @@ -149,13 +186,15 @@ func (b *ClientAdaptor) WriteCharacteristic(cUUID string, data []byte) (err erro return } - uuid, _ := blelib.Parse(cUUID) - - if u := b.profile.Find(blelib.NewCharacteristic(uuid)); u != nil { - err = b.client.WriteCharacteristic(u.(*blelib.Characteristic), data, b.withoutResponses) + if char, ok := b.characteristics[cUUID]; ok { + _, err := char.WriteWithoutResponse(data) + if err != nil { + return err + } + return nil } - return + return fmt.Errorf("Unknown characteristic: %s", cUUID) } // Subscribe subscribes to notifications from the BLE device for the @@ -166,40 +205,28 @@ func (b *ClientAdaptor) Subscribe(cUUID string, f func([]byte, error)) (err erro return } - uuid, _ := blelib.Parse(cUUID) - - if u := b.profile.Find(blelib.NewCharacteristic(uuid)); u != nil { - h := func(req []byte) { f(req, nil) } - err = b.client.Subscribe(u.(*blelib.Characteristic), false, h) - if err != nil { - return err + if char, ok := b.characteristics[cUUID]; ok { + fn := func(d []byte) { + f(d, nil) } - return nil + err = char.EnableNotifications(fn) + return } - return + return fmt.Errorf("Unknown characteristic: %s", cUUID) } -// getBLEDevice is singleton for blelib HCI device connection -func getBLEDevice(impl string) (d *blelib.Device, err error) { - if currentDevice != nil { - return currentDevice, nil +// getBLEDevice is singleton for bluetooth adapter connection +func getBLEAdapter(impl string) (*bluetooth.Adapter, error) { + if currentAdapter != nil { + return currentAdapter, nil } - dev, e := defaultDevice(impl) - if e != nil { - return nil, errors.Wrap(e, "can't get device") + currentAdapter = bluetooth.DefaultAdapter + err := currentAdapter.Enable() + if err != nil { + return nil, errors.Wrap(err, "can't get device") } - blelib.SetDefaultDevice(dev) - currentDevice = &dev - d = &dev - return -} - -func filter(name string) blelib.AdvFilter { - return func(a blelib.Advertisement) bool { - return strings.ToLower(a.LocalName()) == strings.ToLower(name) || - a.Addr().String() == strings.ToLower(name) - } + return currentAdapter, nil } diff --git a/platforms/ble/ble_client_adaptor_darwin.go b/platforms/ble/ble_client_adaptor_darwin.go deleted file mode 100644 index 0071dbdf0..000000000 --- a/platforms/ble/ble_client_adaptor_darwin.go +++ /dev/null @@ -1,10 +0,0 @@ -package ble - -import ( - blelib "github.com/go-ble/ble" - "github.com/go-ble/ble/darwin" -) - -func defaultDevice(impl string) (d blelib.Device, err error) { - return darwin.NewDevice() -} diff --git a/platforms/ble/ble_client_adaptor_linux.go b/platforms/ble/ble_client_adaptor_linux.go deleted file mode 100644 index 413cbf1c4..000000000 --- a/platforms/ble/ble_client_adaptor_linux.go +++ /dev/null @@ -1,10 +0,0 @@ -package ble - -import ( - blelib "github.com/go-ble/ble" - "github.com/go-ble/ble/linux" -) - -func defaultDevice(impl string) (d blelib.Device, err error) { - return linux.NewDevice() -} diff --git a/platforms/ble/ble_client_adaptor_windows.go b/platforms/ble/ble_client_adaptor_windows.go deleted file mode 100644 index ab066d29b..000000000 --- a/platforms/ble/ble_client_adaptor_windows.go +++ /dev/null @@ -1,11 +0,0 @@ -package ble - -import ( - "errors" - - blelib "github.com/go-ble/ble" -) - -func defaultDevice(impl string) (d blelib.Device, err error) { - return nil, errors.New("Not yet implemented for this OS.") -} diff --git a/platforms/ble/device_information_driver.go b/platforms/ble/device_information_driver.go index 1888bce96..c836c43e6 100644 --- a/platforms/ble/device_information_driver.go +++ b/platforms/ble/device_information_driver.go @@ -2,6 +2,7 @@ package ble import ( "bytes" + "log" "gobot.io/x/gobot" ) @@ -48,15 +49,23 @@ func (b *DeviceInformationDriver) Halt() (err error) { return } // GetModelNumber returns the model number for the BLE Peripheral func (b *DeviceInformationDriver) GetModelNumber() (model string) { - c, _ := b.adaptor().ReadCharacteristic("2a24") + c, err := b.adaptor().ReadCharacteristic("2a24") + if err != nil { + log.Println(err) + return + } buf := bytes.NewBuffer(c) - val := buf.String() - return val + model = buf.String() + return } // GetFirmwareRevision returns the firmware revision for the BLE Peripheral func (b *DeviceInformationDriver) GetFirmwareRevision() (revision string) { - c, _ := b.adaptor().ReadCharacteristic("2a26") + c, err := b.adaptor().ReadCharacteristic("2a26") + if err != nil { + log.Println(err) + return + } buf := bytes.NewBuffer(c) val := buf.String() return val @@ -64,7 +73,11 @@ func (b *DeviceInformationDriver) GetFirmwareRevision() (revision string) { // GetHardwareRevision returns the hardware revision for the BLE Peripheral func (b *DeviceInformationDriver) GetHardwareRevision() (revision string) { - c, _ := b.adaptor().ReadCharacteristic("2a27") + c, err := b.adaptor().ReadCharacteristic("2a27") + if err != nil { + log.Println(err) + return + } buf := bytes.NewBuffer(c) val := buf.String() return val @@ -72,7 +85,11 @@ func (b *DeviceInformationDriver) GetHardwareRevision() (revision string) { // GetManufacturerName returns the manufacturer name for the BLE Peripheral func (b *DeviceInformationDriver) GetManufacturerName() (manufacturer string) { - c, _ := b.adaptor().ReadCharacteristic("2a29") + c, err := b.adaptor().ReadCharacteristic("2a29") + if err != nil { + log.Println(err) + return + } buf := bytes.NewBuffer(c) val := buf.String() return val @@ -80,7 +97,11 @@ func (b *DeviceInformationDriver) GetManufacturerName() (manufacturer string) { // GetPnPId returns the PnP ID for the BLE Peripheral func (b *DeviceInformationDriver) GetPnPId() (model string) { - c, _ := b.adaptor().ReadCharacteristic("2a50") + c, err := b.adaptor().ReadCharacteristic("2a50") + if err != nil { + log.Println(err) + return + } buf := bytes.NewBuffer(c) val := buf.String() return val diff --git a/platforms/ble/generic_access_driver.go b/platforms/ble/generic_access_driver.go index 807f6a207..0a12fb8ce 100644 --- a/platforms/ble/generic_access_driver.go +++ b/platforms/ble/generic_access_driver.go @@ -3,6 +3,7 @@ package ble import ( "bytes" "encoding/binary" + "log" "gobot.io/x/gobot" ) @@ -49,7 +50,12 @@ func (b *GenericAccessDriver) Halt() (err error) { return } // GetDeviceName returns the device name for the BLE Peripheral func (b *GenericAccessDriver) GetDeviceName() string { - c, _ := b.adaptor().ReadCharacteristic("2a00") + c, err := b.adaptor().ReadCharacteristic("2a00") + if err != nil { + log.Println(err) + return "" + } + buf := bytes.NewBuffer(c) val := buf.String() return val @@ -57,7 +63,12 @@ func (b *GenericAccessDriver) GetDeviceName() string { // GetAppearance returns the appearance string for the BLE Peripheral func (b *GenericAccessDriver) GetAppearance() string { - c, _ := b.adaptor().ReadCharacteristic("2a01") + c, err := b.adaptor().ReadCharacteristic("2a01") + if err != nil { + log.Println(err) + return "" + } + buf := bytes.NewBuffer(c) var val uint16