Update BLE Settings and Storage Blocks

This commit is contained in:
Juri 2022-02-28 22:41:38 +01:00
parent f54552840f
commit c6eacb4046
12 changed files with 6803 additions and 186 deletions

View File

@ -1,8 +1,7 @@
{ {
"name": "{0} block", "name": "{0} block",
"dependencies": { "dependencies": {
"core": "file:../core", "core": "file:../core"
"radio": "file:../radio"
}, },
"description": "", "description": "",
"files": [ "files": [

View File

@ -32,16 +32,6 @@
} }
}, },
"userConfigs": [ "userConfigs": [
{
"description": "Disable Bluetooth Event Service",
"config": {
"microbit-dal": {
"bluetooth": {
"event_service": 0
}
}
}
}
] ]
} }
} }

View File

@ -424,7 +424,7 @@
"images": "Creation, manipulation and display of LED images.", "images": "Creation, manipulation and display of LED images.",
"images.createBigImage": "Creates an image with 2 frames.", "images.createBigImage": "Creates an image with 2 frames.",
"images.createImage": "Creates an image that fits on the LED screen.", "images.createImage": "Creates an image that fits on the LED screen.",
"input": "Events and data from sensors\n\r\nEvents and data from sensors", "input": "Events and data from sensors",
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)", "input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
"input.acceleration|param|dimension": "x, y, or z dimension, eg: Dimension.X", "input.acceleration|param|dimension": "x, y, or z dimension, eg: Dimension.X",
"input.assumeCalibrationCompass": "Obsolete, compass calibration is automatic.", "input.assumeCalibrationCompass": "Obsolete, compass calibration is automatic.",
@ -688,28 +688,16 @@
"storage": "Provides access to persistent storage functionality.\n\nProvides access to persistent storage functionality.", "storage": "Provides access to persistent storage functionality.\n\nProvides access to persistent storage functionality.",
"storage.getNumber": "Reads a key value pair from the non volatile storage as a number", "storage.getNumber": "Reads a key value pair from the non volatile storage as a number",
"storage.getNumber|param|key": "the key for accesing the value", "storage.getNumber|param|key": "the key for accesing the value",
"storage.getString": "Reads a key value pair from the non volatile storage as a string",
"storage.getString|param|key": "the key for accesing the value",
"storage.getValue": "Reads a key value pair from the non volatile storage",
"storage.getValueInt": "Reads a key value pair from the non volatile storage", "storage.getValueInt": "Reads a key value pair from the non volatile storage",
"storage.getValueInt|param|key": "the key for accesing the value", "storage.getValueInt|param|key": "the key for accesing the value",
"storage.getValue|param|key": "the key for accesing the value",
"storage.putNumber": "Saves a key value pair in the non volatile storage", "storage.putNumber": "Saves a key value pair in the non volatile storage",
"storage.putNumber|param|key": "the key for accesing the value", "storage.putNumber|param|key": "the key for accesing the value",
"storage.putNumber|param|value": "value to store", "storage.putNumber|param|value": "value to store",
"storage.putString": "Saves a key value pair in the non volatile storage",
"storage.putString|param|key": "the key for accesing the value",
"storage.putString|param|value": "value to store",
"storage.putValue": "Saves a key value pair in the non volatile storage",
"storage.putValueInt": "Saves a key value pair in the non volatile storage", "storage.putValueInt": "Saves a key value pair in the non volatile storage",
"storage.putValueInt|param|key": "the key for accesing the value", "storage.putValueInt|param|key": "the key for accesing the value",
"storage.putValueInt|param|value": "value to store", "storage.putValueInt|param|value": "value to store",
"storage.putValue|param|key": "the key for accesing the value", "storage.remove": "Removes a key value pair from the non volatile storage",
"storage.putValue|param|value": "value to store",
"storage.remove": "Reads a key value pair from the non volatile storage",
"storage.removeKeyInt": "Deletes the key from the non volatile storage", "storage.removeKeyInt": "Deletes the key from the non volatile storage",
"storage.removeKeyInt|param|key": "the key for accesing the value", "storage.removeKeyInt|param|key": "the key for accesing the value",
"storage.removeKeyStr": "Deletes the key from the non volatile storage",
"storage.removeKeyStr|param|key": "the key for accesing the value",
"storage.remove|param|key": "the key for accesing the value" "storage.remove|param|key": "the key for accesing the value"
} }

View File

