diff --git a/boards/default_src/micropython/blocks/iot.js b/boards/default_src/micropython/blocks/iot.js index 69931a46..e909daba 100644 --- a/boards/default_src/micropython/blocks/iot.js +++ b/boards/default_src/micropython/blocks/iot.js @@ -332,6 +332,13 @@ export const IOT_MIXIO_PUBLISH = { .appendField(Blockly.Msg.MIXLY_EMQX_PUBLISH_TOPIC); this.appendValueInput('MSG') .appendField(Blockly.Msg.HTML_BODY); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_Service_quality_display) + .appendField(new Blockly.FieldDropdown([ + [Blockly.Msg.MIXLY_AT_MOST_ONCE,"0"], + [Blockly.Msg.MIXLY_AT_LEAST_ONCE,"1"], + [Blockly.Msg.MIXLY_ONLY_ONCE,"2"] + ]),"quality") this.setInputsInline(true); this.setPreviousStatement(true); this.setNextStatement(true); diff --git a/boards/default_src/micropython/generators/iot.js b/boards/default_src/micropython/generators/iot.js index 9405df52..94f49720 100644 --- a/boards/default_src/micropython/generators/iot.js +++ b/boards/default_src/micropython/generators/iot.js @@ -90,8 +90,9 @@ export const iot_mixio_connect = function (_, generator) { export const IOT_MIXIO_PUBLISH = function (_, generator) { var topic = generator.valueToCode(this, 'TOPIC', generator.ORDER_ATOMIC); var msg = generator.valueToCode(this, 'MSG', generator.ORDER_ATOMIC); + var q = this.getFieldValue('quality'); generator.definitions_['import_mixiot'] = "import mixiot"; - var code = 'mqtt_client.publish(MQTT_USR_PRJ + ' + topic + ', ' + msg + ')\n'; + var code = 'mqtt_client.publish(MQTT_USR_PRJ + ' + topic + ', ' + msg + ', qos='+ q +')\n'; return code; } diff --git a/boards/default_src/python/blocks/storage.js b/boards/default_src/python/blocks/storage.js index 11330b5c..70e932ef 100644 --- a/boards/default_src/python/blocks/storage.js +++ b/boards/default_src/python/blocks/storage.js @@ -26,7 +26,15 @@ export const storage_fileopen = { [Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_READ, 'r'], [Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE, 'w'], [Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ, 'rb'], - [Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE, 'wb'] + [Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE, 'wb'], + [Blockly.Msg.MIXLY_ADD, 'a'], + [Blockly.Msg.MATH_BIN + Blockly.Msg.MIXLY_ADD, 'ab'], + [Blockly.Msg.MIXLY_R_W ,'r+'], + [Blockly.Msg.MATH_BIN + Blockly.Msg.MIXLY_R_W ,'rb+'], + [Blockly.Msg.MIXLY_W_R ,'w+'], + [Blockly.Msg.MATH_BIN + Blockly.Msg.MIXLY_W_R ,'wb+'], + [Blockly.Msg.MIXLY_A_R ,'a+'], + [Blockly.Msg.MATH_BIN + Blockly.Msg.MIXLY_A_R ,'ab+'] ]), 'MODE'); this.appendValueInput("FILE") .appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_AS); diff --git a/common/msg/blockly/en.js b/common/msg/blockly/en.js index cdcdac05..a568cfb0 100644 --- a/common/msg/blockly/en.js +++ b/common/msg/blockly/en.js @@ -3978,4 +3978,12 @@ En.MIXLY_MICROPHONE_AMPLIFICATION = 'microphone amplification'; En.MIXLY_MUSIC_VOLUME_SET = 'set music volume'; En.MIXLY_HOTSPOT= 'hot spot'; En.MIXLY_NAME = 'name'; +En.MIXLY_Service_quality_display= "service quality", +En.MIXLY_AT_MOST_ONCE= "At most once", +En.MIXLY_AT_LEAST_ONCE= "At least once", +En.MIXLY_ONLY_ONCE= "Only once", +En.MIXLY_ADD= "Append", +En.MIXLY_R_W= "Readable and Writable, Error if File Does Not Exist", +En.MIXLY_W_R= "Readable and Writable, Create if File Does Not Exist", +En.MIXLY_A_R= "Appendable and Writable, Create if File Does Not Exist" })(); diff --git a/common/msg/blockly/zh-hans.js b/common/msg/blockly/zh-hans.js index d15f443c..c5023d3a 100644 --- a/common/msg/blockly/zh-hans.js +++ b/common/msg/blockly/zh-hans.js @@ -4137,4 +4137,12 @@ ZhHans.MIXLY_MICROPHONE_AMPLIFICATION = '麦克风放大倍数'; ZhHans.MIXLY_MUSIC_VOLUME_SET = '音量调节'; ZhHans.MIXLY_HOTSPOT= '热点'; ZhHans.MIXLY_NAME = '名称'; +ZhHans.MIXLY_Service_quality_display = '服务质量'; +ZhHans.MIXLY_AT_MOST_ONCE = '至多一次'; +ZhHans.MIXLY_AT_LEAST_ONCE = '至少一次'; +ZhHans.MIXLY_ONLY_ONCE = '仅一次'; +ZhHans.MIXLY_ADD = '追加'; +ZhHans.MIXLY_R_W ='可读可写,文件若不存在就报错'; +ZhHans.MIXLY_W_R = '可读可写,文件若不存在就创建'; +ZhHans.MIXLY_A_R = '可追加可写,文件若不存在就创建'; })(); \ No newline at end of file diff --git a/common/msg/blockly/zh-hant.js b/common/msg/blockly/zh-hant.js index 846b81e5..01a58bfe 100644 --- a/common/msg/blockly/zh-hant.js +++ b/common/msg/blockly/zh-hant.js @@ -4132,4 +4132,12 @@ ZhHant.MIXLY_MICROPHONE_AMPLIFICATION = '麥克風放大倍數'; ZhHant.MIXLY_MUSIC_VOLUME_SET = '音量調節'; ZhHant.MIXLY_HOTSPOT= '熱點'; ZhHant.MIXLY_NAME = '名稱'; +ZhHant.MIXLY_Service_quality_display= "服務質量"; +ZhHant.MIXLY_AT_MOST_ONCE= "至多一次"; +ZhHant.MIXLY_AT_LEAST_ONCE= "至少一次"; +ZhHant.MIXLY_ONLY_ONCE= "僅一次"; +ZhHant.MIXLY_ADD= "追加"; +ZhHant.MIXLY_R_W= "可讀可寫,文件若不存在就報錯"; +ZhHant.MIXLY_W_R= "可讀可寫,文件若不存在就創建"; +ZhHant.MIXLY_A_R= "可追加可寫,文件若不存在就創建"; })();