Skip to content

Commit 770bdc1

Browse files
author
antonxy
committed
checksum in audio
1 parent a7bfdf4 commit 770bdc1

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/org/audiosync/MainActivity.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected void onCreate(Bundle savedInstanceState) {
2727

2828
@Override
2929
public void onClick(View arg0) {
30-
int[] bytes_to_send = new int[3];
30+
int[] bytes_to_send = new int[4];
3131
try {
3232
bytes_to_send[0] = Integer.parseInt(sceneInp.getText().toString());
3333
bytes_to_send[1] = Integer.parseInt(shotInp.getText().toString());
@@ -39,6 +39,13 @@ public void onClick(View arg0) {
3939
}
4040
}
4141

42+
int checksum = 0;
43+
for (int i : bytes_to_send) {
44+
checksum += i;
45+
}
46+
checksum %= 255;
47+
bytes_to_send[3] = checksum;
48+
4249
} catch (NumberFormatException e) {
4350
Toast.makeText(MainActivity.this, "invalid numbers in textfields", Toast.LENGTH_SHORT).show();
4451
return;

0 commit comments

Comments
 (0)