@ -410,15 +410,10 @@
"serial.writeValue|block": "serial|write value %name|= %value", "serial.writeValue|block": "serial|write value %name|= %value",
"serial|block": "serial", "serial|block": "serial",
"storage.getNumber|block": "read from number %key", "storage.getNumber|block": "read from number %key",
"storage.getString|block": "read from string %key",
"storage.getValueInt|block": "get number from %key", "storage.getValueInt|block": "get number from %key",
"storage.getValue|block": "get number from %key",
"storage.putNumber|block": "Save into number %key a value of %value", "storage.putNumber|block": "Save into number %key a value of %value",
"storage.putString|block": "Save into string %key a value of %value",
"storage.putValueInt|block": "Put into %key a value of %value as Int", "storage.putValueInt|block": "Put into %key a value of %value as Int",
"storage.putValue|block": "Put into %key a value of %value as String",
"storage.removeKeyInt|block": "Clear number %key", "storage.removeKeyInt|block": "Clear number %key",
"storage.removeKeyStr|block": "Clear string %key",
"storage.remove|block": "remove %key", "storage.remove|block": "remove %key",
"storage|block": "storage", "storage|block": "storage",
"{id:category}AnalogInPin": "AnalogInPin", "{id:category}AnalogInPin": "AnalogInPin",

View File

