<commit_before>// Minicar BLE communicating protocol:
//     steerer(1byte) + angle(2byte) + driver(1byte) + speed(2byte) + others(2byte)
// steerer:
//     front: f >>> 0x66
//     left : l >>> 0x6c
//     right: r >>> 0x72
// driver:
//     coast  : c >>> 0x63
//     brake  : b >>> 0x62
//     forward: f >>> 0x66
//     reverse: r >>> 0x72
// number:
//     0 ~ 9 >>> 0x30 ~ 0x39
// char:
//     a ~ z >>> 0x61 ~ 0x7a

console.log("Minicar is controlled by Bluetooth");

var pwm = require("pwm");
var ble = require ("ble");
var pins = require("arduino101_pins");
var steerer = require("Steerer.js");
var driver = require("Driver.js");

// Minicar init
var steerPin = pwm.open({ channel: pins.IO3 });
steerer.setSteerPin(steerPin);
steerer.init();

var forwardPin = pwm.open({ channel: pins.IO6 });
var reversePin = pwm.open({ channel: pins.IO5 });
driver.setForwadPin(forwardPin);
driver.setReversePin(reversePin);
driver.init();

// Buffer init
var basicBuffer = new Buffer(8);

// start BLE
var speed = 50;
var angle = 30;
var CPFlag = true;

var BuftoNum = function (buf) {
    var Num = 0;
    var checkValue = 0x30;

    for (var j = 0; j < 10; j++) {
        if (buf === checkValue + j) return Num + j;
    }
}

var NumtoBuf = function (num) {
    var buf = 0x30;
    var checkValue = 0;

    for (var j = 0; j < 10; j++) {
        if (num === checkValue + j) return buf + j;
    }
}

var StrtoBuf = function (Str) {
    if (Str === "brake") return 0x62;
    if (Str === "coast") return 0x63;
    if (Str === "front" || Str === "forward") return 0x66;
    if (Str === "left") return 0x6c;
    if (Str === "right" || Str === "reverse") return 0x72;
}

var BasicCharacteristic = new ble.Characteristic({
    uuid: "ff10",
    properties: ["read", "write"],
    descriptors: [
        new ble.Descriptor({
            uuid: "2901",
            value: "Basic: steerer driver"
        })
    ]
});

BasicCharacteristic.onReadRequest = function(offset, callback) {<commit_msg>[tests] Fix bug for ble drive state (#10)<commit_after>// Minicar BLE communicating protocol:
//     steerer(1byte) + angle(2byte) + driver(1byte) + speed(2byte) + others(2byte)
// steerer:
//     front: f >>> 0x66
//     left : l >>> 0x6c
//     right: r >>> 0x72
// driver:
//     coast(park): p >>> 0x70
//     brake(park): p >>> 0x70
//     forward    : f >>> 0x66
//     reverse    : r >>> 0x72
// number:
//     0 ~ 9 >>> 0x30 ~ 0x39
// char:
//     a ~ z >>> 0x61 ~ 0x7a

console.log("Minicar is controlled by Bluetooth");

var pwm = require("pwm");
var ble = require ("ble");
var pins = require("arduino101_pins");
var steerer = require("Steerer.js");
var driver = require("Driver.js");

// Minicar init
var steerPin = pwm.open({ channel: pins.IO3 });
steerer.setSteerPin(steerPin);
steerer.init();

var forwardPin = pwm.open({ channel: pins.IO6 });
var reversePin = pwm.open({ channel: pins.IO5 });
driver.setForwadPin(forwardPin);
driver.setReversePin(reversePin);
driver.init();

// Buffer init
var basicBuffer = new Buffer(8);

// start BLE
var speed = 50;
var angle = 30;
var CPFlag = true;

var BuftoNum = function (buf) {
    var Num = 0;
    var checkValue = 0x30;

    for (var j = 0; j < 10; j++) {
        if (buf === checkValue + j) return Num + j;
    }
}

var NumtoBuf = function (num) {
    var buf = 0x30;
    var checkValue = 0;

    for (var j = 0; j < 10; j++) {
        if (num === checkValue + j) return buf + j;
    }
}

var StrtoBuf = function (Str) {
    if (Str === "park") return 0x70;
    if (Str === "front" || Str === "forward") return 0x66;
    if (Str === "left") return 0x6c;
    if (Str === "right" || Str === "reverse") return 0x72;
}

var BasicCharacteristic = new ble.Characteristic({
    uuid: "ff10",
    properties: ["read", "write"],
    descriptors: [
        new ble.Descriptor({
            uuid: "2901",
            value: "Basic: steerer driver"
        })
    ]
});

BasicCharacteristic.onReadRequest = function(offset, callback) {
{'fraction_non_alphanumeric': 0.17477931904161412, 'fraction_numerical': 0.0416141235813367, 'mean_word_length': 2.7274436090225564, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7200335', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1417, 'n_words': 412}