Skip to content

Instantly share code, notes, and snippets.

View thgbarros's full-sized avatar

Thiago barros thgbarros

  • Zup Innovation
  • São carlos - SP
View GitHub Profile
@thgbarros
thgbarros / models.js
Last active April 23, 2019 07:24
OAuth 2.0 server implementation to Alexa Skill Account linking
const pgp = require('pg-promise')({});
const db = pgp(process.env.DATABASE_URL);
/*
* Get access token.
*/
module.exports.getAccessToken = function(bearerToken) {
return db.query('SELECT otk_token_acesso, otk_token_expira_em, otk_ocl_id, otk_refresh_token, otk_refresh_token_expira_em, otk_usr_id FROM otk_oauth_tokens WHERE otk_token_acesso = $1', [bearerToken])
.then(function(result) {
@thgbarros
thgbarros / smarthome-handler.js
Created March 14, 2018 14:27
Alexa Smart Home Function Example
exports.handler = function (request, context) {
if (request.directive.header.namespace === 'Alexa.Discovery' && request.directive.header.name === 'Discover') {
//log("DEBUG:", "Discover request", JSON.stringify(request));
//handleDiscovery(request, context, "");
console.log("Olá discovery")
}
else if (request.directive.header.namespace === 'Alexa.PowerController') {
if (request.directive.header.name === 'TurnOn' || request.directive.header.name === 'TurnOff') {
log("DEBUG:", "TurnOn or TurnOff Request", JSON.stringify(request));
handlePowerControl(request, context);
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt --assume-yes install oracle-java8-installer
java -version
@thgbarros
thgbarros / FrameDecode.java
Created October 29, 2020 01:21
ProtocolTPMS
public void onEventMainThread(ByteBuffer frameBuf) {
byte[] frame = frameBuf.array();
byte cmd = frame[4];
SLOG.LogByteArr(TAG, frame, frame.length);
if (cmd == 33) {
Log.m941i("find", "查寻反回基本参数");
SLOG.LogByteArr("find", frame, frame.length);
decodeAlarmAgrsProc(frame[6], frame[7], frame[8]);
} else if (cmd == 17) {
Log.m941i(TAG, "是握手了");