This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 元のプログラム | |
| void BLEServer::handleGATTServerEvent( | |
| esp_gatts_cb_event_t event, | |
| esp_gatt_if_t gatts_if, | |
| esp_ble_gatts_cb_param_t* param) { | |
| // 省略 | |
| case ESP_GATTS_CONNECT_EVT: { | |
| m_connId = param->connect.conn_id; // Save the connection id. | |
| if (m_pServerCallbacks != nullptr) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void onConnect(BLEServer* pServer, esp_ble_gatts_cb_param_t* param) { | |
| esp_ble_conn_update_params_t conn_params = {0}; | |
| memcpy(conn_params.bda, param->connect.remote_bda, sizeof(esp_bd_addr_t)); | |
| conn_params.latency = 0; | |
| conn_params.max_int = 0x20; // max_int = 0x20*1.25ms = 40ms | |
| conn_params.min_int = 0x10; // min_int = 0x10*1.25ms = 20ms | |
| conn_params.timeout = 400; // timeout = 400*10ms = 4000ms | |
| //start sent the update connection parameters to the peer device. | |
| esp_ble_gap_update_conn_params(&conn_params); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Obniz = require("obniz"); | |
| const obniz = new Obniz("obniz_ID"); | |
| obniz.onconnect = async () => { | |
| const bme280 = obniz.wired("BME280", {vio:6, vcore:5, gnd:4, csb:3, sdi: 2, sck: 1, sdo:0 }); | |
| await bme280.applyCalibration(); | |
| const val = await bme280.getAllWait(); | |
| console.log(val); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Obniz = require("obniz"); | |
| const ambient = require('ambient-lib'); | |
| const obniz = new Obniz("obniz_ID"); | |
| const channelId = 100; | |
| const writeKey = 'writeKey'; | |
| const get_data_send = async (bme280) => { | |
| const val = await bme280.getAllWait(); | |
| console.log(val); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Obniz = require("obniz"); | |
| const ambient = require('ambient-lib'); | |
| const obniz = new Obniz("obniz-ID"); | |
| const channelId = 100; | |
| const writeKey = 'writeKey'; | |
| // 熱中症の危険度判定 | |
| // 0: 注意、1: 警戒、2: 厳重警戒、3: 危険 | |
| // 日本生気象学会「日常生活における熱中症予防指針」Ver.3を元に作成 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from m5stack import * | |
| import units # センサーユニットのライブラリーunitsをインポート | |
| import time | |
| import ambient # Ambientライブラリーをインポート | |
| machine.DAC(machine.Pin(25)).write(0) # スピーカーをオフにする | |
| angle = units.ANGLE() # Angleセンサーのインスタンスを作る | |
| am = ambient.Ambient(100, 'writeKey') # Ambientのインスタンスを作る | |
| lcd.clear() # LCDを消去する |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from m5stack import * | |
| import units # センサーユニットのライブラリーunitsをインポート | |
| import machine | |
| from machine import Pin | |
| import time | |
| import ambient # Ambientライブラリーをインポート | |
| dark = False | |
| nmoves = 0 # 動いた回数 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setAdvData(BLEAdvertising *pAdvertising) { | |
| bme280.get_sensor_data(&data); | |
| Serial.printf("temp: %.1f, humid: %.1f, press: %.1f\r\n", data.temperature, data.humidity, data.pressure / 100); | |
| uint16_t temp = (uint16_t)(data.temperature * 100); | |
| uint16_t humid = (uint16_t)(data.humidity * 100); | |
| uint16_t press = (uint16_t)(data.pressure / 10); | |
| BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); | |
| oAdvertisementData.setFlags(0x06); // BR_EDR_NOT_SUPPORTED | LE General Discoverable Mode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from machine import UART | |
| import micropyGPS | |
| import utime, gc, _thread | |
| from m5stack import lcd | |
| from math import radians, sin, cos | |
| gps_s = UART(2, tx=17, rx=16, baudrate=9600, timeout=200, buffer_size=256, lineend='\r\n') | |
| micropyGPS.MicropyGPS.supported_sentences.update({'GNGSA': micropyGPS.MicropyGPS.gpgsa}) | |
| gps = micropyGPS.MicropyGPS(9, 'dd') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ScanDelegate(DefaultDelegate): | |
| def handleDiscovery(self, scanEntry, isNewDev, isNewData): | |
| print(strftime("%Y-%m-%d %H:%M:%S", gmtime()), scanEntry.addr, scanEntry.getScanData()) | |
| sys.stdout.flush() | |
| scanner = Scanner().withDelegate(ScanDelegate()) | |
| scanner.scan(10.0, passive=True) |