#c_lang#ble#bluetooth_low_energy#iot#nrf52#sensor#soil_moisture#soil_moisture_sensor
The b-parasite is a small, open-source device that checks soil moisture, air temperature, humidity, and light for your plants, using a simple coin cell battery that can last over two years. It works with popular smart home systems like Home Assistant and can send data wirelessly using Bluetooth or Zigbee. The device is easy to build or buy, comes with free designs and software, and can be protected with a 3D-printed case. This helps you keep your plants healthy by giving you clear, regular updates on their environment, so you know exactly when to water or adjust conditions[1][2][3].
https://github.com/rbaron/b-parasite
🚀 Вышел стабильный JavaScript движок от Google для Android
Новая стабильная библиотека Jetpack JavaScript Engine позволит разработчикам выполнять JS код в изолированной и ограниченной среде.
class MainActivity : ComponentActivity() {
// Теперь nullable, без lateinit
private var jsSandbox: JavaScriptSandbox? = null
private var jsIsolate: JavaScriptIsolate? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (!JavaScriptSandbox.isSupported()) {
Log.e("JS", "JavaScriptSandbox не поддерживается")
return
}
lifecycleScope.launch {
// Создаём и сохраняем в nullable-поле
jsSandbox = JavaScriptSandbox
.createConnectedInstanceAsync(applicationContext)
.await()
jsIsolate = jsSandbox?.createIsolate()
// При выполнении гарантируем, что jsIsolate != null
val result: String = jsIsolate
?.evaluateJavaScriptAsync(JS_SCRIPT_SCRING)
?.await()
?: "Ошибка: isolate не инициализирован"
Log.d("JS", "Результат выполнения: $result")
}
}
override fun onDestroy() {
super.onDestroy()
// Закрываем только если не null
jsIsolate?.close()
jsSandbox?.close()
}
}
#jetpack#js