-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathparams.json
6 lines (6 loc) · 7.72 KB
/
params.json
1
2
3
4
5
6
{
"name": "Bluetooth Simplified",
"tagline": "SimpleBluetoothLibrary is an Android library made to make using bluetooth painless and easy.",
"body": "SimpleBluetoothLibrary\r\n======================\r\n[](http://android-arsenal.com/details/1/1680)\r\n\r\n[](https://jitpack.io/#DeveloperPaul123/SimpleBluetoothLibrary)\r\n\r\n<h2>Description</h2>\r\n\r\nThis library makes it easy for you to implement bluetooth in your Android app. The SimpleBlueooth class handles all the hard work for you and all you have to do is make a few method calls. \r\n\r\n<h2>Dependency</h2>\r\n````java\r\nrepositories {\r\n ....\r\n maven {url \"https://jitpack.io\"}\r\n}\r\ndependencies {\r\n ....\r\n compile 'com.github.DeveloperPaul123:SimpleBluetoothLibrary:1.4.2'\r\n}\r\n ````\r\n\r\n<h2>Requirements</h2>\r\nMin SDK Level is 14 or Android IceCreamSandwich\r\n\r\n<h2>Usage</h2>\r\nThis library provides a ````BaseBluetoothActivity```` that you inherit from to easily take care of:\r\n- Enabling bluetooth\r\n- Scanning for new devices.\r\n- Connecting to a device.\r\n- Receiving data from the device.\r\n- Sending data to the device.\r\n\r\nAs an example:\r\n````java\r\npublic class TestActivity extends BaseBluetoothActivity {\r\n\r\n @Override\r\n protected void onCreate(Bundle savedInstanceState) {\r\n super.onCreate(savedInstanceState);\r\n //set your content view here. \r\n }\r\n\r\n @Override\r\n public void onBluetoothEnabled() {\r\n super.onBluetoothEnabled();\r\n //this is always called, when bluetooth is enabled.\r\n //by default the activity will start a scan. If you don't want this\r\n //delete the super call. \r\n }\r\n\r\n @Override\r\n public void onDeviceSelected(String macAddress) {\r\n super.onDeviceSelected(macAddress);\r\n //this is called when a device is selected from the scan activity. By default,\r\n //the selected device will be connected to. If you don't want this, delete the super call.\r\n }\r\n\r\n @Override\r\n public void onBluetoothDataReceived(byte[] bytes, String data) {\r\n //called when data is received from the device. \r\n }\r\n\r\n @Override\r\n public void onDeviceConnected(BluetoothDevice device) {\r\n\r\n }\r\n\r\n @Override\r\n public void onDeviceDisconnected(BluetoothDevice device) {\r\n\r\n }\r\n\r\n @Override\r\n public void onDiscoveryStarted() {\r\n\r\n }\r\n\r\n @Override\r\n public void onDiscoveryFinished() {\r\n\r\n }\r\n}\r\n````\r\n\r\nAlternatively you can use the ````SimpleBluetooth```` class yourself:\r\n\r\n````java\r\n\r\npublic class MainActivity extends Activity {\r\n\r\n private SimpleBluetooth simpleBluetooth;\r\n private static final int SCAN_REQUEST = 119;\r\n private static final int CHOOSE_SERVER_REQUEST = 120;\r\n //...other code....//\r\n private String curMacAddress;\r\n\r\n @Override\r\n protected void onResume() {\r\n super.onResume();\r\n simpleBluetooth = new SimpleBluetooth(this, new SimpleBluetoothListener() {\r\n\r\n @Override\r\n public void onBluetoothDataReceived(byte[] bytes, String data) {\r\n //read the data coming in.\r\n }\r\n\r\n @Override\r\n public void onDeviceConnected(BluetoothDevice device) {\r\n //a device is connected so you can now send stuff to it\r\n \r\n }\r\n\r\n @Override\r\n public void onDeviceDisconnected(BluetoothDevice device) {\r\n // device was disconnected so connect it again?\r\n \r\n }\r\n\r\n @Override\r\n public void onDiscoveryStarted() {\r\n\r\n }\r\n\r\n @Override\r\n public void onDiscoveryFinished() {\r\n\r\n }\r\n });\r\n simpleBluetooth.initializeSimpleBluetooth();\r\n }\r\n\r\n @Override\r\n protected void onCreate(Bundle savedInstanceState) {\r\n super.onCreate(savedInstanceState);\r\n setContentView(R.layout.activity_main);\r\n //...other code...//\r\n }\r\n\r\n\r\n @Override\r\n public boolean onCreateOptionsMenu(Menu menu) {\r\n // Inflate the menu; this adds items to the action bar if it is present.\r\n getMenuInflater().inflate(R.menu.main, menu);\r\n return true;\r\n }\r\n\r\n @Override\r\n public boolean onOptionsItemSelected(MenuItem item) {\r\n // Handle action bar item clicks here. The action bar will\r\n // automatically handle clicks on the Home/Up button, so long\r\n // as you specify a parent activity in AndroidManifest.xml.\r\n int id = item.getItemId();\r\n if (id == R.id.action_settings) {\r\n return true;\r\n } else if (id == R.id.scan) {\r\n simpleBluetooth.scan(SCAN_REQUEST);\r\n return true;\r\n }\r\n return super.onOptionsItemSelected(item);\r\n }\r\n\r\n @Override\r\n protected void onActivityResult(int requestCode, int resultCode, Intent data) {\r\n super.onActivityResult(requestCode, resultCode, data);\r\n if(requestCode == SCAN_REQUEST || requestCode == CHOOSE_SERVER_REQUEST) {\r\n\r\n if(resultCode == RESULT_OK) {\r\n\r\n curMacAddress = data.getStringExtra(DeviceDialog.DEVICE_DIALOG_DEVICE_ADDRESS_EXTRA);\r\n if(requestCode == SCAN_REQUEST) {\r\n simpleBluetooth.connectToBluetoothDevice(curMacAddress);\r\n } else {\r\n simpleBluetooth.connectToBluetoothServer(curMacAddress);\r\n }\r\n\r\n }\r\n }\r\n }\r\n\r\n @Override\r\n protected void onDestroy() {\r\n super.onDestroy();\r\n simpleBluetooth.endSimpleBluetooth();\r\n }\r\n}\r\n````\r\n\r\nFinally, the library allows for an alternative way to receive data. Say you're using an Arduino or something similar that is sending out a newline character at the end of every loop. You can read this data using a buffered input type through the following line:\r\n\r\n````java\r\nsimpleBluetooth.setInputStreamType(BluetoothUtility.InputStreamType.BUFFERED);\r\n````\r\n\r\nThis will case the input type to change and you should receieve the data line by line. \r\n\r\nAdditionally, this library allows for the creation and connection to a bluetooth server. Simply call:\r\n````java\r\nsimpleBluetooth.createBluetoothServerConnection();\r\n````\r\nand on the connecting device call:\r\n````java\r\n//curMacAddress is the address of the server device.\r\nsimpleBluetooth.connectToBluetoothServer(curMacAddress);\r\n````\r\nFinally, the library can handle A2DP protocols, although this has not yet been tested. \r\n\r\n<h2>Developed By</h2>\r\n**Paul T**\r\n\r\nCredit to **afollestad** for his material-dialog [library](https://github.com/afollestad/material-dialogs)\r\n\r\n<h2>License</h2>\r\n\r\nCopyright 2014 Paul T\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License.\r\n\r\nYou may obtain a copy of the License at\r\n\r\nhttp://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless 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.\r\n\r\n\r\n\r\n",
"note": "Don't delete this file! It's used internally to help with page regeneration."
}