Bluetooth, Sensors & Auto Flashcards

ADVANCED › Emerging

What does GATT stand for, and what role does it play in BLE?
Generic Attribute Profile. It defines how BLE devices exchange data as attributes organized into services, characteristics, and descriptors, transported over the Attribute Protocol (ATT). All modern BLE profiles are built on GATT.
Distinguish the central/peripheral roles from the GATT client/server roles in BLE.
Central scans and initiates connections; peripheral advertises and accepts them. GATT client requests data; GATT server holds and serves it. The two role pairs are independent, though commonly the peripheral is the server and the central is the client.
What runtime permissions does BLE require on Android 12 (API 31) and higher?
BLUETOOTH_SCAN to discover devices, BLUETOOTH_CONNECT to connect and communicate, and BLUETOOTH_ADVERTISE to advertise as a peripheral. Adding android:usesPermissionFlags="neverForLocation" to BLUETOOTH_SCAN avoids needing ACCESS_FINE_LOCATION, which older versions required for scanning.
Walk through the BLE client connection flow and the key API classes.
Get BluetoothAdapter from BluetoothManager, scan with BluetoothLeScanner, then call device.connectGatt() which returns a BluetoothGatt. In BluetoothGattCallback handle onConnectionStateChange, then discoverServices(), and finally read/write characteristics or enable notifications by writing the relevant descriptor.
How do you register for sensor updates, and what are the SensorEventListener callbacks?
Get SensorManager via getSystemService(SENSOR_SERVICE), obtain a sensor with getDefaultSensor(TYPE_X), then call registerListener(listener, sensor, delay). The listener implements onSensorChanged(SensorEvent) and onAccuracyChanged(). Unregister in onPause/onStop to save battery.
What are the SENSOR_DELAY_* rates and which is the default?
FASTEST (0us), GAME (20,000us), UI (60,000us), and NORMAL (200,000us, the default). The delay is only a hint; the system may deliver events faster. On Android 3.0+ you can also pass an explicit microsecond value.
What is the difference between hardware and software (composite) sensors? Give examples.
Hardware sensors are physical components: accelerometer, magnetometer, gyroscope, barometer. Software/composite sensors are derived in software from one or more hardware sensors: gravity, linear acceleration, rotation vector, and step counter.
Android Auto vs Android Automotive OS, what is the difference?
Android Auto is a phone-projection experience: the phone runs the app and casts a driving-safe UI to a compatible head unit. Android Automotive OS (AAOS) is a full Android-based operating system embedded in the vehicle, where apps are installed directly on the car.
How do you build a navigation or point-of-interest app for cars, and why the constraints?
Use the Android for Cars App Library (androidx.car.app) with CarAppService, Session, and Screen, rendering a fixed set of templates (ListTemplate, GridTemplate, NavigationTemplate, etc.). Templates enforce driver-distraction limits, and the same code runs on both Android Auto and Android Automotive OS.

Back to Bluetooth, Sensors & Auto