code stringlengths 1 1.05M | repo_name stringlengths 6 83 | path stringlengths 3 242 | language stringclasses 222
values | license stringclasses 20
values | size int64 1 1.05M |
|---|---|---|---|---|---|
import * as SPI from 'SPI'
function byteArrayToArrayBuffer(byteArray) {
return new Uint8Array(byteArray).buffer
}
class HW_SPI {
constructor(options) {
if (!options || !options.id) {
throw new Error("options is invalid");
}
this.options = {
id: options.id
... | YifuLiu/AliOS-Things | components/amp/jslib/src/spi.js | JavaScript | apache-2.0 | 1,674 |
'use strict';
import * as event from 'events'
import * as TCP from 'TCP'
class TCPClient extends event.EventEmitter{
constructor(options) {
super();
if (!options || !options.host || !options.port) {
throw new Error("invalid params");
}
this.options = {
host:... | YifuLiu/AliOS-Things | components/amp/jslib/src/tcp.js | JavaScript | apache-2.0 | 2,890 |
import * as UART from 'UART'
import * as event from 'events'
function byteArrayToArrayBuffer(byteArray) {
return new Uint8Array(byteArray).buffer
}
class HW_UART extends event.EventEmitter{
constructor(options) {
super();
if (!options || !options.id) {
throw new Error("options is ... | YifuLiu/AliOS-Things | components/amp/jslib/src/uart.js | JavaScript | apache-2.0 | 2,119 |
'use strict';
import * as UDP from 'UDP'
import * as event from 'events'
class UDPClient extends event.EventEmitter {
constructor() {
super();
this.udpClientInstance = UDP.createSocket();
if(this.udpClientInstance < 0) {
throw new Error("create socket error!");
}
... | YifuLiu/AliOS-Things | components/amp/jslib/src/udp.js | JavaScript | apache-2.0 | 1,901 |
import * as WDG from 'WDG'
export function start(timeout) {
if (!timeout) {
throw new Error('params is invalid');
}
WDG.start(timeout);
}
export function feed() {
WDG.feed();
}
export function stop() {
WDG.stop();
}
| YifuLiu/AliOS-Things | components/amp/jslib/src/wdg.js | JavaScript | apache-2.0 | 246 |
// The driver for DS18B20 chip, it is a temperature sensor.
// Require libjs/lib/onewire.js module.
import * as onewire from 'onewire'
var DS18B20Dev;
var start_flag = 0;
/*
* prebuild:
* ./qjsc -c -m ../jsmodules/ds18b20.js -N jslib_ds18b20 -M onewire -o bytecode/jslib_ds18b20.c
* config DS18B20
* GPIO's ... | YifuLiu/AliOS-Things | components/amp/jsmodules/ds18b20.js | JavaScript | apache-2.0 | 1,868 |
const watch = require('node-watch');
const minify = require('@node-minify/core');
const babelMinify = require('@node-minify/babel-minify');
const fse = require('fs-extra');
let watchFile = false;
process.argv.forEach((val, index) => {
if(val === '--watch'){
watchFile = true;
}
});
fse.ensureDirSync('.... | YifuLiu/AliOS-Things | components/amp/libjs/build.js | JavaScript | apache-2.0 | 1,077 |
const fs = require("fs");
const path = require("path");
// const watch = require("node-watch");
const minify = require("@node-minify/core");
const babelMinify = require("@node-minify/babel-minify");
const uglifyJS = require('@node-minify/uglify-js');
let watchFile = false;
process.argv.forEach((val, index) => {
if (... | YifuLiu/AliOS-Things | components/amp/libjs/generator.js | JavaScript | apache-2.0 | 4,684 |
(function () {
globalThis = new Function('return this;')();
globalThis.process = system;
})(); | YifuLiu/AliOS-Things | components/amp/libjs/init/process.js | JavaScript | apache-2.0 | 102 |
(function (global) {
//
// Check for native Promise and it has correct interface
//
var NativePromise = global['Promise'];
var nativePromiseSupported =
NativePromise &&
// Some of these methods are missing from
// Firefox/Chrome experimental implementations
'resolve... | YifuLiu/AliOS-Things | components/amp/libjs/init/promise.js | JavaScript | apache-2.0 | 8,966 |
'use strict';
class HW_ADC {
constructor(options) {
if (!options || !options.id) {
throw new Error('options is invalid');
}
this.options = {
id: options.id
};
this.success = options.success || function(){};
this.fail = options.fail || functi... | YifuLiu/AliOS-Things | components/amp/libjs/lib/adc.js | JavaScript | apache-2.0 | 969 |
'use strict';
const EventEmitter = require('events');
class UTILS_APPOTA extends EventEmitter {
constructor(options){
super();
if (!options) {
throw new Error('options invalid');
}
this._init(options);
}
_init(options) {
__native.APPOTA.otaInit(option... | YifuLiu/AliOS-Things | components/amp/libjs/lib/appota.js | JavaScript | apache-2.0 | 898 |
'use strict';
module.exports = __native.AT; | YifuLiu/AliOS-Things | components/amp/libjs/lib/at.js | JavaScript | apache-2.0 | 44 |
'use strict';
const EventEmitter = require('events');
module.exports = new class AudioPlayer extends EventEmitter {
constructor(){
super();
this._onState();
}
play(source, callback) {
if (!source || !callback) {
throw new Error('invalid params');
}
retu... | YifuLiu/AliOS-Things | components/amp/libjs/lib/audioplayer.js | JavaScript | apache-2.0 | 1,659 |
'use strict';
const EventEmitter = require('events');
module.exports = new class UTILS_Battery extends EventEmitter {
constructor(){
super();
}
getConnectState() {
return __native.Battery.getConnectState();
}
getVoltage() {
return __native.Battery.getVoltage();
}
... | YifuLiu/AliOS-Things | components/amp/libjs/lib/battery.js | JavaScript | apache-2.0 | 465 |
'use strict';
function start() {
__native.BLECFGNET.start();
}
function recoveryWifi() {
__native.BLECFGNET.recoveryWifi();
}
function recoveryDevInfo() {
__native.BLECFGNET.recoveryDevInfo();
}
module.exports = {
start,
recoveryWifi,
recoveryDevInfo
} | YifuLiu/AliOS-Things | components/amp/libjs/lib/blecfgnet.js | JavaScript | apache-2.0 | 280 |
'use strict';
const EventEmitter = require('events');
class bt_host extends EventEmitter{
constructor(options) {
super();
if (!options) {
throw new Error('options is invalid');
}
if (this.inited == true) {
throw new Error('bt_host already inited');
}
this.options = {
... | YifuLiu/AliOS-Things | components/amp/libjs/lib/bt_host.js | JavaScript | apache-2.0 | 3,652 |
'use strict';
const EventEmitter = require('events');
class HW_CAN extends EventEmitter{
constructor(options) {
super();
if (!options || !options.id) {
throw new Error('options is invalid');
}
this.options = {
id: options.id
};
this.success... | YifuLiu/AliOS-Things | components/amp/libjs/lib/can.js | JavaScript | apache-2.0 | 1,539 |
'use strict';
const EventEmitter = require('events');
module.exports = new class UTILS_Charger extends EventEmitter {
constructor(){
super();
this._onConnect();
}
_onConnect() {
__native.Charger.onConnect(function(state) {
this.emit('connect', state);
}.bind(th... | YifuLiu/AliOS-Things | components/amp/libjs/lib/charger.js | JavaScript | apache-2.0 | 630 |
'use strict';
class HW_DAC {
constructor(options) {
if (!options || !options.id) {
throw new Error('options is invalid');
}
this.options = {
id: options.id
};
this.success = options.success || function(){};
this.fail = options.fail || functio... | YifuLiu/AliOS-Things | components/amp/libjs/lib/dac.js | JavaScript | apache-2.0 | 1,173 |
'use strict';
var kv = require('kv');
function setDeviceInfo(pk, ps) {
if (!pk || !ps) {
throw new Error('params is invalid');
}
var productkey_key = '_amp_internal_productkey';
var productsecret_key = '_amp_internal_productsecret';
kv.setStorageSync(productkey_key, pk);
kv.setSto... | YifuLiu/AliOS-Things | components/amp/libjs/lib/device.js | JavaScript | apache-2.0 | 677 |
'use strict';
var spliceOne;
function EventEmitter() {
EventEmitter.init.call(this);
}
EventEmitter.EventEmitter = EventEmitter;
EventEmitter.usingDomains = false;
EventEmitter.prototype._events = undefined;
EventEmitter.prototype._eventsCount = 0;
EventEmitter.prototype._maxListeners = undefined;
var default... | YifuLiu/AliOS-Things | components/amp/libjs/lib/events.js | JavaScript | apache-2.0 | 11,144 |
'use strict';
function writeSync(path, data, options) {
if (!path || !data) {
throw new Error('params is invalid');
}
options = options || {flag: 'w'};
__native.FS.write(path, data, options);
}
function readSync(path) {
if(!path) {
throw new Error("invalid params");
}
var c... | YifuLiu/AliOS-Things | components/amp/libjs/lib/fs.js | JavaScript | apache-2.0 | 855 |
'use strict';
class HW_GPIO {
constructor(options) {
if (!options || !options.id) {
throw new Error("options is invalid");
}
this.options = {
id: options.id
};
this.success = options.success || function(){};
this.fail = options.fail || functi... | YifuLiu/AliOS-Things | components/amp/libjs/lib/gpio.js | JavaScript | apache-2.0 | 1,555 |
'use strict';
module.exports = __native.HTTP; | YifuLiu/AliOS-Things | components/amp/libjs/lib/http.js | JavaScript | apache-2.0 | 46 |
'use strict';
class HW_I2C {
constructor(options) {
if (!options || !options.id) {
throw new Error("options is invalid");
}
this.options = {
id: options.id
};
this.success = options.success || function(){};
this.fail = options.fail || functi... | YifuLiu/AliOS-Things | components/amp/libjs/lib/i2c.js | JavaScript | apache-2.0 | 1,644 |
'use strict';
const EventEmitter = require('events');
class IotDeviceClient extends EventEmitter {
constructor(options){
super();
if(!options || !options.productKey || !options.deviceName || !options.deviceSecret){
throw new Error('device info error');
}
this.options =... | YifuLiu/AliOS-Things | components/amp/libjs/lib/iot.js | JavaScript | apache-2.0 | 7,145 |
'use strict';
const EventEmitter = require('events');
module.exports = new class Keypad extends EventEmitter {
constructor(){
super();
this._on();
}
open() {
return __native.Keypad.open();
};
close() {
this.removeAllListeners('keypadEvent');
return __nativ... | YifuLiu/AliOS-Things | components/amp/libjs/lib/keypad.js | JavaScript | apache-2.0 | 492 |
'use strict';
module.exports = __native.KV; | YifuLiu/AliOS-Things | components/amp/libjs/lib/kv.js | JavaScript | apache-2.0 | 44 |
'use strict';
class ADVANCED_LOCATION {
constructor() {}
getAccessApInfo() {
var ap_info;
ap_info = __native.LOCATION.accessedWifi();
return ap_info;
}
getScannedApInfo() {
var ap_info;
ap_info = __native.LOCATION.scannedWifi();
return ap_info;
}
... | YifuLiu/AliOS-Things | components/amp/libjs/lib/location.js | JavaScript | apache-2.0 | 683 |
'use strict';
const EventEmitter = require('events');
class MQTTClient extends EventEmitter{
constructor(options) {
super();
if (!options || !options.host) {
throw new Error('options is invalid');
}
this.options = {
host: options.host,
p... | YifuLiu/AliOS-Things | components/amp/libjs/lib/mqtt.js | JavaScript | apache-2.0 | 4,445 |
'use strict';
const EventEmitter = require('events');
class netMgr extends EventEmitter{
constructor(options) {
super();
if(!options || !options.name){
throw new Error('device info error');
}
this.options = {
name: options.name
};
this.nam... | YifuLiu/AliOS-Things | components/amp/libjs/lib/netmgr.js | JavaScript | apache-2.0 | 3,456 |
'use strict';
const EventEmitter = require('events');
class netWork extends EventEmitter{
constructor(options) {
super();
if(!options || !options.type){
throw new Error('net type is error');
}
this.options = {
type: options.type || 'cellular',
... | YifuLiu/AliOS-Things | components/amp/libjs/lib/network.js | JavaScript | apache-2.0 | 4,651 |
'use strict';
class HW_ONEWIRE {
constructor(options) {
if (!options || !options.id) {
throw new Error("options is invalid");
}
this.options = {
id: options.id
};
this.success = options.success || function(){};
this.fail = options.fail || fun... | YifuLiu/AliOS-Things | components/amp/libjs/lib/onewire.js | JavaScript | apache-2.0 | 1,582 |
'use strict';
const EventEmitter = require('events');
class PayboxClient extends EventEmitter{
constructor(options){
super();
if(!options || !options.xpPrductKey || !options.xpDeviceSecret){
throw new Error('device info error');
}
this.options = {
mqttPrduct... | YifuLiu/AliOS-Things | components/amp/libjs/lib/paybox.js | JavaScript | apache-2.0 | 1,999 |
'use strict';
const EventEmitter = require('events');
module.exports = new class UTILS_PM extends EventEmitter {
constructor(){
super();
this._onPwrkey();
}
_onPwrkey() {
__native.PM.onPwrkey(function(state) {
this.emit('powerKey', state);
}.bind(this));
};... | YifuLiu/AliOS-Things | components/amp/libjs/lib/pm.js | JavaScript | apache-2.0 | 1,660 |
'use strict';
class HW_PWM {
constructor(options) {
if (!options || !options.id) {
throw new Error("options is invalid");
}
this.options = {
id: options.id
};
this.success = options.success || function(){};
this.fail = options.fail || functio... | YifuLiu/AliOS-Things | components/amp/libjs/lib/pwm.js | JavaScript | apache-2.0 | 1,172 |
'use strict';
function start() {
__native.RTC.open();
}
function setTime(time) {
if (!time) {
throw new Error('params is invalid');
}
if (!(time instanceof Date)) {
throw new Error('params is invalid');
}
var date = {
year: time.getYear(),
month: time.getMonth... | YifuLiu/AliOS-Things | components/amp/libjs/lib/rtc.js | JavaScript | apache-2.0 | 853 |
'use strict';
const EventEmitter = require('events');
module.exports = new class Smartcard extends EventEmitter {
constructor(){
super();
}
init() {
return __native.smartcard.init();
};
deinit() {
return __native.smartcard.deinit();
};
select(operator) {
... | YifuLiu/AliOS-Things | components/amp/libjs/lib/smartcard.js | JavaScript | apache-2.0 | 372 |
'use strict';
class HW_SPI {
constructor(options) {
if (!options || !options.id) {
throw new Error("options is invalid");
}
this.options = {
id: options.id
};
this.success = options.success || function(){};
this.fail = options.fail || functio... | YifuLiu/AliOS-Things | components/amp/libjs/lib/spi.js | JavaScript | apache-2.0 | 1,444 |
'use strict';
const EventEmitter = require('events');
function stringToBytesArray(str) {
var ch, st, re = [];
for (var i = 0; i < str.length; i++ ) {
ch = str.charCodeAt(i);
st = [];
do {
st.push(ch & 0xFF);
ch = ch >> 8;
}
while ( ch );
... | YifuLiu/AliOS-Things | components/amp/libjs/lib/tcp.js | JavaScript | apache-2.0 | 3,286 |
'use strict';
class HW_TIMER {
constructor(options) {
if (!options || !options.id) {
throw new Error('options is invalid');
}
this.options = {
id: options.id
};
this.success = options.success || function(){};
this.fail = options.fail || func... | YifuLiu/AliOS-Things | components/amp/libjs/lib/timer.js | JavaScript | apache-2.0 | 1,961 |
'use strict';
const EventEmitter = require('events');
module.exports = new class TTSSystem extends EventEmitter {
constructor(){
super();
this._onState();
}
play(content, encode) {
if (!content) {
throw new Error('invalid params');
}
return __native.TTS... | YifuLiu/AliOS-Things | components/amp/libjs/lib/tts.js | JavaScript | apache-2.0 | 1,205 |
'use strict';
const EventEmitter = require('events');
class HW_UART extends EventEmitter{
constructor(options) {
super();
if (!options || !options.id) {
throw new Error("options is invalid");
}
this.options = {
id: options.id,
mode: options.mode... | YifuLiu/AliOS-Things | components/amp/libjs/lib/uart.js | JavaScript | apache-2.0 | 1,939 |
'use strict';
const EventEmitter = require('events');
function stringToBytesArray(str) {
var ch, st, re = [];
for (var i = 0; i < str.length; i++ ) {
ch = str.charCodeAt(i);
st = [];
do {
st.push(ch & 0xFF);
ch = ch >> 8;
}
while ( ch );
... | YifuLiu/AliOS-Things | components/amp/libjs/lib/udp.js | JavaScript | apache-2.0 | 2,003 |
'use strict';
module.exports = __native.UI;
| YifuLiu/AliOS-Things | components/amp/libjs/lib/ui.js | JavaScript | apache-2.0 | 47 |
'use strict';
module.exports = __native.UND; | YifuLiu/AliOS-Things | components/amp/libjs/lib/und.js | JavaScript | apache-2.0 | 45 |
'use strict';
module.exports = __native.VM; | YifuLiu/AliOS-Things | components/amp/libjs/lib/vm.js | JavaScript | apache-2.0 | 44 |
'use strict';
function start(timeout) {
if (!timeout) {
throw new Error('params is invalid');
}
__native.WDG.start(timeout);
}
function feed() {
__native.WDG.feed();
}
function stop() {
__native.WDG.stop();
}
module.exports = {
start,
feed,
stop
} | YifuLiu/AliOS-Things | components/amp/libjs/lib/wdg.js | JavaScript | apache-2.0 | 291 |
'use strict';
const event = require('events');
function setIfConfig(options) {
if (!options) {
throw new Error('params is invalid');
}
__native.WIFI.set_ifconfig(options);
}
function getIfConfig() {
var config = __native.WIFI.get_ifconfig();
if (!config) {
throw 'get ifconfig fail... | YifuLiu/AliOS-Things | components/amp/libjs/lib/wifi.js | JavaScript | apache-2.0 | 893 |
TARGET = libmain.a
MODULE = main
MOD_SOURCES += \
amp_main.c \
amp_engine.c \
amp_task.c
MOD_INCLUDES := \
../adapter/include \
../adapter/include/peripheral \
../adapter/platform/linux \
../utils/mbedtls/include \
../utils/mbedtls/platform/include \
../utils/mbedtls/platform/amp/include \
../util... | YifuLiu/AliOS-Things | components/amp/main/Makefile | Makefile | apache-2.0 | 1,372 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#ifndef AMP_DEFINES_H
#define AMP_DEFINES_H
#include "amp_config.h"
#include "amp_memory.h"
#include "mbedtls/md5.h"
#include "mbedtls/sha1.h"
#include "mbedtls/aes.h"
#include "mbedtls/des.h"
#include "mbedtls/base64.h"
#include "ulog/ulog.h"
#include "... | YifuLiu/AliOS-Things | components/amp/main/amp_defines.h | C | apache-2.0 | 4,762 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "aos/kernel.h"
#include "aos/vfs.h"
#include "aos_system.h"
#include "aos_fs.h"
#include "amp_platform.h"
#include "amp_config.h"
#include "amp_task.h"
#include "amp_defines.h"
#include "board_mgr.h"
#include "cJSON.h"
#define MOD_STR "AMP_ENGIN... | YifuLiu/AliOS-Things | components/amp/main/amp_engine.c | C | apache-2.0 | 5,489 |
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#ifndef AMP_ERRNO_H
#define AMP_ERRNO_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__GNUC__)&&!defined(__CC_ARM)||defined(_WIN32)
#include <errno.h>
#else
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No... | YifuLiu/AliOS-Things | components/amp/main/amp_errno.h | C | apache-2.0 | 9,176 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "amp_platform.h"
#include "amp_defines.h"
#include "amp_config.h"
#include "aos_system.h"
#include "aos_network.h"
#ifdef AMP_KV_ENABLE
#include "aos/kv.h"
#endif
#include "aos_fs.h"
#include "amp_boot_recovery.h"
#include "amp_boot.h"
#ifdef JS... | YifuLiu/AliOS-Things | components/amp/main/amp_main.c | C | apache-2.0 | 3,063 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "amp_platform.h"
#include "amp_defines.h"
#include "amp_config.h"
#include "aos_system.h"
#include "amp_task.h"
#include "amp_list.h"
#define MOD_STR "AMP_TASK"
#define AMP_MSGQ_WAITIME (2000)
#define AMP_MSGQ_MAX_NUM ... | YifuLiu/AliOS-Things | components/amp/main/amp_task.c | C | apache-2.0 | 5,464 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#ifndef AMP_TASK_H
#define AMP_TASK_H
#include <aos/kernel.h>
#include <stdint.h>
typedef void (*amp_engine_call_t)(void *data);
typedef enum {
AMP_TASK_MSG_CALLBACK = 0, /* default JSE callback */
AMP_TASK_MSG_EXIT = 1,
AMP_TASK_MSG_TYPE_M... | YifuLiu/AliOS-Things | components/amp/main/amp_task.h | C | apache-2.0 | 1,225 |
// The driver for DS18B20 chip, it is a temperature sensor.
// Require libjs/lib/onewire.js module.
var onewire = require('onewire');
var DS18B20Dev;
var start_flag = 0;
/* Init DS18B20
*
* GPIO's options are configured in app.json. Specify the ID, e.g. GPIO below to init DS18B20.
{
"version": "1.0.0",
"i... | YifuLiu/AliOS-Things | components/amp/modules/DS18B20.js | JavaScript | apache-2.0 | 1,792 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
/*
The driver for AP3216C chip, The AP3216C is an integrated ALS & PS module
that includes a digital ambient light sensor [ALS], a proximity sensor [PS],
and an IR LED in a single package.
*/
/*
添加如下配置到app.json中:
"ap3216c": {
"type": "... | YifuLiu/AliOS-Things | components/amp/modules/ap3216c.js | JavaScript | apache-2.0 | 14,703 |
// The driver for mpu6050 chip, it is a temperature and humidity sensor.
/*
添加如下配置到app.json中:
"mpu6050": {
"type": "I2C",
"port": 1,
"addrWidth": 7,
"freq": 100000,
"mode": "master",
"devAddr": 105
}
*/
// Require libjs/lib/i2c.js ... | YifuLiu/AliOS-Things | components/amp/modules/mpu6050.js | JavaScript | apache-2.0 | 10,243 |
// The driver for qlc5883 chip, it is a temperature and humidity sensor.
var x_max, x_min, z_min, y_max, y_min, z_max;
var addr;
var mode;
var rate;
var range;
var oversampling;
var INT16_MIN = (-32767-1)
var INT16_MAX = 32767
/* Register numbers */
var QMC5883L_X_LSB = 0
var QMC5883L_X_MSB = 1
var QMC5883L_Y... | YifuLiu/AliOS-Things | components/amp/modules/qlc5883.js | JavaScript | apache-2.0 | 7,845 |
const SET_SCAN_DIR = 0xc0
const LOW_COLUMN_ADDRESS = 0x00
const HIGH_COLUMN_ADDRESS = 0x10
const SET_PAGE_ADDRESS = 0xB0
const SET_CONTRAST = 0x81
const SET_ENTIRE_ON = 0xa4
const SET_NORM_INV = 0xa6
const SET_DISP = 0xae
const SET_MEM_ADDR = 0x20
const SET_DISP_START_LINE = 0x40
const SET_SEG_REMAP = 0xa0
const SET_MU... | YifuLiu/AliOS-Things | components/amp/modules/sh1106.js | JavaScript | apache-2.0 | 7,456 |
// The driver for Si7006 chip, it is a temperature and humidity sensor.
// The register address in Si7006 controller.
var Si7006_MEAS_REL_HUMIDITY_MASTER_MODE = 0xE5;
var Si7006_MEAS_REL_HUMIDITY_NO_MASTER_MODE = 0xF5;
var Si7006_MEAS_TEMP_MASTER_MODE = 0xE3;
var Si7006_MEAS_TEMP_NO_MASTER_MODE =... | YifuLiu/AliOS-Things | components/amp/modules/si7006.js | JavaScript | apache-2.0 | 3,600 |
// The driver for spl06 chip, it is a temperature and humidity sensor.
/*
添加如下配置到app.json中:
"spl06": {
"type": "I2C",
"port": 1,
"addrWidth": 7,
"freq": 400000,
"mode": "master",
"devAddr": 119
}
*/
// Require libjs/lib/i2c.js modu... | YifuLiu/AliOS-Things | components/amp/modules/spl06.js | JavaScript | apache-2.0 | 12,554 |
TARGET = libservices.a
MODULE = services
MOD_SOURCES += \
app_mgr/app_message.c \
app_mgr/app_mgr.c \
app_mgr/app_management_center.c \
app_mgr/app_upgrade.c
MOD_SOURCES += \
board_mgr/board_info.c \
board_mgr/board_mgr.c
MOD_SOURCES += \
recovery/recovery.c \
recovery/ymodem.c
MOD_SOURCES += \
am... | YifuLiu/AliOS-Things | components/amp/services/Makefile | Makefile | apache-2.0 | 2,048 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "aos/kernel.h"
#include "aos/kv.h"
#include "amp_boot.h"
#define MOD_STR "amp_boot"
#define AMP_BOOT_WAIT_TIME 1000
#define AMP_BOOT_MAX_KV_LEN 256
#define AMP_BOOT_KV_VALUE_END_STR "[amp_value_end]\n"
static char g_amp_boot_sync[] = "amp_boo... | YifuLiu/AliOS-Things | components/amp/services/amp_boot/amp_boot.c | C | apache-2.0 | 5,395 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#ifndef AMP_BOOT_H
#define AMP_BOOT_H
#include <stdio.h>
#include <string.h>
#include "stdint.h"
#include "stdbool.h"
#include "amp_platform.h"
#include "amp_defines.h"
#include "amp_config.h"
#include "aos_system.h"
#include "aos_network.h"
#include "ao... | YifuLiu/AliOS-Things | components/amp/services/amp_boot/amp_boot.h | C | apache-2.0 | 506 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "amp_boot.h"
static amp_boot_cmd_t g_amp_boot_cmd[] = {
[AMP_BOOT_CMD_EXIT] = {
"cmd_exit"
},
[AMP_BOOT_CMD_QUERY_IMEI] = {
"cmd_query_imei"
},
[AMP_BOOT_CMD_QUERY_SEC] = {
"cmd_query_sec"
},
[... | YifuLiu/AliOS-Things | components/amp/services/amp_boot/amp_boot_cmd.c | C | apache-2.0 | 1,332 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#ifndef AMP_BOOT_CMD_H
#define AMP_BOOT_CMD_H
enum {
AMP_BOOT_CMD_NULL,
AMP_BOOT_CMD_EXIT,
AMP_BOOT_CMD_QUERY_IMEI,
AMP_BOOT_CMD_QUERY_SEC,
AMP_BOOT_CMD_FLASH_SEC,
AMP_BOOT_CMD_FLASH_JS,
AMP_BOOT_CMD_FLASH_KV,
AMP_BOOT_CMD... | YifuLiu/AliOS-Things | components/amp/services/amp_boot/amp_boot_cmd.h | C | apache-2.0 | 529 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "amp_config.h"
#include "amp_utils.h"
#include "aos_system.h"
#include "amp_defines.h"
#include "aos_hal_uart.h"
#include "aos_hal_gpio.h"
#include "aos/kernel.h"
#i... | YifuLiu/AliOS-Things | components/amp/services/amp_boot/amp_boot_recovery.c | C | apache-2.0 | 5,554 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#ifndef AMP_RECOVERY_H
#define AMP_RECOVERY_H
#include <stddef.h>
#include <stdint.h>
#include "amp_config.h"
/* recovery switch & status led. default for esp32 */
#ifndef AMP_REC_UART
#define AMP_REC_UART 2
#endif
#ifndef AMP_STATUS_IO
#define AMP_STA... | YifuLiu/AliOS-Things | components/amp/services/amp_boot/amp_boot_recovery.h | C | apache-2.0 | 964 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "amp_boot.h"
#include "amp_board_config.h"
#ifdef AMP_VUART_PORT
static vuart_dev_t g_boot_vuart = {0};
#else
static uart_dev_t g_boot_uart = {0};
#endif
void amp_boot_uart_send_byte(unsigned char c)
{
#ifdef AMP_VUART_PORT
if ((aos_hal_vua... | YifuLiu/AliOS-Things | components/amp/services/amp_boot/amp_boot_uart.c | C | apache-2.0 | 3,126 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#ifndef AMP_BOOT_UART_H
#define AMP_BOOT_UART_H
void amp_boot_uart_send_byte(unsigned char c);
void amp_boot_uart_send_str(char *str);
unsigned char amp_boot_uart_recv_byte(unsigned char *c);
int amp_boot_uart_recv_line(char *str_line, int lens, int time... | YifuLiu/AliOS-Things | components/amp/services/amp_boot/amp_boot_uart.h | C | apache-2.0 | 399 |
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#include "amp_boot.h"
#define MOD_STR "AMP_YMODEM"
#define YMODEM_OK 0
#define YMODEM_ERR (-1)
#define YMODEM_FILE_TOOBIG (-2)
#define YMODEM_SOH 0x01
#define YMODEM_STX 0x02
#define YMODEM_EOT 0x04
#define YMODEM_ACK 0x06
#define YMODE... | YifuLiu/AliOS-Things | components/amp/services/amp_boot/amp_boot_ymodem.c | C | apache-2.0 | 10,249 |
#include "stdlib.h"
#include "stdint.h"
#include "string.h"
#include "aos_system.h"
#include "amp_memmgt.h"
typedef struct amp_memmgt_rec_stru_tag {
void *ptr;
unsigned int size;
unsigned int lr;
unsigned int seq;
struct amp_memmgt_rec_stru_tag *next;
struct amp_memmgt_rec_stru_tag *prev;
} amp... | YifuLiu/AliOS-Things | components/amp/services/amp_memmgt/amp_memmgt.c | C | apache-2.0 | 8,777 |
/*!
* @file amp_memmgt.h
*
* Copyright (C) 2015-2021 Alibaba Group Holding Limited
*/
#ifndef _AMP_MEMMGT_H_
#define _AMP_MEMMGT_H_
#include "stdio.h"
#include "stdlib.h"
#include "stdint.h"
//#define MEMMGT_MEM_SIZE_CHECK
//#define MEMMGT_MEM_DBG_STATIC
//#define MEMMGT_MEM_TRACE
#define MEMMGT_TOTAL_PT_NUM 2
... | YifuLiu/AliOS-Things | components/amp/services/amp_memmgt/amp_memmgt.h | C | apache-2.0 | 2,398 |
#include "amp_memmgt.h"
#include "aos_system.h"
void amp_memory_init()
{
static int memory_initialized = 0;
if(0 == memory_initialized) {
amp_memmgt_config_t config;
memset(&config, 0, sizeof(config));
config.malloc_fn = aos_malloc;
config.realloc_fn = aos_realloc;
conf... | YifuLiu/AliOS-Things | components/amp/services/amp_memmgt/amp_memory.c | C | apache-2.0 | 1,138 |
/*!
* @file amp_memory.h
*
* Copyright (C) 2015-2021 Alibaba Group Holding Limited
*/
#ifndef _AMP_MEMORY_H_
#define _AMP_MEMORY_H_
void amp_memory_init();
void *amp_malloc(unsigned int size);
void amp_free(void *ptr);
void *amp_calloc(unsigned int nitems, unsigned int size);
void *amp_realloc(void *ptr, unsigned... | YifuLiu/AliOS-Things | components/amp/services/amp_memmgt/amp_memory.h | C | apache-2.0 | 421 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <string.h>
#include "amp_utils.h"
#include "amp_defines.h"
#include "aos_system.h"
#define MOD_STR "AMP_UTILS"
static AOS_SYSTEM_VERSION aos_version = {0};
unsigned char hex2num(unsigned char ch)
{
if (ch >= 'a') {
... | YifuLiu/AliOS-Things | components/amp/services/amp_utils/amp_utils.c | C | apache-2.0 | 5,254 |
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#ifndef AMP_UTILS_H
#define AMP_UTILS_H
#if defined(__cplusplus)
extern "C" {
#endif
#define AOS_VERSION_LENGTH 32
typedef struct {
char userjs[AOS_VERSION_LENGTH];
char app[AOS_VERSION_LENGTH];
char kernel[AOS_VERSION_LENGTH];
char syst... | YifuLiu/AliOS-Things | components/amp/services/amp_utils/amp_utils.h | C | apache-2.0 | 1,254 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include "aos/kernel.h"
#include "aos/vfs.h"
#include "amp_platform.h"
#include "amp_config.h"
#include "amp_memory.h"
#include "aos_system.h"
#include "aos_fs.h"
#include "aos_tcp.h"
#include "amp_task.h"
#include "amp_errno.h"
#include "amp_defines.h"
#... | YifuLiu/AliOS-Things | components/amp/services/app_mgr/app_mgr.c | C | apache-2.0 | 22,760 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#ifndef APP_MGR_H
#define APP_MGR_H
#include <stdio.h>
#include <string.h>
// #include <unistd.h>
/* complete = 0 success, 1 check success(EOF), -1 check failed */
typedef int (*write_js_cb_t)(const char *filename, int32_t file_size,
... | YifuLiu/AliOS-Things | components/amp/services/app_mgr/app_mgr.h | C | apache-2.0 | 1,420 |
/*
* Copyright (C) 2015-2021 Alibaba Group Holding Limited
*/
#include "aos/kernel.h"
#include "amp_platform.h"
#include "aos_system.h"
#include "amp_defines.h"
#include "amp_utils.h"
#include "app_mgr.h"
#include "app_upgrade.h"
#include "ota_agent.h"
#include "aiot_state_api.h"
#define MOD_STR "APP_UPGRADE"
stat... | YifuLiu/AliOS-Things | components/amp/services/app_mgr/app_upgrade.c | C | apache-2.0 | 10,875 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#ifndef APP_UPGRADE_H
#define APP_UPGRADE_H
#include <stdint.h>
#define AMP_OTA_MODULE_NAME "jsapp"
#define SUBDEV_FILE_PATH AMP_FS_ROOT_DIR"/pack.bin"
#define JS_JSON_PATH AMP_FS_ROOT_DIR"/js.json"
#define OS_APP_PATH AMP_FS_ROOT_DIR"/o... | YifuLiu/AliOS-Things | components/amp/services/app_mgr/app_upgrade.h | C | apache-2.0 | 550 |
/*
* Copyright (C) 2015-2021 Alibaba Group Holding Limited
*/
#include "amp_platform.h"
#include "aos_system.h"
#include "aos_ota.h"
#include "amp_defines.h"
#include "amp_task.h"
#include "app_mgr.h"
#include "app_upgrade.h"
#include "ota_agent.h"
#include "ota_import.h"
// #include "ota_hal_os.h"
#include "aiot_st... | YifuLiu/AliOS-Things | components/amp/services/app_mgr/app_upgrade_adapt.c | C | apache-2.0 | 5,642 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#define CONFIG_LOGMACRO_DETAILS
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "board_info.h"
#include "board_mgr.h"
#ifdef AMP_KV_ENABLE
#include "aos/kv.h"
#endif
int8_t board_setDeviceInfo(char *deviceKey, ch... | YifuLiu/AliOS-Things | components/amp/services/board_mgr/board_info.c | C | apache-2.0 | 1,906 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#ifndef BE_BOARD_INFO_H
#define BE_BOARD_INFO_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define DEVICE_KEY_TAG "DEVICE_KEY"
#define DEVICE_NAME_TAG "DEVICE_NAME"
#define DEVICE_SECRET_TAG "DEVICE_SECRET"
/**
* set config info of th... | YifuLiu/AliOS-Things | components/amp/services/board_mgr/board_info.h | C | apache-2.0 | 1,029 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#ifndef BE_BOARD_MARKER_H
#define BE_BOARD_MARKER_H
#ifdef __cplusplus
extern "C" {
#endif
/* app.json configuration */
#define APP_CONFIG_PAGES "pages"
#define APP_CONFIG_IO "io"
#define APP_CONFIG_AUDIO "audio"
#define APP_CONFIG_NET "... | YifuLiu/AliOS-Things | components/amp/services/board_mgr/board_marker.h | C | apache-2.0 | 3,088 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#define CONFIG_LOGMACRO_DETAILS
#include "amp_platform.h"
#include "amp_config.h"
#include "aos_system.h"
#include "aos_fs.h"
#include "amp_defines.h"
#include "board_mgr.h"
#include "board_marker.h"
//#include "core_list.h"
#include "cJSON.h"
#ifdef J... | YifuLiu/AliOS-Things | components/amp/services/board_mgr/board_mgr.c | C | apache-2.0 | 42,966 |
/*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#ifndef BE_BOARD_MGR_H
#define BE_BOARD_MGR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
typedef enum addon_module {
MODULE_GPIO = 0x1324,
MODULE_UART,
MODULE_I2C,
MODULE_PWM,
MODULE_ADC,
MODULE_DAC,
MODULE_... | YifuLiu/AliOS-Things | components/amp/services/board_mgr/board_mgr.h | C | apache-2.0 | 2,689 |
var net = require('net');
var HOST = '100.81.240.32';
var PORT = 50000;
var server = net.createServer();
server.listen(PORT, HOST);
// console.log(server);
console.log('Server listening on ' + HOST + ':' + PORT);
server.on('connection', function(sock) {
console.log('CONNECTED: ' + sock.remoteAddress +':'+ sock.rem... | YifuLiu/AliOS-Things | components/amp/test/host/tcpServer.js | JavaScript | apache-2.0 | 796 |
const dgram = require('dgram');
const server = dgram.createSocket('udp4'); //创建udp服务器
//以下server.on 都是在监听不同信号
server.on('close',()=>{
console.log('socket已关闭');
});
server.on('error',(err)=>{
console.log(err);
});
server.on('listening',()=>{
console.log('socket正在监听中...');
});
server.on('message',(msg,ri... | YifuLiu/AliOS-Things | components/amp/test/host/udpServer.js | JavaScript | apache-2.0 | 645 |
/*
Please add this section into app.json when run this script as app.js.
This configuration is designed for haas100 edu k1.
{
"version": "1.0.0",
"io": {
"DS18B20": {
"type": "GPIO",
"port": 4,
"dir": "output",
"pull": "pullup"
}
},
"debu... | YifuLiu/AliOS-Things | components/amp/test/test_DS18B20.js | JavaScript | apache-2.0 | 663 |
/*
Please add this section into app.json when run this script as app.js.
This configuration is designed for HaaS EDU K1.
"ap3216c": {
"type": "I2C",
"port": 1,
"addrWidth": 7,
"freq": 100000,
"mode": "master",
"devAddr": 30
}
*/
console.log('testing ap3216c...');
var ap3216c = require('./ap321... | YifuLiu/AliOS-Things | components/amp/test/test_ap3216c.js | JavaScript | apache-2.0 | 857 |
/* 本测试case,测试fs的接口,接口返回值等 */
console.log('testing fs...');
// 测试 fs 模块
var fs = require('fs');
if(!(fs && fs.writeSync && fs.readSync && fs.unlinkSync)){
throw new Error("[failed] require(\'fs\')");
}
console.log('[success] require(\'fs\')');
// 测试 fs 写入
if(fs.writeSync('./aiot.txt', 'amp')){
throw new Error(... | YifuLiu/AliOS-Things | components/amp/test/test_fs.js | JavaScript | apache-2.0 | 1,033 |
console.log('http: testing http...');
var http = require('http');
if (!(http && http.request)) {
throw new Error("http: [failed] require(\'http\')");
}
console.log('http: [success] require(\'http\')');
var request_url = 'http://appengine.oss-cn-hangzhou.aliyuncs.com/httpTest.txt';
var defaultMessage = 'this is ... | YifuLiu/AliOS-Things | components/amp/test/test_http.js | JavaScript | apache-2.0 | 659 |
console.log('iot: testing iot...');
var iot = require('iot');
if (!(iot && iot.device)) {
throw new Error("iot: [failed] require(\'iot\')");
}
console.log('iot: [success] require(\'iot\')');
var productKey = 'a10h6IdruJf';
var deviceName = 'nodemcu_02';
var deviceSecret = 'StFYN4UigwDiRbhRwVFkFIKsEqpuaHKu';
var... | YifuLiu/AliOS-Things | components/amp/test/test_iot.js | JavaScript | apache-2.0 | 2,535 |
/* 本测试case,测试kv的接口,接口返回值等 */
console.log('testing kv...');
// 测试 kv 模块
var kv = require('kv');
if(!(kv && kv.setStorageSync && kv.getStorageSync && kv.removeStorageSync)){
throw new Error("[failed] require(\'kv\')");
}
console.log('[success] require(\'kv\')');
// 测试 kv 写入
if(kv.setStorageSync('aiot', 'amp')){
... | YifuLiu/AliOS-Things | components/amp/test/test_kv.js | JavaScript | apache-2.0 | 1,257 |
/*
Please add this section into app.json when run this script as app.js.
This configuration is designed for haas100 edu k1.
"spl06": {
"type": "I2C",
"port": 1,
"addrWidth": 7,
"freq": 400000,
"mode": "master",
"devAddr": 105
}
*/
console.log('testing mpu6050...');
var mpu6050 = require('./mpu... | YifuLiu/AliOS-Things | components/amp/test/test_mpu6050.js | JavaScript | apache-2.0 | 678 |
function ArrayToString(fileData) {
var dataString = "";
for (var i = 0; i < fileData.length; i++) {
dataString += String.fromCharCode(fileData[i]);
}
return dataString;
}
console.log('mqtt: testing mqtt...');
var mqtt = require('mqtt');
if (!(mqtt && mqtt.createClient)) {
throw new Error(... | YifuLiu/AliOS-Things | components/amp/test/test_mqtt.js | JavaScript | apache-2.0 | 4,243 |