Skip to content

Instantly share code, notes, and snippets.

Avatar

Rohan Mendon rohanmendon

View GitHub Profile
@rohanmendon
rohanmendon / lambda_process_data_stream.rb
Created Aug 28, 2019
Lambda to process the data stream from Kinesis in real time
View lambda_process_data_stream.rb
require 'json'
require 'base64'
require 'aws-sdk-s3'
def lambda_handler(event:, context:)
region = ''
bucket_name = ''
access_key = ''
secret_key = ''
View android_execute_command_paired_obd2.java
Pattern WHITESPACE_PATTERN = Pattern.compile("\\s");
private class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInStream;
private final OutputStream mmOutStream;
private byte[] mmBuffer; // mmBuffer store for the stream
public ConnectedThread(BluetoothSocket socket) {
mmSocket = socket;
@rohanmendon
rohanmendon / android_connect_paired_obd2.java
Created Aug 28, 2019
Connecting to the Paired OBD2 Device
View android_connect_paired_obd2.java
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
BluetoothSocket mmSocket;
UUID MY_UUID = UUID.fromString("2cf6e0ab-5417-4595-8564-487134f99ccd");
try {
// Get a BluetoothSocket to connect with the given BluetoothDevice.
// MY_UUID is the app's UUID string, also used in the server code.
@rohanmendon
rohanmendon / android_find_paired_obd2.java
Created Aug 28, 2019
Creating an instance of the paired OBDII device
View android_find_paired_obd2.java
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
private static String OBD2_DEVICE_NAME = "OBDII"; // Name of the Device shipped by the manufacturer
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Set<BluetoothDevice> bondedDevices = mBluetoothAdapter.getBondedDevices();
BluetoothDevice obd2Device;
for(BluetoothDevice bondedDevice: bondedDevices) {
if (bondedDevice.getName().contains(OBD2_DEVICE_NAME)) {
@rohanmendon
rohanmendon / android_post_kinesis_stream.java
Created Aug 28, 2019
Android code to post data to that Kinesis Stream
View android_post_kinesis_stream.java
import com.amazonaws.auth.CognitoCachingCredentialsProvider;
import com.amazonaws.mobileconnectors.kinesis.kinesisrecorder.KinesisRecorder;
File directory = getApplicationContext().getCacheDir();
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(getApplicationContext(), "Identity pool ID", Regions.US_WEST_2);
KinesisRecorder kinesisRecorder = new KinesisRecorder(directory, Regions.US_WEST_2, credentialsProvider);
String kinesisStreamName = "test2-kinesis-data-stream";
JSONObject json = new JSONObject();
try {
You can’t perform that action at this time.