Created
September 16, 2018 07:04
-
-
Save TakehikoShimojima/465738be65eb0043cb2fc0f1f185c756 to your computer and use it in GitHub Desktop.
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 | |
| std::string strServiceData = ""; | |
| strServiceData += (char)0x0a; // 長さ | |
| strServiceData += (char)0xff; // AD Type 0xFF: Manufacturer specific data | |
| strServiceData += (char)0xff; // Test manufacture ID low byte | |
| strServiceData += (char)0xff; // Test manufacture ID high byte | |
| strServiceData += (char)seq; // シーケンス番号 | |
| strServiceData += (char)(temp & 0xff); // 温度の下位バイト | |
| strServiceData += (char)((temp >> 8) & 0xff); // 温度の上位バイト | |
| strServiceData += (char)(humid & 0xff); // 湿度の下位バイト | |
| strServiceData += (char)((humid >> 8) & 0xff); // 湿度の上位バイト | |
| strServiceData += (char)(press & 0xff); // 気圧の下位バイト | |
| strServiceData += (char)((press >> 8) & 0xff); // 気圧の上位バイト | |
| oAdvertisementData.addData(strServiceData); | |
| pAdvertising->setAdvertisementData(oAdvertisementData); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment