aws / amazon-freertos-ble-android-sdk

Android SDK for FreeRTOS Bluetooth Devices.
Apache License 2.0
49 stars 41 forks source link

Get status in SaveNetworkResp #32

Closed ignasbol closed 4 years ago

ignasbol commented 4 years ago

When building a custom app using the SDK, I've noticed that the SaveNetworkResp does not contain a getStatus() method the same way as the ListNetworkResp does. It is possible to use contains() method on the response.toString() to capture the status required:

@Override
public void onSaveNetworkResponse(final SaveNetworkResp response) {
  if (response.toString().contains("status: 0")) {
    Log.i(TAG, "Network saved successfully");     
  } else {
    Log.i(TAG, "Network not saved");     
  }
}

However it feels more like a workaround, rather than an optimal solution. After investigating, I've noticed that the SaveNetworkResp class is missing a @Getter annotation. Same for DeleteNetworkResp and EditNetworkResp. After adding @Getter to the classes, getStatus() can be used:

@Override
public void onSaveNetworkResponse(final SaveNetworkResp response) {
  if (response.getStatus() == 0) {
    Log.i(TAG, "Network saved successfully");     
  } else {
    Log.i(TAG, "Network not saved");     
  }
}

I've made a commit https://github.com/ignasbol/amazon-freertos-ble-android-sdk/commit/025a8c1c0100d2364004115c8ea1d754659bcbab to solve this.

ignasbol commented 4 years ago

PR: #33

ravibhagavandas commented 4 years ago

Thanks for bringing this into our attention and fixing the issue. I have merged the PR to master.