AlertWear-T19 Developer's Portal

Introduction

 

For development of applications, please use the resources that can guide and facilitate depending on your requirements:

1. You can use the Communication Protocols listed in the document of Sxtreo T19 (AlertWear) to the user so that the developers can develop their own application, or can integrate with your application.

2. Users can use the SDK in their Mobile App to consume all the methods as and when required. when the data consumption will be done the user can transfer those collected data to our server using the Web APIs provided by us.

3. In the case of BLE Gateway, users can assess the collected data from the server using the web API provided by us to the Mobile App being developed.

The detail of those above-mentioned points are briefed clearly in the next tabs.

  • .gradle
  • .idea
  • app
  • gradle
  • LibrryT19
  • .gitattributes
  • .gitignore
  • build.gradle
  • gradle.properties
  • gradlew
  • gradlew.bat
  • local.properties
  • settings.gradle
  • .gradle
  • .idea
  • app
  • gradle
  • LibrryT19
  • .gitattributes
  • .gitignore
  • build.gradle
  • gradle.properties
  • gradlew
  • gradlew.bat
  • local.properties
  • settings.gradle
Release Note: Add Diagnosis API
1. LED Test
2. Buzzer Test
Sxtreo T19 Firmware Protocol Document (Version BLE 1.2)
Sxtreo T19 Firmware Protocol Document (Version BLE 1.3)

Installation

 

BBX T19 Android SDK enables Developers to Communicate with BBX T19 Devices. SDK will provide Temperature and Contact tracing data from BBX T19 Device. Application set data fetching time interval and date time by SDK. The full project’s source code can be downloaded from https://github.com/Alertware-Blackbox/T19Device

Before started the entire operation, you have to connect BBX T19 Device by Bluetooth Pairing with your Android Device and place the Bluetooth Address of BBX T19 Device as a parameter for connection. For establish Bluetooth connection you may follow this piece of code.

1. Give the following permissions in Manifiest file.

2. Write this piece of code to your application class.

3. If Bluetooth is supported but disabled, then the isEnabled() method will return false and we can request the user to enable Bluetooth without leaving our application by using startActivityForResult() method with ACTION_REQUEST_ENABLE intent action parameter.

4. Android Enable Discoverability

To make the device discoverable to other devices, we need to start the new activity by calling startActivityForResult(intent, int) with the ACTION_REQUEST_DISCOVERABLE intent.

5. Android List Paired Devices

By using the BluetoothAdapter method getBondedDevices(), we can get the Bluetooth paired devices list.

Compability Versions

 

This SDK is compatible for Android 6.0 (Marshmello) upto Android 10.

Project Dependency

 

To add this Device, 'com.github.avishekmca:T19Device:1.1' is necessary to add on your project. Unless it will not work.

System Requirements

 

Support for Bluetooth 4.0 on the device.

CPU architecture is on of the following: arm, arm64, x86, x86_64, mips, mips64.

Implementation Steps

 

Step 1: Add Dependency

Add this in root build.gradle at the end of repositories:

allprojects {

    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
    
}

Add it to your project:

implementation 'com.github.avishekmca:T19Device:1.1'

Step 2: Register Services

Add Services to manifiest file.

Step 3: Permissions

For BBX T19 library to work in your application, you should add the following permissions to your AndroidManifest.xml:

SDK Methods

 

Step 1: Connect to T19

implements Activity with implements BleWrapperUiCallbacks

Step 2: Initialize variables

Conn conn;

Bluetooth Bluetooth;

private final String LIST_NAME = "NAME";

private final String LIST_UUID = "UUID";

Attributes attributes=new Attributes();

bluetooth = Bluetooth.getInstance(this, this);

conn=new Conn(this,String dvc_id,bluetooth,attributes);

Step 3: Register and Unregister Receiver

For BBX T19 library to work in your application, you should add the following permissions to your AndroidManifest.xml:

Step 4: Service Binding

Intent gattServiceIntent = new Intent (this, BluetoothLeService.class);

bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);

on uiSuccessfulWrite.

Add Receiver

 

Add Broadcast Receiver mGattUpdateReceiver And get Data on OnReceive()

Calling Events

 

int i = 1;

