The AudioMoth-Chime library provide support to set the time and the 8-byte deployment ID of an AudioMoth using an acoustic tone. These will automatically work with version 1.5.0 of the AudioMoth-Firmware-Basic and later.
The Kotlin Android library contains two classes that must be included in the app. They define AudioMothChime and AudioMothChimeConnector objects. The latter exposes three public functions:
fun playTone(duration: Int)
fun playTime(calendar: Calendar)
fun playTimeAndDeploymentID(calendar: Calendar, deploymentID: Array<Int>)
Below is an example of their use:
val chimeButton: Button = findViewById(R.id.chimeButton)
val audioMothConnector = AudioMothChimeConnector()
chimeButton.setOnClickListener{
val calendar = Calendar.getInstance()
Thread {
audioMothConnector.playTime(calendar)
}.start()
}
The Javascript library contains two classes that must be included in the webpage. They define the global AudioMothChime and AudioMothChimeConnector objects. The latter exposes three public functions:
playTone(duration, callback);
playTime(date, callback);
playTimeAndDeploymentID(date, deploymentID, callback);
Below is an example of their use:
var audioMothChimeConnector = new AudioMothChimeConnector();
document.getElementById("chime_button").addEventListener("click", () => {
document.getElementById("chime_button").disabled = true;
var date = new Date();
audioMothChimeConnector.playTime(date, () => {
document.getElementById("chime_button").disabled = false;
});
});
The Swift iOS library contains two classes that must be included in the app. They define AudioMothChime and AudioMothChimeConnector objects. The latter exposes three public functions:
func playTone(duration: Int)
func playTime(date: Date, timezone: TimeZone)
func playTimeAndDeploymentID(date: Date, timezone: TimeZone, deploymentID: Array<Int>)
Below is an example of their use:
Button(action: {
let date: Date = Date()
let timezone: TimeZone = TimeZone.current
audioMothChimeConnector.playTime(date: date, timezone: timezone)
}) {
Text("Play Chime")
}
Copyright 2019 Open Acoustic Devices.