diff --git a/TODO.md b/TODO.md index bef3149c..45e31164 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,12 @@ +* test reg reading/writing directly via bt to device * fix bluetooth update * add real messaging code/protobufs * use https://codelabs.developers.google.com/codelabs/jetpack-compose-basics/#4 to show service state * connect to bluetooth device automatically using minimum power +protoc -I=. --java_out /tmp ./mesh.proto + # Medium priority * remove secret google settings json before open sourcing diff --git a/app/build.gradle b/app/build.gradle index 0ddb520f..603c4263 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,6 +6,9 @@ apply plugin: 'com.google.gms.google-services' // Apply the Crashlytics Gradle plugin apply plugin: 'com.google.firebase.crashlytics' +// protobuf +apply plugin: 'com.google.protobuf' + android { compileSdkVersion 29 buildToolsVersion "29.0.2" @@ -41,6 +44,22 @@ android { } } +// per protobuf-gradle-plugin docs, this is recommended for android +protobuf { + protoc { + artifact = 'com.google.protobuf:protoc:3.9.0' + } + generateProtoTasks { + all().each { task -> + task.builtins { + java { + option "lite" + } + } + } + } +} + dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" @@ -52,6 +71,9 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + // You need to depend on the lite runtime library, not protobuf-java + implementation 'com.google.protobuf:protobuf-javalite:3.8.0' + // You also need to include the following Compose toolkit dependencies. implementation("androidx.compose:compose-runtime:$compose_version") implementation("androidx.ui:ui-framework:$compose_version") diff --git a/app/src/main/proto/mesh.proto b/app/src/main/proto/mesh.proto new file mode 100644 index 00000000..87603df3 --- /dev/null +++ b/app/src/main/proto/mesh.proto @@ -0,0 +1,29 @@ +syntax = "proto2"; + +package tutorial; + +option java_package = "com.geeksville.meshutil"; +option java_outer_classname = "MeshProtos"; + +message Person { + required string name = 1; + required int32 id = 2; + optional string email = 3; + + enum PhoneType { + MOBILE = 0; + HOME = 1; + WORK = 2; + } + + message PhoneNumber { + required string number = 1; + optional PhoneType type = 2 [default = HOME]; + } + + repeated PhoneNumber phones = 4; +} + +message AddressBook { + repeated Person people = 1; +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4557f73b..0520b74c 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { repositories { google() jcenter() - + mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:4.0.0-alpha09' @@ -19,6 +19,9 @@ buildscript { // (if not, add it). classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta01' + + // protobuf plugin - docs here https://github.com/google/protobuf-gradle-plugin + classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.11' } }