class MyTask extends TimerTask {

public void run() {
        if (mGattCharacteristics != null) {
            if (mGattCharacteristics.size() > 3) {
                // for(int i=1;i<4;i++) {
                if (i == 5) i = 1;
                BluetoothGattCharacteristic characteristic;
                if (i == 1) {
                    characteristic =
                            mGattCharacteristics.get(3).get(0);
                } else {
                    characteristic =
                            mGattCharacteristics.get(6).get(i-1);
                }
                Log.e("count", i + "");
                i = i + 1;
                final int charaProp = characteristic.getProperties();
                if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
                    // If there is an active notification on a characteristic, clear
                    // it first so it doesn't update the data field on the user interface.
                    if (mNotifyCharacteristic != null
                            && mBluetoothLeService != null) {
                        mBluetoothLeService.setCharacteristicNotification(
                                mNotifyCharacteristic, false);
                        mNotifyCharacteristic = null;
                    }
                    if (mBluetoothLeService != null) {
                        mBluetoothLeService.readCharacteristic(characteristic);
                    }
                }
                if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
                    mNotifyCharacteristic = characteristic;
                    if (mBluetoothLeService != null) {
                        mBluetoothLeService.setCharacteristicNotification(
                                characteristic, true);
                    }
                }
            }
        }
    }

}

Data Storage

 

private void displayGattServices(List gattServices) {

    if (gattServices == null) return;
    String uuid = null;
    String unknownServiceString = getResources().getString(R.string.unknown_service);
    String unknownCharaString = getResources().getString(R.string.unknown_characteristic);
    ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<>();
    ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData
            = new ArrayList<ArrayList<HashMap<String, String>>>();
    mGattCharacteristics = new ArrayList<>();
    // Loops through available GATT Services.
    for (BluetoothGattService gattService : gattServices) {
        HashMap<String, String> currentServiceData = new HashMap<>();
        uuid = gattService.getUuid().toString();
        currentServiceData.put(
                LIST_NAME, SampleGattAttributes.lookup(uuid, unknownServiceString));
        currentServiceData.put(LIST_UUID, uuid);

        gattServiceData.add(currentServiceData);

        ArrayList<HashMap<String, String>> gattCharacteristicGroupData =
                new ArrayList<HashMap<String, String>>();
        List<BluetoothGattCharacteristic> gattCharacteristics =
                gattService.getCharacteristics();
        ArrayList<BluetoothGattCharacteristic> charas =
                new ArrayList<BluetoothGattCharacteristic>();

        for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
            charas.add(gattCharacteristic);
            HashMap<String, String> currentCharaData = new HashMap<String, String>();
            uuid = gattCharacteristic.getUuid().toString();
            currentCharaData.put(
                    LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));
            currentCharaData.put(LIST_UUID, uuid);
            gattCharacteristicGroupData.add(currentCharaData);
        }
        mGattCharacteristics.add(charas);
        gattCharacteristicData.add(gattCharacteristicGroupData);
    }

    SimpleExpandableListAdapter gattServiceAdapter = new SimpleExpandableListAdapter(
            this,
            gattServiceData,
            android.R.layout.simple_expandable_list_item_2,
            new String[]{LIST_NAME, LIST_UUID},
            new int[]{android.R.id.text1, android.R.id.text2},
            gattCharacteristicData,
            android.R.layout.simple_expandable_list_item_2,
            new String[]{LIST_NAME, LIST_UUID},
            new int[]{android.R.id.text1, android.R.id.text2}
    );
    mGattServicesList.setAdapter(gattServiceAdapter);

}

private static IntentFilter makeGattUpdateIntentFilter() {

    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED);
    intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED);
        intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED);
    intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
    return intentFilter;

}

Device Battery Status

 

Call this methods to get Battery Information.

attributes.getBattery() methods returns Battery Information details.

Add this after conn.display(intent.getStringExtra(BluetoothLeService.EXTRA_DATA));

Device Contact Tracing Data

 

Step 1: Add this piece of code

int i = 4;

class MyTask extends TimerTask {

public void run() {
    if (mGattCharacteristics != null) {
        if (mGattCharacteristics.size() > 3) {
            if (i == 78) i = 4;
            BluetoothGattCharacteristic characteristic;
            characteristic =
                    mGattCharacteristics.get(6).get(i);
            i = i + 1;
            final int charaProp = characteristic.getProperties();
            if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
                if (mNotifyCharacteristic != null
                        && mBluetoothLeService != null) {
                    mBluetoothLeService.setCharacteristicNotification(
                            mNotifyCharacteristic, false);
                    mNotifyCharacteristic = null;
                }
                if (mBluetoothLeService != null) {
                    mBluetoothLeService.readCharacteristic(characteristic);
                }
            }
            if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
                mNotifyCharacteristic = characteristic;
                if (mBluetoothLeService != null) {
                    mBluetoothLeService.setCharacteristicNotification(
                            characteristic, true);
                }
            }
        }
    }
 }

}

Step 2: Fetching Contact Tracing Data

attributes.getAlrt_wr_mac_id() & attributes.getCntct_dt() returns Contact Tracing Data.

