GShock API
This class contains all the API functions. This should the the main interface to the library.
Here is how to use it:
private val api = GShockAPI(this)
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
GlobalScope.launch {
api.waitForConnection(this)
api.getPressedButton()
api.getWatchName()
api.getBatteryLevel()
api.getTimer()
api.getAppInfo()
api.getHomeTime()
api.setTime()
...
}
}
}
Functions
Clears all events (reminders) from the watch. Up to 5 events are supported.
Disconnect from the watch
Gets and internally sets app info to the watch. This is needed to re-enable lower-right button after the watch has been reset or BLE has been cleared. Call this function after each time the connection has been established.
Get Battery level.
Get the Daylight Saving Time for a particular World City set on the watch. There are 6 world cities that can be stored.
Get the DST state of the watch.
Gets the current events (reminders) from the watch. Up to 5 events are supported.
Get Home Time, (Home City).
This function tells us which button was pressed on the watch to initiate the connection. Remember, the connection between the phone and the watch can only be initiated from the watch.
Get settings from the watch. Example:
Get the name of the watch.
Get Watch Temperature.
Get the name for a particular World City set on the watch. There are 6 world cities that can be stored.
This function tells us if the connection was initiated by short-pressing the lower-right button on the watch, also known as ACTION BUTTON
This function tells us if the connection was initiated automatically by the watch, without the user pressing any button. This happens if Auto-Time is set in the setting. In this case, the watch will periodically connect at around 00:30, 06:30, 12:30 and 18:30
Tells us if Bluetooth is currently enabled on the phone. If not, the app can take action to enable it.
Returns a Boolean value indicating if the watch is currently commenced to the phone
This function tells us if the connection was initiated by ling-pressing the lower-right button on the watch, used to activate FIND PHONE action
This function tells us if the connection was initiated by long-pressing the lower-left button on the watch
Set settings to the watch. Populate a Settings and call this function. Example:
Sets the current time on the watch from the time on the phone. In addition, it can optionally set the Home Time to the current time zone. If timezone changes during travel, the watch will automatically be set to the correct time and timezone after running this function.
Close the connection and free all associated resources.
This function waits for the watch to connect to the phone. When connected, it returns and emmits a ConnectionSetupComplete
event, which can inform other parts of the app that the connection has taken place.