@@ -324,7 +324,7 @@ void evt_received(TL_EvtPacket_t *hcievt)
324
324
}
325
325
}
326
326
327
- /* to send BLE packet to the SharedMem */
327
+ /* to send BLE packet to the SharedMem : return nb of bytes actually written */
328
328
uint16_t mbox_write (uint8_t type, uint16_t len, const uint8_t *pData)
329
329
{
330
330
TL_CmdPacket_t *bleCmdBuf = &BleCmdBuffer;
@@ -598,8 +598,10 @@ size_t HCISharedMemTransportClass::write(const uint8_t *data, size_t length)
598
598
if ((data[1 ] == 0x03 ) && (data[2 ] == 0x0C )) {
599
599
phase_reset = false ;
600
600
601
- mbox_write (data[0 ], (length - 1 ), msg_data);
602
-
601
+ if (mbox_write (data[0 ], (length - 1 ), msg_data) != (length - 1 )) {
602
+ /* Error: no data are written */
603
+ return 0 ;
604
+ }
603
605
/* capture event after HCI_RESET */
604
606
while (!phase_reset);
605
607
@@ -645,7 +647,7 @@ size_t HCISharedMemTransportClass::write(const uint8_t *data, size_t length)
645
647
646
648
return (length - 1 ); /* mbox_size of the HCI reset command */
647
649
}
648
- return 0 ; /* mbox_size of the HCI reset command */
650
+ return 0 ; /* Error: no data written */
649
651
}
650
652
651
653
// private:
@@ -810,7 +812,10 @@ int HCISharedMemTransportClass::bt_ipm_set_addr(void)
810
812
data[5 ] = 6 ; /* is the length of the bd_addr table */
811
813
memcpy (data + 6 , bd_addr_udn, 6 );
812
814
/* send the ACI_HAL_WRITE_CONFIG_DATA */
813
- mbox_write (data[0 ], 11 , &data[1 ]);
815
+ if (mbox_write (data[0 ], 11 , &data[1 ]) != 11 ) {
816
+ /* Error: no data are written */
817
+ return 0 ;
818
+ }
814
819
/* now wait for the corresponding Rx event */
815
820
return 1 ; /* success */
816
821
}
@@ -847,7 +852,10 @@ int HCISharedMemTransportClass::bt_ipm_set_random_addr(void)
847
852
data[5 ] = 6 ; /* is the length of the random address */
848
853
memcpy (data + 6 , srd_bd_addr, 6 );
849
854
/* send the ACI_HAL_WRITE_CONFIG_DATA */
850
- mbox_write (data[0 ], 11 , &data[1 ]);
855
+ if (mbox_write (data[0 ], 11 , &data[1 ]) != 11 ) {
856
+ /* Error: no data are written */
857
+ return 0 ;
858
+ }
851
859
/* now wait for the corresponding Rx event */
852
860
return 1 ; /* success */
853
861
}
@@ -869,7 +877,10 @@ int HCISharedMemTransportClass::bt_ipm_set_power(void)
869
877
data[5 ] = CFG_TX_POWER; /* PA_level */
870
878
871
879
/* send the SET_POWER */
872
- mbox_write (data[0 ], 5 , &data[1 ]);
880
+ if (mbox_write (data[0 ], 5 , &data[1 ]) != 5 ) {
881
+ /* Error: no data are written */
882
+ return 0 ;
883
+ }
873
884
/* now wait for the corresponding Rx event */
874
885
return 1 ; /* success */
875
886
}
@@ -887,7 +898,10 @@ int HCISharedMemTransportClass::bt_ipm_gatt_init(void)
887
898
data[3 ] = 0 ; /* the length */
888
899
889
900
/* send the GATT_INIT */
890
- mbox_write (data[0 ], 3 , &data[1 ]);
901
+ if (mbox_write (data[0 ], 3 , &data[1 ]) != 3 ) {
902
+ /* Error: no data are written */
903
+ return 0 ;
904
+ }
891
905
/* now wait for the corresponding Rx event */
892
906
return 1 ; /* success */
893
907
}
@@ -910,7 +924,10 @@ int HCISharedMemTransportClass::bt_ipm_gap_init(void)
910
924
data[6 ] = 0x00 ; /* device_name_char_len */
911
925
912
926
/* send the GAP_INIT */
913
- mbox_write (data[0 ], 6 , &data[1 ]);
927
+ if (mbox_write (data[0 ], 6 , &data[1 ]) != 6 ) {
928
+ /* Error: no data are written */
929
+ return 0 ;
930
+ }
914
931
/* now wait for the corresponding Rx event */
915
932
return 1 ; /* success */
916
933
}
@@ -934,7 +951,10 @@ int HCISharedMemTransportClass::bt_ipm_get_random_addr(void)
934
951
data[4 ] = 0x2E ; /* the offset */
935
952
936
953
/* send the ACI_READ_CONFIG_DATA_OPCODE */
937
- mbox_write (data[0 ], 4 , &data[1 ]);
954
+ if (mbox_write (data[0 ], 4 , &data[1 ]) != 4 ) {
955
+ /* Error: no data are written */
956
+ return 0 ;
957
+ }
938
958
/* now wait for the corresponding Rx event */
939
959
return 1 ; /* success */
940
960
}
0 commit comments