Intent API
The Network Survey Intent API allows external applications to interact with the Network Survey app. By sending Android intents with specific actions and extras, you can control various aspects of Network Survey’s functionality, such as:
- Starting and stopping network surveys
- Configuring logging options (cellular, Wi-Fi, etc.)
- Setting up MQTT connections for real-time data streaming
This API is designed to enable integration between your application and Network Survey, enabling 3rd party apps to control the basic functions of Network Survey.
Intent Basic Structure
Section titled “Intent Basic Structure”To use the Network Survey Intent API, you need to create an Intent object with the following action and component:
Action: com.craxiom.networksurvey.START_SURVEY
or com.craxiom.networksurvey.STOP_SURVEY
Component:
- Package:
com.craxiom.networksurvey
- Service:
com.craxiom.networksurvey.services.NetworkSurveyService
Intent Extras
Section titled “Intent Extras”The following extras can be set on an Intent to configure Network Survey’s behavior:
Extra Name | Type | Description | Example Value |
---|---|---|---|
cellular_file_logging | boolean | If true, cellular file logging will be enabled | true |
wifi_file_logging | boolean | If true, Wi-Fi file logging will be enabled | true |
bluetooth_file_logging | boolean | If true, Bluetooth file logging will be enabled | true |
gnss_file_logging | boolean | If true, GNSS file logging will be enabled | true |
cdr_file_logging | boolean | If true, call detail record file logging will be enabled | true |
mqtt_config_json | string (JSON) | A JSON string containing MQTT connection configuration | See below |
MQTT Configuration JSON
Section titled “MQTT Configuration JSON”The mqtt_config_json
extra value is a JSON string. Following is an example showing all the values that can be set in the JSON object:
{ "mqtt_host": "mqtt.example.com", "mqtt_port": 8883, "mqtt_tls": true, "mqtt_client": "aclient", "mqtt_username": "auser", "mqtt_password": "apassword", "mqtt_topic_prefix": "my/custom/topic/path/", "cellular_stream_enabled": true, "wifi_stream_enabled": true, "bluetooth_stream_enabled": true, "gnss_stream_enabled": true, "device_status_stream_enabled": true}
Required fields:
mqtt_host
mqtt_port
mqtt_tls
mqtt_client
All other fields are optional.
Usage Examples
Section titled “Usage Examples”Start Network Survey with Logging
Section titled “Start Network Survey with Logging”Intent startNetworkSurveyIntent = new Intent("com.craxiom.networksurvey.START_SURVEY");
// Specify which logging to enablestartNetworkSurveyIntent.putExtra("cellular_file_logging", true);startNetworkSurveyIntent.putExtra("wifi_file_logging", true);
// Specify NS as the componentstartNetworkSurveyIntent.setComponent(new ComponentName( "com.craxiom.networksurvey", "com.craxiom.networksurvey.services.NetworkSurveyService"));
// Start the NS Servicecontext.startForegroundService(startNetworkSurveyIntent);
Start Network Survey with MQTT and Logging
Section titled “Start Network Survey with MQTT and Logging”Intent startNetworkSurveyIntent = new Intent("com.craxiom.networksurvey.START_SURVEY");
// Specify which logging to enablestartNetworkSurveyIntent.putExtra("cellular_file_logging", true);startNetworkSurveyIntent.putExtra("wifi_file_logging", true);
// MQTT is configured via a JSON stringString mqttConfigJsonString = "{\"mqtt_host\": \"mqtt.example.com\", " + "\"mqtt_port\": 8883, " + "\"mqtt_tls\": true, " + "\"mqtt_client\": \"aclient\", " + "\"mqtt_username\": \"auser\", " + "\"mqtt_password\": \"apassword\", " + "\"cellular_stream_enabled\": true, " + "\"wifi_stream_enabled\": true, " + "\"device_status_stream_enabled\": true " + "}";startNetworkSurveyIntent.putExtra("mqtt_config_json", mqttConfigJsonString);
// Specify NS as the componentstartNetworkSurveyIntent.setComponent(new ComponentName( "com.craxiom.networksurvey", "com.craxiom.networksurvey.services.NetworkSurveyService"));
// Start the NS Servicecontext.startForegroundService(startNetworkSurveyIntent);
Stop Network Survey
Section titled “Stop Network Survey”Intent stopNetworkSurveyIntent = new Intent("com.craxiom.networksurvey.STOP_SURVEY");
// Specify the componentstopNetworkSurveyIntent.setComponent(new ComponentName( "com.craxiom.networksurvey", "com.craxiom.networksurvey.services.NetworkSurveyService"));
// Start the service to stop itcontext.startForegroundService(stopNetworkSurveyIntent);
Related
Section titled “Related”- MQTT Streaming - MQTT configuration details
- File Logging Overview - Understanding file logging
- Required Permissions - Permissions needed