API Reference
All methods are available directly on gotenna
globally as well as on window (window.gotenna
). When testing for the presence of gotenna it is recommended to check window.gotenna
since trying to access gotenna
on the global scope when it is undefined will result in a reference error.
gotenna.d.ts
declare namespace gotenna {
export interface IUserOptions {
gid?: number;
kGroupGIDs?: number[];
kMulticastGroupGIDs?: number[];
lastConnectedTime?: number;
latitude?: number;
locationAccuracy?: number;
locationTimestamp?: number;
longitude?: number;
name?: string;
}
export interface SystemInfo {
batteryLevel: number;
batteryPercentage: number;
dateCreated: Date;
firmwareVersion: FirmwareVersion;
serialNumber: string;
}
export class FirmwareVersion {
private major: string;
private minor: string;
private build: string;
/**
* A model class that represents a specific version of the firmware.
* Has helper methods for comparing and displaying firmware versions.
*/
constructor(firmwareVersionString: string);
/**
* The major revision number for the firmware, this would be '0' in 0.23.02
*/
public majorRevision: number;
/**
* The minor revision number for the firmware, this would be '23' in 0.23.02
*/
public minorRevision: number;
/**
* The build revision number for the firmware, this would be '02' in 0.23.02
*/
public buildRevision: number;
/**
* The current firmware version represented as a comparable number. Firmware Version 0.23.02 would be represented as 0.2302 Firmware Version 1.00.02 would be represented as 1.0002
*/
public toFloat(): number;
/**
* Returns a string representing the specified firmware version object.
*/
public toString(): string;
/**
* Returns the primitive value of a FirmwareVersion object.
*/
public valueOf(): number;
}
export interface Message {
receiverGID: number;
senderGID: number;
sentDate: string;
text: string;
}
export class User {
/**
* Helper methods for creating a brand new user object.
* @param name The name of the user.
* @param gid The goTenna ID of the user.
*/
static createUser(name: string, gid: number): User;
gid: number;
kGroupGIDs: number[];
kMulticastGroupGIDs: number[];
lastConnectedTime: number;
latitude: number;
locationAccuracy: number;
locationTimestamp: number;
longitude: number;
name: string;
/**
* A model representing the current goTenna User. There is typically only one instance of this class via UserDataStore
*/
constructor(options?: IUserOptions);
/**
* Adds the group GID to the list of the user's valid group GIDs.
* @param groupGID The group GID to add.
*/
addGroupGID(groupGID: number): void;
/**
* Adds the multicast group GID to the list of the user's valid group GIDs.
* @param groupGID The group GID to add.
*/
addMulticstGroupGID(groupGID: number): void;
/**
* Removes the group GID from the user's list of valid GIDs.
* @param groupGID The group GID to delete.
*/
deleteGroupGID(groupGID: number): void;
/**
* Removes the group GID from the user's list of valid GIDs.
* @param groupGID The multicast group GID to delete.
*/
deleteMulticastGroupGID(groupGID: number): void;
/**
* The GID (goTenna ID) of this specific user.
*/
getGID(): number;
/**
* Retrieves the list of the GIDs of all the groups this user belongs to.
*/
getGroupGIDs(): number[];
/**
* The last known time that the user was connected to the goTenna.
*/
getLastConnectedTime(): number;
/**
* Retrieves the user's last recorded gps location.
*/
getLastLocation(): Coordinates;
/**
* Retrieves the user's last recorded position.
*/
getLastPosition(): Position;
/**
* Retrieves the list of the GIDs of all the multicast groups this user belongs to.
*/
getMulticastGroupGIDs(): number[];
/**
* The name of the user i.e.) John Doe.
*/
getName(): string;
/**
* Checks to see if this group GID is already listed as one of the user's valid group GIDs.
* @param groupGID The group GID to check.
*/
hasGroupGID(groupGID: number): boolean;
/**
* Checks to see if this multicast group GID is already listed as one of the user's valid group GIDs.
* @param groupGID The multicast group GID to check.
*/
hasMulticastGroupGID(groupGID: number): boolean;
/**
* The users initials based on their name. **Note:** this may not work the same as the native SDK.
*/
initials(): string;
/**
* Sets the GID (goTenna ID) of this specific user.
* @param gid The GID (goTenna ID) of this specific user.
*/
setGID(gid: number): void;
/**
* Sets the last known time that the user was connected to the goTenna.
* @param timestamp The milliseconds timestamp of the last known time that the user was connected to the goTenna.
*/
setLastConnectedTime(timestamp: number): void;
/**
* Sets the user's name i.e.) John Doe.
* @param name The user's name.
*/
setName(name: string): void;
/**
* Updates the user's last recorded location. This location is cached with the user's basic info.
* @param latitude The user's last recorded latitude.
* @param longitude The user's last recorded longitude.
* @param accuracy The horizontal accuracy of the recorded location.
* @param timestamp The milliseconds timestamp of when the location was recorded.
*/
updateLocation(latitude: number, longitude: number, accuracy: number, timestamp: number): void;
/**
* Updates the user's last recorded position.
* @param position The user's last recorded position.
*/
updatePosition(position: Position): void;
}
function getApplicationBuildId(): Promise<{}>;
function hasSuperToken(): Promise<boolean>;
function isInDebugMode(): Promise<boolean>;
function setApplicationToken(token: string): void;
function tokenIsVerified(): Promise<boolean>;
function bluetoothIsEnabled(): Promise<boolean>;
function deviceSupportsBluetooth(): Promise<boolean>;
function disableBluetooth(): void;
function getBluetoothStatus(): Promise<GotennaBluetoothStatus>;
function showRequestBluetoothPermissionDialog(): void;
function addGtConnectionListener(callback: (gtConnectionState: GotennaConnectionState) => any): Promise<{}>;
function clearConnectedGotennaAddress(): void;
function disconnect(): void;
function disconnectWithRetry(): void;
function getConnectedGotennaAddress(): Promise<string>;
function getGtConnectionState(): Promise<GotennaConnectionState>;
function isConnected(): Promise<boolean>;
function scanAndConnect(deviceType?: 'V1' | 'MESH'): Promise<{}>;
function stopScan(): Promise<{}>;
function setGoTennaGID(gid: number, username: string): Promise<{}>;
function sendMessage(outgoingData: string, receiverGID: number, willEncrypt: boolean): Promise<{}>;
function sendGetSystemInfo(): Promise<SystemInfo>;
function setMessageListener(callback: (message: Message) => void): Promise<{}>;
//#region UserDataStore
function addGroupGID(groupGID: number): void;
function addMulticastGroupGID(groupGID: number): void;
function deleteCurrentUser(): void;
function deleteGroupGID(groupGID: number): void;
function deleteMulticastGroupGID(groupGID: number): void;
function getCurrentUser(): Promise<User | undefined>;
function hasGroupGID(groupGID: number): Promise<boolean>;
function hasMulticastGroupGID(groupGID: number): Promise<boolean>;
function hasValidUser(): Promise<boolean>;
function isMyGID(gid: number): Promise<boolean>;
function registerUser(name: string, gid: number): Promise<User>;
function saveCurrentUser(): void;
function setCurrentUser(user: User): void;
function updateLastConnectedTime(): void;
function updateLastLocation(latitude: number, longitude: number, accuracy: number, timestamp: number): void;
//#endregion UserDataStore
}
Last updated