Add this after conn.display(intent.getStringExtra(BluetoothLeService.EXTRA_DATA)); Provides Conditions
!attributes.getAlrt_wr_mac_id().matches("") && attributes.getAlrt_wr_mac_id().length() > 4.

Device Temperature Data

 

Call this methods to get Temparature Information.

attributes.getTemp_cen(), attributes.getTemp_frn() methods returns Temparature details.

Add this after conn.display(intent.getStringExtra(BluetoothLeService.EXTRA_DATA));

Device Disconnection

 

To Disconnect Alert wear, just put this piece of code

try {

unbindService(mServiceConnection);
                                
mBluetoothLeService = null;
                                
if(bluetooth != null) {
                                    
bluetooth.disconnect();
                                
}
                                
Toast.makeText(getApplicationContext(),"Device is disconnected successfully!",Toast.LENGTH_SHORT).show();                           

}

catch(IllegalArgumentException ex){

Toast.makeText(getApplicationContext(),"Device is already disconnected!",Toast.LENGTH_SHORT).show();

}

Diagonis API

 

1. LED Test
Add this in your activity conn.led_Diago()

2. Buzzer Test
Add this in your activity conn.buzzer_Diago()

Integration for Beacon

 

Step 1:
Add Dependency
Implement dependency implementation 'org.altbeacon:android-beacon-library:2.17.1' in your Gradle file.

 

Step 2:
Initialization of variables

 private BeaconManager beaconManager;
 BeaconService beaconService;

 

Step 3:
Implementation for Beacon Feature
Need to implement BeaconConsumer in your Activity class

 

Step 4:
Write this piece of Code within onBeaconServiceConnect() to get UUID,Major Value,Minor Value and Distance as follows

