Skip to content

Commit

Permalink
fix(ci): fix lint error
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Froment <sfroment42@gmail.com>
  • Loading branch information
sfroment committed Nov 29, 2018
1 parent c6584a4 commit 46323fe
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void initScannerAndAdvertiser() {
curActivity.startActivityForResult(enableBtIntent, BLUETOOTH_ENABLE_REQUEST);
if (ContextCompat.checkSelfPermission(curActivity,
android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
/** intentionally empty */
} else {
ActivityCompat.requestPermissions(curActivity, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},
99);
Expand Down Expand Up @@ -244,16 +245,26 @@ public boolean write(byte[] p, String ma) {
return true;
}

@Override
protected void finalize() throws Throwable {
try {
mBluetoothGattServer.clearServices();
stopAdvertising();
stopScanning();
} finally {
super.finalize();
}
}
// @Override
// protected void finalize() throws Throwable {
// try {
// mBluetoothGattServer.clearServices();
// for (BertyDevice value : BertyUtils.bertyDevices.values()) {
// if (value.gatt != null) {
// value.gatt.disconnect();
// value.gatt.close();
// value.gatt = null;
// value
// .device = null;
// Log.e(TAG, "CLOSE");
// }
// }
// stopAdvertising();
// stopScanning();
// } finally {
// super.finalize();
// }
// }

public interface ActivityGetter {
@Nullable
Expand Down
2 changes: 0 additions & 2 deletions core/network/ble/conn.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build android darwin

package ble

import (
Expand Down
12 changes: 6 additions & 6 deletions core/network/ble/listener.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// +build android darwin

package ble

import (
"fmt"
"net"

// "runtime/debug"

peer "github.com/libp2p/go-libp2p-peer"
tpt "github.com/libp2p/go-libp2p-transport"
ma "github.com/multiformats/go-multiaddr"
Expand All @@ -24,7 +24,7 @@ type Listener struct {
lAddr ma.Multiaddr
}

var listeners map[string]*Listener = make(map[string]*Listener)
var listeners := make(map[string]*Listener)

func RealAcceptSender(peerID string, ble string, incPeerID string) {
for {
Expand Down Expand Up @@ -59,7 +59,8 @@ func (b *Listener) Accept() (tpt.Conn, error) {
case bleUUID, _ := <-b.incomingBLEUUID:
peerIDb58 := <-b.incomingPeerID
for {
if ci, ok := getConn(bleUUID); !ok {
ci, ok := getConn(bleUUID)
if !ok {
rAddr, err := ma.NewMultiaddr("/ble/" + bleUUID)
if err != nil {
return nil, err
Expand All @@ -70,9 +71,8 @@ func (b *Listener) Accept() (tpt.Conn, error) {
}
c := NewConn(b.transport, b.transport.MySelf.ID(), rID, b.lAddr, rAddr, 1)
return &c, nil
} else {
return ci, nil
}
return ci, nil
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions core/network/ble/os_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@ package ble

import (
"context"
"time"

host "github.com/libp2p/go-libp2p-host"
peer "github.com/libp2p/go-libp2p-peer"
tpt "github.com/libp2p/go-libp2p-transport"
rtpt "github.com/libp2p/go-reuseport-transport"
ma "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"
)

// BLETransport is the TCP transport.
type Transport struct {
MySelf host.Host
// Explicitly disable reuseport.
DisableReuseport bool
// ID
ID string
lAddr ma.Multiaddr
// TCP connect timeout
ConnectTimeout time.Duration
reuse rtpt.Transport
}

var ErrNotImplemented = errors.New("not implemented yet")
Expand Down Expand Up @@ -59,3 +71,7 @@ func (t *Transport) String() string {
func (b *Listener) closeNative() {

}

func (b *Conn) Write(p []byte) (n int, err error) {
return 0, errors.Wrap(ErrNotImplemented, "Write")
}

0 comments on commit 46323fe

Please sign in to comment.