gatt-ip-js
Version:
GATT-IP library is A simple javascript protocol to connect any Bluetooth Smart (GATT) Device to the IP network
143 lines (136 loc) • 4.96 kB
JavaScript
var C = {
// TODO: When we are done, clean up all unsupported constancts
// make default timeout a tad longer than whatever the longest gateway timeout may be
// client should pass adequate timeouts
DEFAULT_MESSAGE_TIMEOUT_MS: 61000,
MAX_PENDING_MESSAGES: 200, // maximum number of pending requests (in message-processor)
NUM_CONNECT_ATTEMPTS: 3,
/* BEGIN new constants with gattip 2.0 */
kMessageId : "id",
kSessionId : "session_id",
kObjectId : "oid",
kAuthenticate : 'aut',
kOpen : 'opn',
kDeviceAccessToken : 'dat',
kGetVersionInfo : 'vif',
kOpenStream : 'ops',
kCloseStream : 'cls',
kStreamClosedIndication : 'cis',
kWriteStreamData : 'wsd',
kStreamDataIndication : 'sdi',
kVal : 'val',
kSpeed : 'spd',
kForce : 'frc',
/* END new constants with gattip 2.0 */
kError: "error",
kCode: "code",
kMessageField: "message",
kMethod:'method',
kResult: "result",
kIdField: "id",
kConfigure: "aa",
kScanForPeripherals: "ab",
kStopScanning: "ac",
kConnect: "ad",
kDisconnect: "ae",
kCentralState: "af",
kGetConnectedPeripherals: "ag",
kGetPerhipheralsWithServices: "ah",
kGetPerhipheralsWithIdentifiers: "ai",
kGetServices: "ak",
kGetIncludedServices: "al",
kGetCharacteristics: "am",
kGetDescriptors: "an",
kGetCharacteristicValue: "ao",
kGetDescriptorValue: "ap",
kWriteCharacteristicValue: "aq",
kWriteDescriptorValue: "ar",
kSetValueNotification: "as",
kGetPeripheralState: "at",
kGetRSSI: "au",
kInvalidatedServices: "av",
kPeripheralNameUpdate: "aw",
kMessage: "zz",
kCentralUUID: "ba",
kPeripheralUUID: "bb",
kPeripheralName: "bc",
kPeripheralUUIDs: "bd",
kServiceUUID: "be",
kServiceUUIDs: "bf",
kPeripherals: "bg",
kIncludedServiceUUIDs: "bh",
kCharacteristicUUID: "bi",
kCharacteristicUUIDs: "bj",
kDescriptorUUID: "bk",
kServices: "bl",
kCharacteristics: "bm",
kDescriptors: "bn",
kProperties: "bo",
kValue: "bp",
kState: "bq",
kStateInfo: "br",
kStateField: "bs",
kWriteType: "bt",
kRSSIkey: "bu",
kIsPrimaryKey: "bv",
kIsBroadcasted: "bw",
kIsNotifying: "bx",
kShowPowerAlert: "by",
kIdentifierKey: "bz",
kScanOptionAllowDuplicatesKey: "b0",
kScanOptionSolicitedServiceUUIDs: "b1",
kAdvertisementDataKey: "b2",
kCBAdvertisementDataManufacturerDataKey: "mfr",
kCBAdvertisementDataServiceUUIDsKey: "suu",
kCBAdvertisementDataServiceDataKey: "sdt",
kCBAdvertisementDataOverflowServiceUUIDsKey: "b6",
kCBAdvertisementDataSolicitedServiceUUIDsKey: "b7",
kCBAdvertisementDataIsConnectable: "cbl",
kCBAdvertisementDataTxPowerLevel: "txp",
kPeripheralBtAddress: "c1",
kRawAdvertisementData: "c2",
kScanRecord: "c3",
kCBCentralManagerRestoredStatePeripheralsKey: "da",
kCBCentralManagerRestoredStateScanServicesKey: "db",
kWriteWithResponse: "cc",
kWriteWithoutResponse: "cd",
kNotifyOnConnection: "ce",
kNotifyOnDisconnection: "cf",
kNotifyOnNotification: "cg",
kDisconnected: "ch",
kConnecting: "ci",
kConnected: "cj",
kUnknown: "ck",
kResetting: "cl",
kUnsupported: "cm",
kUnauthorized: "cn",
kPoweredOff: "co",
kPoweredOn: "cp",
kErrorPeripheralNotFound: "-32001",
kErrorServiceNotFound: "-32002",
kErrorCharacteristicNotFound: "-32003",
kErrorDescriptorNotFound: "-32004",
kErrorPeripheralStateIsNotValid: "-32005",
kErrorNoServiceSpecified: "-32006",
kErrorNoPeripheralIdentiferSpecified: "-32007",
kErrorStateRestorationNotValid: "-32008",
kInvalidRequest: "-32600",
kMethodNotFound: "-32601",
kInvalidParams: "-32602",
kError32603: "-32603",
kParseError: "-32700",
kGAP_ADTYPE_FLAGS: "01",
kGAP_ADTYPE_INCOMPLETE_16BIT_SERVICEUUID: "02",
kGAP_ADTYPE_COMPLETE_16BIT_SERVICEUUID: "03",
kGAP_ADTYPE_INCOMPLETE_32BIT_SERVICEUUID: "04",
kGAP_ADTYPE_COMPLETE_32BIT_SERVICEUUID: "05",
kGAP_ADTYPE_INCOMPLETE_128BIT_SERVICEUUID: "06",
kGAP_ADTYPE_COMPLETE_128BIT_SERVICEUUID: "07",
kGAP_ADTYPE_POWER_LEVEL: "0A",
kGAP_ADTYPE_MANUFACTURER_SPECIFIC: "FF",
kGAP_ADTYPE_16BIT_SERVICE_DATA: "16",
id: 1,
authenticate: 'authenticate',
AllProperties: ["Broadcast", "Read", "WriteWithoutResponse", "Write", "Notify", "Indicate", "AuthenticatedSignedWrites", "ExtendedProperties", "NotifyEncryptionRequired", "IndicateEncryptionRequired"]
};
module.exports.C = C;