All Projects → bantucracy → ayanda

bantucracy / ayanda

Licence: other
Android Library to discover nearby devices Offline

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to ayanda

wx-ant-ble
微信、支付宝小程序BLE蓝牙SDK
Stars: ✭ 75 (+97.37%)
Mutual labels:  bluetooth
seeed-ambd-firmware
This RTL8720DN firmware export a RPC server interface through hardware SPI/UART port to MCU.
Stars: ✭ 20 (-47.37%)
Mutual labels:  bluetooth
stenogotchi
Portable stenography using Plover and bluetooth keyboard emulation on a Raspberry Pi Zero W
Stars: ✭ 71 (+86.84%)
Mutual labels:  bluetooth
MobilECG-II
Open source ECG holter
Stars: ✭ 375 (+886.84%)
Mutual labels:  bluetooth
bluetooth-manager
Java Bluetooth Manager. A library/framework for managing bluetooth adapters, bluetooth devices, GATT services and characteristics
Stars: ✭ 75 (+97.37%)
Mutual labels:  bluetooth
soma-ctrl
Node util for controlling SOMA smart shade via MQTT or HTTP
Stars: ✭ 19 (-50%)
Mutual labels:  bluetooth
pycom-ruuvitag
Pycom MicroPython RuuviTag BLE Sensor Beacon scanner
Stars: ✭ 18 (-52.63%)
Mutual labels:  bluetooth
android-ble-made-easy
An Android Library for handling Bluetooth Low Energy on Android Easy
Stars: ✭ 34 (-10.53%)
Mutual labels:  bluetooth
cuble.js
This project is now part of `cubing.js`: https://github.com/cubing/cubing.js/tree/master/src/bluetooth
Stars: ✭ 20 (-47.37%)
Mutual labels:  bluetooth
Bluetooth-Unlock
Simple script to unlock your Linux based Computer using a Bluetooth device when nearby
Stars: ✭ 37 (-2.63%)
Mutual labels:  bluetooth
nativeble
A fully-fledged cross-platform BLE library for desktop.
Stars: ✭ 15 (-60.53%)
Mutual labels:  bluetooth
8BitVita
Connect 8Bitdo controllers to the PSVita
Stars: ✭ 21 (-44.74%)
Mutual labels:  bluetooth
Servus
Ad-hoc peer-to-peer iOS library
Stars: ✭ 27 (-28.95%)
Mutual labels:  bluetooth
bluetooth
Android Bluetooth examples
Stars: ✭ 80 (+110.53%)
Mutual labels:  bluetooth
codec2 talkie
Turn your Android phone into Codec2 Walkie-Talkie (Bluetooth/USB/TCPIP KISS modem client for DV digital voice communication)
Stars: ✭ 65 (+71.05%)
Mutual labels:  bluetooth
bluetooth-gatt-parser
Bluetooth GATT service and characteristic parser
Stars: ✭ 61 (+60.53%)
Mutual labels:  bluetooth
CombineCoreBluetooth
A wrapper API for CoreBluetooth using Combine Publishers
Stars: ✭ 50 (+31.58%)
Mutual labels:  bluetooth
ble-utilities-unreal
This is Unreal Engine plugin that allows to scan for BLE devices with Cycling Power service running, connect to one of them and subscribe for its notifications.
Stars: ✭ 48 (+26.32%)
Mutual labels:  bluetooth
ble-heart-rate-demo
Web bluetooth heart rate monitor
Stars: ✭ 24 (-36.84%)
Mutual labels:  bluetooth
Walkie-Talkie
An Android app to enable infrastructure-less communication using WIFI-Direct.
Stars: ✭ 47 (+23.68%)
Mutual labels:  wifi-direct

Ayanda

Ayanda Ayanda is an Open Source Android Library that makes it easy to discover nearby devices and share files through a simple API. Ayanda is meant to detect nearby devices using WiFi and Bluetooth technology.

This library relies on interfaces to add custom functionality, the main Bluetooth, Wifi, and LAN functionality is enclosed within the Ayanda class.

Usage

The example app shows how to use Ayanda to discover devices on the local network, through Wifi Direct and through Bluetooth classic. Actions to be taken when nearby devices are discovered by each discovery method are defined by user defined interfaces.