@ -112,42 +112,32 @@
"optionalConfig": { "optionalConfig": {
"microbit-dal": { "microbit-dal": {
"bluetooth": { "bluetooth": {
"enabled": 1,
"pairing_mode": 1,
"private_addressing": 0, "private_addressing": 0,
"open": 1,
"security_level": null,
"whitelist": 1,
"advertising_timeout": 0, "advertising_timeout": 0,
"tx_power": 6, "tx_power": 6,
"dfu_service": 1, "dfu_service": 1,
"event_service": 1, "event_service": 0,
"device_info_service": 1, "device_info_service": 0
"eddystone_url": 1, },
"eddystone_uid": 1, "stack_size": 1280,
"open": 0, "gatt_table_size": "0x600",
"pairing_mode": 1, "panic_on_heap_full": 0,
"whitelist": 1, "debug": 0,
"security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM", "heap_debug": 0
"partial_flashing": 1
}
}
},
"userConfigs": [{
"description": "No Pairing Required: Anyone can connect via Bluetooth.",
"config": {
"microbit-dal": {
"bluetooth": {
"open": 1,
"whitelist": 0,
"security_level": null
}
}
} }
}, },
"userConfigs": [
{ {
"description": "JustWorks pairing (default): Pairing is automatic once the pairing is initiated.", "description": "Limit bluetooth access to BLE mode (A + B + Reset)",
"config": { "config": {
"microbit-dal": { "microbit-dal": {
"bluetooth": { "bluetooth": {
"open": 0, "enabled": 0
"whitelist": 1,
"security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM"
} }
} }
} }

26
libs/core/shims.d.ts vendored
View File

@ -1316,19 +1316,6 @@ declare namespace control {
declare namespace storage { declare namespace storage {
/**
* Saves a key value pair in the non volatile storage
* @param key the key for accesing the value
* @param value value to store
*/
//% weight=100 blockGap=16
//% block="Put into %key a value of %value as String"
//% blockId=storage_put_value_str
//%
//% group="Put"
//% blockHidden=true value.defl=0 shim=storage::putValue
function putValue(key: string, value?: string): void;
/** /**
* Saves a key value pair in the non volatile storage * Saves a key value pair in the non volatile storage
* @param key the key for accesing the value * @param key the key for accesing the value
@ -1342,17 +1329,6 @@ declare namespace storage {
//% blockHidden=true value.defl=0 shim=storage::putValueInt //% blockHidden=true value.defl=0 shim=storage::putValueInt
function putValueInt(key: string, value?: int32): void; function putValueInt(key: string, value?: int32): void;
/**
* Reads a key value pair from the non volatile storage
* @param key the key for accesing the value
*/
//% weight=100 blockGap=16
//% block="get number from %key"
//% blockId=storage_get_value
//% group="Get"
//% blockHidden=true shim=storage::getValue
function getValue(key: string): string;
/** /**
* Reads a key value pair from the non volatile storage * Reads a key value pair from the non volatile storage
* @param key the key for accesing the value * @param key the key for accesing the value
@ -1365,7 +1341,7 @@ declare namespace storage {
function getValueInt(key: string): int32; function getValueInt(key: string): int32;
/** /**
* Reads a key value pair from the non volatile storage * Removes a key value pair from the non volatile storage
* @param key the key for accesing the value * @param key the key for accesing the value
*/ */
//% weight=100 blockGap=16 //% weight=100 blockGap=16

View File

@ -4,22 +4,6 @@
* Provides access to persistent storage functionality. * Provides access to persistent storage functionality.
*/ */
namespace storage { namespace storage {
/**
* Saves a key value pair in the non volatile storage
* @param key the key for accesing the value
* @param value value to store
*/
//% weight=100 blockGap=16
//% block="Put into %key a value of %value as String"
//% blockId=storage_put_value_str
//% value.defl=0
//% group="Put"
//% blockHidden=true
void putValue(String key, String value) {
ManagedString managedKey = MSTR(key);
uBit.storage.put(managedKey, (uint8_t *)&value, sizeof(int));
}
/** /**
* Saves a key value pair in the non volatile storage * Saves a key value pair in the non volatile storage
* @param key the key for accesing the value * @param key the key for accesing the value
@ -36,27 +20,6 @@ namespace storage {
uBit.storage.put(managedKey, (uint8_t *)&value, sizeof(int)); uBit.storage.put(managedKey, (uint8_t *)&value, sizeof(int));
} }
/**
* Reads a key value pair from the non volatile storage
* @param key the key for accesing the value
*/
//% weight=100 blockGap=16
//% block="get number from %key"
//% blockId=storage_get_value
//% group="Get"
//% blockHidden=true
String getValue(String key) {
KeyValuePair* data = uBit.storage.get(MSTR(key));
String stored;
if(data == NULL) {
return mkString("", -1);
} else {
memcpy(&stored, data->value, sizeof(int));
delete data;
return stored;
}
}
/** /**
* Reads a key value pair from the non volatile storage * Reads a key value pair from the non volatile storage
* @param key the key for accesing the value * @param key the key for accesing the value
@ -79,7 +42,7 @@ namespace storage {
} }
/** /**
* Reads a key value pair from the non volatile storage * Removes a key value pair from the non volatile storage
* @param key the key for accesing the value * @param key the key for accesing the value
*/ */
//% weight=100 blockGap=16 //% weight=100 blockGap=16

View File

@ -15,7 +15,7 @@ enum StorageSlots {
s7 = 6, s7 = 6,
} }
let storagesStr = ['s1', 's2', 's3', 's4', 's5', 's6', 's7']; // let storagesStr = ['s1', 's2', 's3', 's4', 's5', 's6', 's7'];
let storagesInt = ['i1', 'i2', 'i3', 'i4', 'i5', 'i6', 'i7']; let storagesInt = ['i1', 'i2', 'i3', 'i4', 'i5', 'i6', 'i7'];
/** /**
@ -25,21 +25,6 @@ let storagesInt = ['i1', 'i2', 'i3', 'i4', 'i5', 'i6', 'i7'];
//% advanced=true //% advanced=true
namespace storage { namespace storage {
/**
* Saves a key value pair in the non volatile storage
* @param key the key for accesing the value
* @param value value to store
*/
//% weight=100 blockGap=16
//% block="Save into string %key a value of %value"
//% blockId=storage_put_string
//% value.shadowOptions.toString=true
//% group="Put"
export function putString(key: StorageSlots, value: string) : void {
putValue(storagesStr[key], value);
}
/** /**
* Saves a key value pair in the non volatile storage * Saves a key value pair in the non volatile storage
* @param key the key for accesing the value * @param key the key for accesing the value
@ -67,30 +52,6 @@ namespace storage {
return value / 100; return value / 100;
} }
/**
* Reads a key value pair from the non volatile storage as a string
* @param key the key for accesing the value
*/
//% weight=80 blockGap=16
//% block="read from string %key"
//% blockId=storage_get_string
//% group="Get"
export function getString(key: StorageSlots) : string {
return getValue(storagesStr[key]);
}
/**
* Deletes the key from the non volatile storage
* @param key the key for accesing the value
*/
//% weight=60 blockGap=16
//% block="Clear string %key"
//% blockId=storage_remove_key_string
//% group="Remove"
export function removeKeyStr(key: StorageSlots) : void {
remove(storagesStr[key]);
}
/** /**
* Deletes the key from the non volatile storage * Deletes the key from the non volatile storage
* @param key the key for accesing the value * @param key the key for accesing the value

View File

@ -1,5 +1,5 @@
{ {
"input": "Events and data from sensors\n\r\nEvents and data from sensors", "input": "Events and data from sensors",
"input.onLoudSound": "Registers an event that runs when a loud sound is detected", "input.onLoudSound": "Registers an event that runs when a loud sound is detected",
"input.setLoudSoundThreshold": "Sets the minimum threshold for a loud sound", "input.setLoudSoundThreshold": "Sets the minimum threshold for a loud sound",
"input.soundLevel": "gets the level of loudness from 0 (silent) to 255 (loud)\n\nReads the loudness through the microphone from 0 (silent) to 255 (loud)" "input.soundLevel": "gets the level of loudness from 0 (silent) to 255 (loud)\n\nReads the loudness through the microphone from 0 (silent) to 255 (loud)"

6800
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,8 @@
"keywords": [ "keywords": [
"JavaScript", "JavaScript",
"education", "education",
"microbit" "calliope",
"mini"
], ],
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -109,7 +109,7 @@
"useNewFunctions": true "useNewFunctions": true
}, },
"compileService": { "compileService": {
"yottaTarget": "calliope-mini-classic-gcc", "yottaTarget": "calliope-mini-classic-gcc@https://github.com/calliope-mini/target-calliope-mini-classic-gcc#v1.2.0-yotta",
"yottaCorePackage": "microbit", "yottaCorePackage": "microbit",
"githubCorePackage": "calliope-mini/microbit", "githubCorePackage": "calliope-mini/microbit",
"gittag": "v2.2.0-rc6-calliope.rc3-iss0.3", "gittag": "v2.2.0-rc6-calliope.rc3-iss0.3",