Git Product home page Git Product logo

underdark-android's Introduction

Underdark Android

http://underdark.io

Peer-to-peer networking library for Android, with Wi-Fi and Bluetooth support.

This repository contains library sources, examples of using it and also short "Getting Started" guide below.

License

http://underdark.io/LICENSE.txt

Underdark Android is published under the Underdark License, which is modified Apache 2.0 license with added requirement that applications that use the library must add to their app store description the following line: "Mesh networking by http://underdark.io"

Demo apps

Please note that for Bluetooth connection to work on Android, one of the phones must have Android 5.x AND support Bluetooth LE Peripheral mode (have "yes" in the last column here: http://altbeacon.github.io/android-beacon-library/beacon-transmitter-devices.html).

Video demo: http://www.youtube.com/watch?v=ox4dh0s1XTw

Author

You can contact me via Telegram at http://telegram.me/virlof or by email at [email protected]

Installation

First, add underdark repository in your root or app's build.gradle:

repositories {
    maven {
        url 'https://dl.bintray.com/underdark/android/'
    }
}

Next, add Underdark library dependency in your apps' build.gradle:

dependencies {
    compile 'io.underdark:underdark:1.+'
}

Getting started

Underdark API is very simple — it consists of entry class Underdark with method configureTransport() — it allows you to create Transport instance with desired parameters (like network interface type) and set listener for callbacks.

Full documentation resides in javadoc jar, starting from io.underdark.Underdark class. If you're using Android Studio or IntelliJ IDEA, you can automatically download it like that:

apply plugin: 'idea'

idea {
    module {
        downloadJavadoc = true
    }
}

underdark-android's People

Contributors

virl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

underdark-android's Issues

transportNeedsActivity

When exactly gets this method invoked? It makes it difficult to put this in background service.

Status of developement (Android, IOS)

Hi Virl, can you tell us some news about the planned update for Android or IOS ?
I really like your api, but it doesn't work for new devices on Android.

Trying to disconnect

First i create conection
by create new Node
mNodeSound = Node(this, this, Node.NodeType.SOUND, SOUND_ID_PREFIX + id)
my logs

... D/Node: transportLinkConnected Link = alink(1) nodeId 7855185628251833254
--
....D/Node: transportLinkConnected Link = alink(1) nodeId 4618952656116501996
--

I try unconnect via this method

private val mLinks = ArrayList<Link>()`
fun unconnected() {
        for (link in mLinks) {
            link.disconnect()
        }
        dataTransfer = null
    }

disconnect() is method from Underdark:

public void disconnect() {
        this.transport.queue.dispatch(new Runnable() {
            public void run() {
                Iterator var1 = AggLink.this.links.iterator();

                while(var1.hasNext()) {
                    Link link = (Link)var1.next();
                    link.disconnect();
                }

            }
        });
    }

My logs:

....D/Node: transportLinkDisconnected  Link = alink(0) nodeId 7855185628251833254
--
....D/Node: transportLinkDisconnected  Link = alink(0) nodeId 4618952656116501996
--

Then i conect again by create new Node
mNodeSound = Node(this, this, Node.NodeType.SOUND, SOUND_ID_PREFIX + id)

It works
But create redundant links:
See my logs:

//Connected
...D/Node: transportLinkConnected Link = alink(1) nodeId 7376268880458696257
--
..... D/Node: transportLinkConnected Link = alink(0) nodeId 755959319961052674
--
//Disconnected
...D/Node: transportLinkDisconnected  Link = alink(0) nodeId 755959319961052674
--
...D/Node: transportLinkDisconnected  Link = alink(0) nodeId 7376268880458696257

Connected
.... D/Node: transportLinkConnected Link = alink(1) nodeId 3420549108642149074

.....D/Node: transportLinkConnected Link = alink(0) nodeId 5710137947420927346

//Disconnected
.... D/Node: transportLinkDisconnected  Link = alink(0) nodeId 5710137947420927346

.....D/Node: transportLinkDisconnected  Link = alink(0) nodeId 3420549108642149074

....D/Node: transportLinkConnected Link = alink(1) nodeId 7855185628251833254

How to fix it?

Unable to connect multiple devices

We have one plus 5T, google pixel 2 devices. Unable to find an option to connect these devices in solidarity app. Bluetooth is turned on both the devices

Documentation

How to access it,where to find it ?!!?.
I've tried the idea plugin approach in both my project and app gradle files to no avail

manifest merger error due to android:label specified in underdark manifest

Hi,

Thank you very much for your library.

I faced an issue with manifest merger. In our case we have very complicated build system with many manifests and flavours. Once I add dependency to underdark, build fails with message about duplication of android:label attribute of an application.

There is no requirement for android library to put any attribute for application tag. There is no need to add allowBackup and label in library.

Also when users add dependency to your lib, their apps automatically become backup supportive - which might be against their needs.

Is it possible to remove them? (I can create a pull request if you wish)

Enable logging

I'm having trouble seeing any logging.
What is supposed to happen when Underdark.configureLogging(true); is called?

Lots of packages missing?

Can you please tell me how to solve it. I have tried everything in the documentation, It still does not work.

UDApp example doesn’t work on same devices via Bluetooth.

HTC One M8 has used as Android 5.x with hardware BLE Peripheral mode support. With other 2 android devices and one iPhone cross mesh network works excellent using the play store app. But UDApp example doesn’t work on same devices via Bluetooth.

Transmission is not working between iOS and Android

At first, appreciate for your guys fantastic work. ^_^

Solidarity are installed in an iPhone 6S Plus, iPad Air, and another three Android devices. The three Android devices could see each other, send data, text without any issue, but none of them could see any iOS devices. The two iOS devices also could talk to each other, however none of android devices could be discovered by them.
Android devices go with Android 5 and 6; iOS devices go with iOS 10.

BTW, does underdark communicate with BLE and Wifi at same time? And what kind of wifi tech do you use? Wifi-direct? Or normal ad-hoc based wifi?

can work only with wifi?

we are working on a project which connects to devices using mesh network. but i tested udark on android devices and it only works with bluetooth . can i test it using only wifi?if yes then how?

routing algorithm

Does underdark implement routing algorithm? How many devices underdark mesh support to connect ?

time out issue each time while sending data via WIFI

       java.net.ConnectException: failed to connect to /192.168.5.111 (port 50000): connect failed: ETIMEDOUT (Connection timed out)
                                                         at libcore.io.IoBridge.connect(IoBridge.java:124)
                                                         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
                                                         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:163)
                                                         at java.net.Socket.startupSocket(Socket.java:590)
                                                         at java.net.Socket.tryAllAddresses(Socket.java:128)
                                                         at java.net.Socket.<init>(Socket.java:178)
                                                         at java.net.Socket.<init>(Socket.java:150)
                                                         at io.underdark.util.nslogger.NSLogger.connectImpl(SourceFile:163)
                                                         at io.underdark.util.nslogger.NSLogger.access$100(SourceFile:40)
                                                         at io.underdark.util.nslogger.NSLogger$2.run(SourceFile:152)
                                                         at android.os.Handler.handleCallback(Handler.java:739)
                                                         at android.os.Handler.dispatchMessage(Handler.java:95)
                                                         at android.os.Looper.loop(Looper.java:135)
                                                         at io.underdark.util.dispatch.DispatchQueue$2.run(SourceFile:82)
                                                         at java.lang.Thread.run(Thread.java:818)
                                                      Caused by: android.system.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)
                                                         at libcore.io.Posix.connect(Native Method)
                                                         at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:111)
                                                         at libcore.io.IoBridge.connectErrno(IoBridge.java:137)
                                                         at libcore.io.IoBridge.connect(IoBridge.java:122)
                                                         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183) 
                                                         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:163) 
                                                         at java.net.Socket.startupSocket(Socket.java:590) 
                                                         at java.net.Socket.tryAllAddresses(Socket.java:128) 
                                                         at java.net.Socket.<init>(Socket.java:178) 
                                                         at java.net.Socket.<init>(Socket.java:150) 
                                                         at io.underdark.util.nslogger.NSLogger.connectImpl(SourceFile:163) 
                                                         at io.underdark.util.nslogger.NSLogger.access$100(SourceFile:40) 
                                                         at io.underdark.util.nslogger.NSLogger$2.run(SourceFile:152) 
                                                         at android.os.Handler.handleCallback(Handler.java:739) 
                                                         at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                         at android.os.Looper.loop(Looper.java:135) 
                                                         at io.underdark.util.dispatch.DispatchQueue$2.run(SourceFile:82) 
                                                         at java.lang.Thread.run(Thread.java:818) 

Problem of file transfers

Hello, I am interested in the project named underdark-android . And I have some questions, eg"1. Could I achieve transmission of files by wifi ?On my phone , I can only transfer photo and message by bluetooth. 2.The app I used is downloaded from Goole Play. When I used APK built by the repo downloaded from "https://github.com/udark/underdark-android", I could not transfer anything. Would you mind giving the source code of the APP on Goole Play.

Crash relative to Bluetooth usage

Hi, I am testing the library, and i noticed that it crashes when initialize it for both WIFI and Bluetooth, with EnumSet.of(TransportKind.BLUETOOTH, TransportKind.WIFI). if i start the app with BT turned off, and i switch it on, the app crashes with the following stacktrace:

09-11 16:45:45.982 23118-23118/com.oimmei.cellvoice.guide E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            Process: com.oimmei.cellvoice.guide, PID: 23118
                                                                            java.lang.RuntimeException: Error receiving broadcast Intent { act=android.bluetooth.adapter.action.SCAN_MODE_CHANGED flg=0x4000010 (has extras) } in impl.underdark.transport.bluetooth.BtTransport$6@8c4d11
                                                                                at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_51267(LoadedApk.java:1305)
                                                                                at android.app.-$Lambda$FilBqgnXJrN9Mgyks1XHeAxzSTk.$m$0(Unknown Source:4)
                                                                                at android.app.-$Lambda$FilBqgnXJrN9Mgyks1XHeAxzSTk.run(Unknown Source:0)
                                                                                at android.os.Handler.handleCallback(Handler.java:789)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                                at android.os.Looper.loop(Looper.java:164)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
                                                                             Caused by: java.lang.NullPointerException: Attempt to get length of null array
                                                                                at com.google.protobuf.ByteString.copyFrom(ByteString.java:218)
                                                                                at impl.underdark.transport.bluetooth.switcher.BtSwitcherDumb.setMyAddress(BtSwitcherDumb.java:47)
                                                                                at impl.underdark.transport.bluetooth.BtTransport.onReceive_ACTION_SCAN_MODE_CHANGED(BtTransport.java:374)
                                                                                at impl.underdark.transport.bluetooth.BtTransport.onReceive(BtTransport.java:326)
                                                                                at impl.underdark.transport.bluetooth.BtTransport.access$200(BtTransport.java:49)
                                                                                at impl.underdark.transport.bluetooth.BtTransport$6.onReceive(BtTransport.java:247)
                                                                                at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_51267(LoadedApk.java:1295)
                                                                                at android.app.-$Lambda$FilBqgnXJrN9Mgyks1XHeAxzSTk.$m$0(Unknown Source:4) 
                                                                                at android.app.-$Lambda$FilBqgnXJrN9Mgyks1XHeAxzSTk.run(Unknown Source:0) 
                                                                                at android.os.Handler.handleCallback(Handler.java:789) 
                                                                                at android.os.Handler.dispatchMessage(Handler.java:98) 
                                                                                at android.os.Looper.loop(Looper.java:164) 
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6541)

Your help would be really appreciated, thank you

Crashing on simulator

Hi @virl, I'm using the library through the react-native bindings.
It's working great, but the problem is that I can no longer use my app in the simulator because it crashes immediately because there is not a Bluetooth adapter on it.
the exception reads like this:

Attempt to invoke virtual method 'java.lang.String android.bluetooth.BluetoothAdapter.getName()' on a null object reference

It would be great if you could fix this.

Thanks.

app is crashing on uploading image.

i just use your app for checking.

when i try to upload image it just crashed. i tried almost 5 times with the same image. it crashed 3 times.

Device Name : Galaxy Tab S2
Model no. : SM-T815Y
OS_VERSION: 6.0.1

Current Version

During including this to gradle, which version to add? as 1.+ is not working.
implementation 'io.underdark:underdark:1.+'

bluetooth address null on Android OREO

Hi,
On Android, Oreo Underdark library cannot get the bluetooth_address with the folllowing methods
String macAddress = android.provider.Settings.Secure.getString(context.getContentResolver(), "bluetooth_address");

Please give us a update.

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.