@@ -18,7 +18,8 @@ int mcm_send_video_frames(MeshConnection *connection, MeshClient *client, FILE *
1818 MeshBuffer * buf ;
1919 if (file == NULL ) {
2020 printf ("[TX] Failed to serialize video: file is null \n" );
21- exit (1 );
21+ err = 1 ;
22+ return err ;
2223 }
2324
2425 unsigned char frame_num = 0 ;
@@ -29,27 +30,30 @@ int mcm_send_video_frames(MeshConnection *connection, MeshClient *client, FILE *
2930 err = mesh_get_buffer (connection , & buf );
3031 if (err ) {
3132 printf ("[TX] Failed to get buffer: %s (%d)\n" , mesh_err2str (err ), err );
32- exit (err );
33+ err = 2 ;
34+ return err ;
3335 }
3436 read_size = fread (buf -> payload_ptr , 1 , buf -> payload_len , file );
3537 if (read_size == 0 ) {
36- exit (2 );
38+ err = 2 ;
39+ return err ;
3740 }
3841
3942 /* Send the buffer */
4043 printf ("[TX] Sending frame: %d\n" , ++ frame_num );
4144 err = mesh_put_buffer (& buf );
4245 if (err ) {
4346 printf ("[TX] Failed to put buffer: %s (%d)\n" , mesh_err2str (err ), err );
44- exit (err );
47+ err = 2 ;
48+ return err ;
4549 }
4650
4751 /* Temporary implementation for pacing */
4852 /* TODO: Implement pacing calculation */
4953 usleep (40000 );
5054 }
5155 printf ("[TX] data sent successfully \n" );
52- return err ;
56+ return 0 ;
5357}
5458
5559void read_data_in_loop (MeshConnection * connection , const char * filename ) {
@@ -69,20 +73,18 @@ void read_data_in_loop(MeshConnection *connection, const char *filename) {
6973 err = mesh_get_buffer_timeout (connection , & buf , timeout );
7074 if (err == MESH_ERR_CONN_CLOSED ) {
7175 printf ("[RX] Connection closed\n" );
72- exit ( err );
76+
7377 }
7478 printf ("[RX] Fetched mesh data buffer\n" );
7579 if (err ) {
7680 printf ("[RX] Failed to get buffer: %s (%d)\n" , mesh_err2str (err ), err );
77- exit (err );
7881 }
7982 /* Process the received user data */
8083 buffer_to_file (out , buf );
8184
8285 err = mesh_put_buffer (& buf );
8386 if (err ) {
8487 printf ("[RX] Failed to put buffer: %s (%d)\n" , mesh_err2str (err ), err );
85- exit (err );
8688 }
8789 printf ("[RX] Frame: %d\n" , ++ frame );
8890 fclose (out );
@@ -96,7 +98,6 @@ void buffer_to_file(FILE *file, MeshBuffer *buf) {
9698 return ;
9799 }
98100 // Write the buffer to the file
99- unsigned int * temp_buf = buf -> payload_ptr ;
100101 fwrite (buf -> payload_ptr , buf -> payload_len , 1 , file );
101102 printf ("[RX] Saving buffer data to a file\n" );
102103}
0 commit comments