File tree 3 files changed +16
-21
lines changed
3 files changed +16
-21
lines changed Original file line number Diff line number Diff line change @@ -12,21 +12,19 @@ TinyFrame is a simple library for building and parsing data frames to be sent ov
12
12
import 'dart:typed_data';
13
13
import 'package:tiny_frame/tiny_frame.dart';
14
14
15
- void write(Uint8List data) => print('write: $data');
16
15
void main() {
17
- const mainID = 1;
18
- // create a TinyFrame instance as master (peer id set)
19
- // the write method has to be implemented, tinyframe will call it
20
- // to send the data after building the frame
21
- final tf = TinyFrame(write);
16
+ const typeID = 1;
17
+ // create a TinyFrame instance with a write function
18
+ // TF_WriteImpl in C Library
19
+ final tf = TinyFrame((Uint8List data) => print('write: $data'));
22
20
// some optional settings
23
21
tf.cksumType = 'xor';
24
22
// generate a listener for the id 1
25
- tf.addIdListener(mainID , (Uint8List frame ) => print('main: $frame '));
23
+ tf.addTypeListener(typeID , (_, TF_Msg msg ) => print('main: $msg '));
26
24
// if no listener is found for the id, this listener will be called
27
- tf.addFallbackListener((Uint8List frame ) => print('fallback: $frame '));
25
+ tf.addFallbackListener((_, TF_Msg msg ) => print('fallback: $msg '));
28
26
// send to slave on id 1
29
- tf.send(mainID , Uint8List.fromList('abcde'.codeUnits));
27
+ tf.send(typeID , Uint8List.fromList('abcde'.codeUnits));
30
28
}
31
29
```
32
30
Original file line number Diff line number Diff line change @@ -2,20 +2,17 @@ import 'dart:typed_data';
2
2
3
3
import 'package:tiny_frame/tiny_frame.dart' ;
4
4
5
- void write (Uint8List data) => print ('write: $data ' );
6
5
void main () {
7
- const mainID = 1 ;
8
- // create a TinyFrame instance as master (peer id set)
9
- // the write method has to be implemented, tinyframe will call it
10
- // to send the data after building the frame
11
- final tf = TinyFrame (write);
6
+ const typeID = 1 ;
7
+ // create a TinyFrame instance with a write function
8
+ // TF_WriteImpl in C Library
9
+ final tf = TinyFrame ((Uint8List data) => print ('write: $data ' ));
12
10
// some optional settings
13
11
tf.cksumType = 'xor' ;
14
12
// generate a listener for the id 1
15
- tf.addIdListener (mainID , (Uint8List frame ) => print ('main: $frame ' ));
13
+ tf.addTypeListener (typeID , (_, TF_Msg msg ) => print ('main: $msg ' ));
16
14
// if no listener is found for the id, this listener will be called
17
- tf.addFallbackListener ((Uint8List frame) => print ('fallback: $frame ' ));
18
-
15
+ tf.addFallbackListener ((_, TF_Msg msg) => print ('fallback: $msg ' ));
19
16
// send to slave on id 1
20
- tf.send (mainID , Uint8List .fromList ('abcde' .codeUnits));
17
+ tf.send (typeID , Uint8List .fromList ('abcde' .codeUnits));
21
18
}
Original file line number Diff line number Diff line change 1
1
name : tiny_frame
2
- description : TinyFrame port
3
- version : 1.0.0
2
+ description : TinyFrame library port
3
+ version : 1.0.1
4
4
repository : https://github.com/marcel-cd/tiny_frame
5
5
6
6
environment :
You can’t perform that action at this time.
0 commit comments