//Constructing a new Region object to be used for Ranging or Monitoring

    final Region region = new Region("myBeaons",null, null, null);

    //Specifies a class that should be called each time the BeaconService sees or stops seeing a Region of beacons.
    beaconManager.addMonitorNotifier(new MonitorNotifier() {

        /*
            This override method is runned when some beacon will come under the range of device.
        */
        @Override
        public void didEnterRegion(Region region) {
            System.out.println("ENTER ------------------->");
            try {

                //Tells the BeaconService to start looking for beacons that match the passed Region object
                // , and providing updates on the estimated mDistance every seconds while beacons in the Region
                // are visible.
                beaconManager.startRangingBeaconsInRegion(region);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

        /*
             This override method is runned when beacon that comes in the range of device
             ,now been exited from the range of device.
         */
        @Override
        public void didExitRegion(Region region) {
            System.out.println("EXIT----------------------->");
            try {

                //Tells the BeaconService to stop looking for beacons
                // that match the passed Region object and providing mDistance
                // information for them.
                beaconManager.stopRangingBeaconsInRegion(region);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }


        /*
             This override method will Determine the state for the device , whether device is in range
           of beacon or not , if yes then i = 1 and if no then i = 0
        */
        @Override
        public void didDetermineStateForRegion(int state, Region region) {
            System.out.println( "I have just switched from seeing/not seeing beacons: "+state);
        }
    });



    //Specifies a class that should be called each time the BeaconService gets ranging data,
    // which is nominally once per second when beacons are detected.
    beaconManager.addRangeNotifier(new RangeNotifier() {

        /*
           This Override method tells us all the collections of beacons and their details that
           are detected within the range by device
         */
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            System.out.println( "AAAAAAAA11111: "+beacons);

                // Iterating through all Beacons from Collection of Beacons
                for (Beacon b:beacons){

                    //UUID
                    String uuid = String.valueOf(b.getId1());

                    //Major
                    long major = Long.parseLong(String.valueOf(b.getId2()));

                    long unsignedTemp = Long.parseLong(String.valueOf(major>>8));
                    // long unsignedTemp = Long.parseLong(major);
                    double temperature = unsignedTemp > 128 ?
                            unsignedTemp - 256 :
                            unsignedTemp +(Long.parseLong(String.valueOf(unsignedTemp & 0xff)))/25;
                    //Minor
                    String minor = String.valueOf(b.getId3());

                    //Distance
                    double distance1 =b.getDistance();
                    String distance = String.valueOf(Math.round(distance1*100.0)/100.0);
                }
           
        }
    });
    try {
        //Tells the BeaconService to start looking for beacons that match the passed Region object.
        beaconManager.startMonitoringBeaconsInRegion(region);
    } catch (RemoteException e) {
    }

Web API

 

1.User Temperature Data (For 1 day)
Endpointhttp://182.18.157.246:5000/getHistoricDayUserDataMethodPOST
Params Required:
user_id =[DEVICE_MAC_ID]
day=[ YYYY-MM] eg. [2020-06-02 17:54:54”]
Success Response: Code: 200
Content {
"status": 1,
"message": "Successfully executed query.",
"filtereddata": [
{
"date": "24-Jun-2020",
"time": "00:00:00",
"temperature": 98.4
},
{
"date": "24-Jun-2020",
"time": "00:30:00",
"temperature": 98.2
}
]
}
Error Response: Code: 200
Content: "data":[{}]

 

2. Using this API user will able to get temperature by giving user id and date & time range.

 

2.User Data with Temperature (Date Range)
Endpointhttp://182.18.157.246:5000/getHistoricEmployeeDataMethodPOST
Params Required:
user_id=[ DEVICE_MAC_ID]
from= [YYYY-MM-DD & HH:SS] eg . [2020-05-01 00:00]
to = [YYYY-MM-DD & HH:SS] eg .[ 2020-05-01 23:00]
offset = [integer]
limit = [limit]
Success Response: Code: 200
Content : {
"filtereddata": [
{
"resulttime": "2020-06-2912: 35: 30",
"temperature": 99.45,
"fullname": "samratmitra",
"employee_code": null,
"city": null,
"zipcode": null
},
{
"resulttime": "2020-06-2912: 35: 20",
"temperature": 100.67,
"fullname": "samratmitra",
"employee_code": null,
"city": null,
"zipcode": null
}],
"totaldata": 60
}
Error Response: Code: 200
Content: "data":[{}]

 

3. Using this API user will able to get min/max temperature by giving user id and no. of days.

 

3.User Min/Max Temperature
Endpointhttp://182.18.157.246:5000/getUserMinMaxDataMethodPOST
Params Required:
user_id=[ DEVICE_MAC_ID]
day = [integer]
Success Response: Code: 200
Content {
"status": 1,
"message": "Successfully executed query.",
"filtereddata": [
{
"maxdate": "01-Aug-2020",
"maxtime": "23:59:59",
"mindate": "01-Aug-2020",
"mintime": "00:00:43",
"minTemperature": 98.56,
"maxTemperature": 100.67
},
{
"maxdate": "02-Aug-2020",
"maxtime": "23:59:09",
"mindate": "02-Aug-2020",
"mintime": "00:00:39",
"minTemperature": 98.56,
"maxTemperature": 100.67
}],
"totaldata": 2
}
Error Response: Code: 200
Content: "data":[{}]

 

4. Using this API user will able to get temperature by giving user id and from date &no. of days.

 

4.User Temperature Data
Endpointhttp://182.18.157.246:5000/getHistoricUserDataMethodPOST
Params Required:
user_id=[ DEVICE_MAC_ID]
day = [integer]
dtform = [date] eg [2020-06-21]
Success Response: Code: 200
Content {
"status": 1,
"message": "Successfully executed query.",
"filtereddata": [
{
"date": "11-Jun-2020",
"time": "00:00:00",
"temperature": 98.0
},
{
"date": "11-Jun-2020",
"time": "00:30:00",
"temperature": 98.2
},
{
"date": "11-Jun-2020",
"time": "01:00:00",
"temperature": 98.0
},
{
"date": "11-Jun-2020",
"time": "01:30:00",
"temperature": 99.0
} ],
"totaldata": 479
}
Error Response: Code: 200
Content: "data":[{}]

 

5. Using this API user will able to get the contact tracing report.

 

5.User Temperature Data
Endpointhttp://182.18.157.246:5000/getContactTracingReportMethodPOST
Params Required:
user_id=[ DEVICE_MAC_ID]
dtpickerfrom= [YYYY-MM-DD & HH:SS] eg . [2020-05-01 00:00]
dtpickerto= [YYYY-MM-DD & HH:SS] eg .[ 2020-05-01 23:00]
Success Response: Code: 200
Content {
"filtereddata": [
{
"contact_userid": "ReemaChaudhuri",
"contactoccured": {
"$date": 1607077565000
},
"user_name": "Amit Paul"
},
{
"contact_userid": "ReemaChaudhuri",
"contactoccured": {
"$date": 1607076659000
},
"user_name": "Amit Paul"
}
],
"totaldata": 2
}
Error Response: Code: 200
Content: "data":[{}]

Security Policy

 

Use of personal information

Personal data and other kinds of information is collected and used for the purpose of providing our services to you. This kind of information might be collected as required by us and we would aim to prevent the violation of personal integrity in the processing of personal data. We will, of course, always handle personal data about you in accordance with the relevant legislation.

Let's Get In Touch!


Ready to start your next project with us?
That's great! Give us a call or send us an email and we will get back to you as soon as possible!

Black Box Network Services India Pvt. Ltd.

+91 990 309 1725 / +91 907 392 9780

Copyright © 2024 Sxtreo. All Rights Reserved.