Hi,

While lurking in code I noticed that endianness APIs in Mynewt
are bit strange and scattered around:
- htole16, htobe16 etc are defined in "nimble/ble.h"
- above mentioned functions have signatures different than same named
  functions normally defined in endian.h

So to clean those up I propose following:
 - rename functions existing in ble.h to put_le16, get_le16 etc which are
   intended for use on raw byte buffer
 - move those to endian.h
 - add standard htole16 etc definitions in endian.h

Some open points:
1) there are two functions in ble.h
     void swap_in_place(void *buf, int len);
     void swap_buf(uint8_t *dst, const uint8_t *src, int len);
   that I also moved to endian.h for time being but I think that eventually
   we should have "os/misc.h" (or utils.h) for such helpers

2) I had to wrap macros in endian.h into #ifndef-endif since tests seem
   to be including both os/ and system includes resulting in macro redefined
   error

Code implementing above is available at [1].

Comments are welcome.


[1] https://github.com/sjanc/incubator-mynewt-core/commits/endianness

-- 
pozdrawiam
Szymon K. Janc

Reply via email to