77#include <lfp/body.h>
88#include <lfp/header.h>
99#include <lfp/stream.h>
10- #include <ulog/ulog.h>
1110#include <zephyr/kernel.h>
11+ #include <zephyr/logging/log.h>
1212
1313#define SYSID_CDH 1
1414#define SYSID_COMMS 3
1515#define ENDPOINT_COMMS_TEST 154
1616
17+ LOG_MODULE_REGISTER (main );
18+
1719void asn1_example_bms_system_status_req (const BMSSystemStatusRequest * p_payload , const asn1_lfp_decode_data_t * p_data ) {
18- ULOG_INFO ("Received system status request" );
20+ LOG_INF ("Received system status request" );
1921}
2022void asn1_example_bms_system_status_res (const BMSSystemStatusResponse * p_payload , const asn1_lfp_decode_data_t * p_data ) {
21- ULOG_INFO ("Received system status response: version {} , uptime {} " , p_payload -> version , p_payload -> uptime );
23+ LOG_INF ("Received system status response: version %d , uptime %d " , p_payload -> version , p_payload -> uptime );
2224}
2325
2426void asn1_example_stream_error_handler (lfp_code_t reason , void * p_ctx ) {
2527 ARG_UNUSED (p_ctx );
2628
27- ULOG_ERROR ("Stream error: {} " , reason );
29+ LOG_ERR ("Stream error: %d " , reason );
2830}
2931
3032void asn1_example_error_handler (const int asn1_error , const asn1_lfp_decode_data_t * p_data ) {
31- ULOG_ERROR ("Failed to decode message {} (error {} )" , lfp_composite_id (p_data -> p_header ), asn1_error );
33+ LOG_ERR ("Failed to decode message %d (error %d )" , lfp_composite_id (p_data -> p_header ), asn1_error );
3234}
3335
3436void asn1_example_on_msg (const lfp_header_t * p_header , const uint8_t * p_body , const uint16_t body_length , void * p_ctx ) {
3537 ARG_UNUSED (p_ctx );
3638 ARG_UNUSED (body_length );
3739
38- ULOG_INFO ("Decoded packet on endpoint {}: {}" , p_header -> endpoint , ((struct ulog_slice ){.data = (void * )p_body ,.size = body_length }));
40+ LOG_INF ("Decoded packet on endpoint %d" , p_header -> endpoint );
41+ LOG_HEXDUMP_INF (p_body , body_length , "Decoded packet:" );
3942
4043 const asn1_lfp_decode_data_t data = {
4144 .p_header = p_header ,
@@ -52,7 +55,7 @@ void asn1_example_on_msg(const lfp_header_t * p_header, const uint8_t * p_body,
5255 return ;
5356 }
5457
55- ULOG_WARN ( "Received unknown message {}" , ULOG_SLICE_PTR (( lfp_header_t * ) p_header ) );
58+ LOG_HEXDUMP_WRN ( p_header , sizeof ( lfp_header_t ), "Received unknown message:" );
5659}
5760
5861void asn1_example (void ) {
@@ -63,10 +66,10 @@ void asn1_example(void) {
6366 .version = 12
6467 });
6568 if (!size ) {
66- ULOG_ERROR ("LFP encoding failed! {} {} " , ASN1_LFP_ERROR_CODE .asn1 , ASN1_LFP_ERROR_CODE .lfp );
69+ LOG_ERR ("LFP encoding failed! %d %d " , ASN1_LFP_ERROR_CODE .asn1 , ASN1_LFP_ERROR_CODE .lfp );
6770 }
6871
69- ULOG_INFO ( "Sending: {}" , (( struct ulog_slice ) {. data = payload , . size = size }) );
72+ LOG_HEXDUMP_INF ( payload , size , "Sending:" );
7073
7174 uint8_t payload2 [ASN1_LFP_RECV_BUF_SIZE (BMSSystemStatusResponse )];
7275 lfp_stream_ctx_t stream ;
0 commit comments