This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Declare int8_t in python

I'm using the s130 SoftDevice on the nRF51 dongle and writing a PC app in python. How can I declare an int8_t in python for use in the sd_ble_gap_rssi_get function? The function parameters are:

[in]       uint16_t  conn_handle    Connection handle.
[out]     int8_t *   p_rssi               Pointer to the location where the RSSI measurement shall be stored.

I can declare a uint8_t with the new_uint8t() function, but there doesn't seem to be an equivalent function new_int8t().

Parents
  • What you can do as a workaround is to convert the uint8 that you receive:

    import struct
    int_value = struct.unpack("<b", chr(new_uint8))
    
  • Thanks for the tip, I think you're saying that after I call sd_ble_gap_rssi_get I can convert the uint8 that I receive to a int8? The problem is that I get a TypeError when I call sd_ble_gap_rssi_get with a uint8 as an argument, so I'm not at the stage where I'm receiving any values back yet.

Reply
  • Thanks for the tip, I think you're saying that after I call sd_ble_gap_rssi_get I can convert the uint8 that I receive to a int8? The problem is that I get a TypeError when I call sd_ble_gap_rssi_get with a uint8 as an argument, so I'm not at the stage where I'm receiving any values back yet.

Children
No Data