/* Ex: Discovering Devices on Local Network
  *peers* is an ArrayList to store Lan peers discovered.

*/

// Define how to respond when nearby devices are discovered on network
private List peers = new ArrayList();
private List peerNames = new ArrayList();
private ArrayAdapter<String> peersAdapter = null;
ILan iLan = new ILan() {
    @Override
    public void deviceListChanged() {
        // Clear the list of discovered peers
        peers.clear();
        peerNames.clear();
        peersAdapter.clear();
        // update list with all peers within range
        peers.addAll(a.lanGetDeviceList());
        for (int i = 0; i < peers.size(); i++) {
            Lan.Device d = (Lan.Device) peers.get(i);
            peersAdapter.add(d.getName());
        }
    }
};

a = new Ayanda(this, null, iLan, null);
a.lanDiscover();
// INFO: lanDiscover() automatically makes an HTTP connection to services discovered

To share a file using NSD (LAN)

/* Share a file to nearby devices through LAN */

String filePath = "sdcard/somepic.jpg";
// NearbyMedia is a helper class to describe a file
NearbyMedia nearbyMedia = new NearbyMedia();
nearbyMedia.setMimeType("image/jpeg");
nearbyMedia.setTitle("pic");
nearbyMedia.setFileMedia(new File(filePath));

//get a JSON representation of any metadata we want to share
Gson gson = new GsonBuilder()
        .setDateFormat(DateFormat.FULL, DateFormat.FULL).create();
nearbyMedia.mMetadataJson = gson.toJson("key:value");

// Share the file to devices on LAN registered for current service
try {
    // Will store on nearby device's "Download" folder.
    a.lanShare(nearbyMedia);
} catch (IOException e) {
    e.printStackTrace();
}

Discovering nearby devices by WifiDirect

/* Discovering nearby devices by WifiDirect */
private List peers = new ArrayList();
private List peerNames = new ArrayList();
private ArrayAdapter<String> peersAdapter = null;

a = new Ayanda(this, null, null, new IWifiDirect() {
        @Override
        public void wifiP2pStateChangedAction(Intent intent) {

        }

        // Decide what to do when the list of nearby devices changes
        @Override
        public void wifiP2pPeersChangedAction() {
            peers.clear();
            peers.addAll(a.wdGetDevicesDiscovered() );
            peerNames.clear();
            for (int i = 0; i < peers.size(); i++) {
                WifiP2pDevice device = (WifiP2pDevice) peers.get(i);
                peersAdapter.add(device.deviceName);
            }
        }

        @Override
        public void wifiP2pConnectionChangedAction(Intent intent) {
        }

        @Override
        public void wifiP2pThisDeviceChangedAction(Intent intent) {
        }
    });
    
a.wdDiscover();

Sharing a file (bytes) using Bluetooth

private List peers = new ArrayList();
private List peerNames = new ArrayList();
private ArrayAdapter<String> peersAdapter = null;

  a = new Ayanda(this, new IBluetooth() {
            @Override
            public void actionDiscoveryStarted(Intent intent) {}

            @Override
            public void actionDiscoveryFinished(Intent intent) {}

            @Override
            public void stateChanged(Intent intent) {}

            @Override
            public void scanModeChange(Intent intent) {}

            @Override
            public void actionFound(Intent intent) {
                peersAdapter.clear();
                peersAdapter.addAll(a.btGetDeviceNamesDiscovered());
                devices = a.btGetDevices();
            }

            @Override
            public void dataRead(byte[] bytes, int length) {
                String readMessage = new String(bytes, 0, length);
                Toast.makeText(BluetoothActivity.this, readMessage, Toast.LENGTH_LONG)
                        .show();
            }

            // Send "Hello World" after connecting to a device
            @Override
            public void connected(BluetoothDevice device) {
                String message = "Hello World";
                try {
                    a.btSendData(device, message.getBytes()); // maybe a class for a device that's connected
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }, null, null);
        // Discover nearby Bluetooth devices paired or not
        a.btDiscover();
        // Connect to device from list
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
            BluetoothDevice device = devices.get(peerNames.get(pos));
            a.btConnect(device); // will trigger "connected" event
        }

See Example App in the app folder for more implementation details.

Contributing

See CONTRIBUTING.md.

License

Copyright [2017] [Sabelo Mhlambi]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].