mirror of
https://gitlab.silvrtree.co.uk/martind2000/bluetest.git
synced 2025-01-10 22:05:07 +00:00
init
This commit is contained in:
commit
87f7cb9ac7
32
.editorconfig
Normal file
32
.editorconfig
Normal file
@ -0,0 +1,32 @@
|
||||
; http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.txt]
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
|
||||
[*.m]
|
||||
indent_size = 4
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 8
|
||||
|
||||
[*.{js,json}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
79
.gitignore
vendored
Normal file
79
.gitignore
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
|
||||
|
||||
*.iml
|
||||
|
||||
/dist
|
||||
## Directory-based project format:
|
||||
.idea/
|
||||
# if you remove the above rule, at least ignore the following:
|
||||
|
||||
# User-specific stuff:
|
||||
# .idea/workspace.xml
|
||||
# .idea/tasks.xml
|
||||
# .idea/dictionaries
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
# .idea/dataSources.ids
|
||||
# .idea/dataSources.xml
|
||||
# .idea/sqlDataSources.xml
|
||||
# .idea/dynamic.xml
|
||||
# .idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
# .idea/gradle.xml
|
||||
# .idea/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
# .idea/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
### Node template
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directory
|
||||
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
|
||||
node_modules
|
||||
|
46
.jscsrc
Normal file
46
.jscsrc
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"disallowKeywords": ["with"],
|
||||
"disallowKeywordsOnNewLine": ["else"],
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowMultipleVarDecl": "exceptUndefined",
|
||||
"disallowNewlineBeforeBlockStatements": true,
|
||||
"disallowQuotedKeysInObjects": true,
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
||||
"disallowSpacesInFunction": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"maximumLineLength": 120,
|
||||
"requireCamelCaseOrUpperCaseIdentifiers": false,
|
||||
"requireCapitalizedComments": true,
|
||||
"requireCapitalizedConstructors": true,
|
||||
"requireCurlyBraces": true,
|
||||
"requireSpaceAfterKeywords": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"switch",
|
||||
"case",
|
||||
"return",
|
||||
"try",
|
||||
"catch",
|
||||
"typeof"
|
||||
],
|
||||
"requireSpaceAfterLineComment": true,
|
||||
"requireSpaceAfterBinaryOperators": true,
|
||||
"requireSpaceBeforeBinaryOperators": true,
|
||||
"requireSpaceBeforeBlockStatements": true,
|
||||
"requireSpaceBeforeObjectValues": true,
|
||||
"requireSpacesInFunction": {
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"requireTrailingComma": false,
|
||||
"requireEarlyReturn": false,
|
||||
"validateIndentation": 2,
|
||||
"validateLineBreaks": "LF",
|
||||
"validateQuoteMarks": "'"
|
||||
}
|
41
.jshintrc
Normal file
41
.jshintrc
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"predef": [
|
||||
"Promise"
|
||||
],
|
||||
"node": true,
|
||||
"browser": false,
|
||||
"boss": true,
|
||||
"curly": true,
|
||||
"debug": false,
|
||||
"devel": true,
|
||||
"eqeqeq": true,
|
||||
"evil": true,
|
||||
"forin": false,
|
||||
"immed": false,
|
||||
"laxbreak": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": false,
|
||||
"nonew": false,
|
||||
"nomen": false,
|
||||
"onevar": false,
|
||||
"plusplus": false,
|
||||
"regexp": false,
|
||||
"undef": true,
|
||||
"sub": true,
|
||||
"strict": false,
|
||||
"white": false,
|
||||
"eqnull": true,
|
||||
"esnext": true,
|
||||
"unused": true,
|
||||
"supernew": true,
|
||||
"globals": {
|
||||
"$": false,
|
||||
"EJS": false,
|
||||
"MicroEvent": false,
|
||||
"express":false,
|
||||
"http":false,
|
||||
"request":false,
|
||||
"cheerio":false
|
||||
}
|
||||
}
|
12
bin/cli.js
Normal file
12
bin/cli.js
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
var isEs2015;
|
||||
try {
|
||||
isEs2015 = new Function('() => {}');
|
||||
} catch (e) {
|
||||
isEs2015 = false;
|
||||
}
|
||||
isEs2015 ? require('../lib/cli') : require('../lib-es5/cli');*/
|
||||
|
||||
|
||||
require('../lib/cli')
|
4
index.js
Normal file
4
index.js
Normal file
@ -0,0 +1,4 @@
|
||||
var spawn = require('child_process').spawn;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
|
29
lib/cli.js
Normal file
29
lib/cli.js
Normal file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
const meow = require('meow');
|
||||
const bluetest = require('./index');
|
||||
|
||||
const cli = meow({
|
||||
help: `
|
||||
Usage
|
||||
$ bluetest <MAC>
|
||||
|
||||
Mac
|
||||
Mac address of bluetooth device.
|
||||
|
||||
`},
|
||||
{
|
||||
|
||||
default: {
|
||||
mac: process.cwd()
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const options = {
|
||||
mac:cli.input[0]
|
||||
};
|
||||
|
||||
bluetest(options);
|
50
lib/index.js
Normal file
50
lib/index.js
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
*
|
||||
* User: Martin Donnelly
|
||||
* Date: 2016-07-06
|
||||
* Time: 13:37
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
var spawn = require('child_process').spawn;
|
||||
var EventEmitter = require('events');
|
||||
var busEmitter = new EventEmitter();
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var logger = require('log4js').getLogger();
|
||||
|
||||
var bluetest = module.exports = function(options) {
|
||||
'use strict';
|
||||
|
||||
var core = {};
|
||||
|
||||
|
||||
core.init = function(options) {
|
||||
|
||||
var _mac;
|
||||
|
||||
//if ()
|
||||
if (typeof options.mac !== 'undefined') {
|
||||
_mac = options.mac;
|
||||
} else{
|
||||
console.log('You need to pass a mac address.');
|
||||
process.exit(1);
|
||||
}
|
||||
logger.info('Working with:' , options);
|
||||
|
||||
|
||||
var hciconfig = spawn(tool_path + 'hciconfig', [hcidev, 'up']);
|
||||
|
||||
hciconfig.on('exit', function(code) {
|
||||
|
||||
logger.debug('code',code);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
core.init(options);
|
||||
};
|
||||
util.inherits(bluetest, EventEmitter);
|
18
package.json
Normal file
18
package.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "bluetest",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "lib",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Martin Donnelly <martind2000@gmail.com>",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"log4js": "^0.6.37",
|
||||
"meow": "^3.7.0"
|
||||
},
|
||||
"bin": {
|
||||
"bluetest": "bin/cli.js"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user