File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -25,23 +25,27 @@ const COAP_KEY_SIZE: usize = 32;
2525/// Size of the static value buffer
2626const COAP_VALUE_SIZE : usize = 32 ;
2727
28- /// Global CBOR root map
28+ /// Global CBOR root map for encoding CBOR documents
2929static mut cbor_encoder0: CborEncoder = fill_zero ! ( CborEncoder ) ;
3030static mut cbor_encoder1: CborEncoder = fill_zero ! ( CborEncoder ) ;
3131
3232impl CoapContext {
3333
34+ /// Encode a text value into the current JSON document with the specified key
3435 pub fn json_set_text_string ( & mut self , key : & Strn , value : & Strn ) {
36+ // Convert the key to C string.
3537 let key_cstr: * const u8 =
3638 match key. rep {
3739 StrnRep :: ByteStr ( bs) => { self . key_to_cstr ( bs) }
3840 StrnRep :: CStr ( cstr) => { cstr }
3941 } ;
42+ // Convert the value to a C string.
4043 let value_cstr: * const u8 =
4144 match value. rep {
4245 StrnRep :: ByteStr ( bs) => { self . value_to_cstr ( bs) }
4346 StrnRep :: CStr ( cstr) => { cstr }
4447 } ;
48+ // Encode the value.
4549 unsafe {
4650 crate :: libs:: mynewt_rust:: json_helper_set_text_string (
4751 self . to_void_ptr ( ) ,
You can’t perform that action at this time.
0 commit comments