This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = None | |
while True: | |
for line in scanner.get_lines(): | |
if line: | |
found_mac = line[14:][:12] | |
reversed_mac = ''.join( | |
reversed([found_mac[i:i + 2] for i in range(0, len(found_mac), 2)])) | |
mac = ':'.join(a+b for a,b in zip(reversed_mac[::2], reversed_mac[1::2])) | |
data = line[26:] | |
if mac == deviceId and len(data) == 66: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BLEScanner: | |
hcitool = None | |
hcidump = None | |
def start(self): | |
print('Start receiving broadcasts') | |
DEVNULL = subprocess.DEVNULL if sys.version_info > (3, 0) else open(os.devnull, 'wb') | |
subprocess.call('sudo hciconfig hci0 reset', shell = True, stdout = DEVNULL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// one-shot flag for setting adv data | |
static volatile bool g_setAdvData = false; | |
/**@brief Function for handling the Battery measurement timer timeout. | |
* | |
* @details This function will be called each time the battery level measurement timer expires. | |
* | |
* @param[in] p_context Pointer used for passing some arbitrary information (context) from the | |
* app_start_timer() call to the timeout handler. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
process_uid.py | |
eg. | |
Input: 80c4a66b-ddb7-46e3-87bc-ae7053faf6ee | |
Output: 0xee,0xf6,0xfa,0x53,0x70,0xae,0xbc,0x87,0xe3,0x46,0xb7,0xdd,0x6b,0xa6,0xc4,0x80 | |
electronut.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set adv data | |
void set_adv_data(bool init) | |
{ | |
uint32_t err_code; | |
ble_advdata_t advdata; | |
uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED; | |
ble_advdata_manuf_data_t manuf_data; // Variable to hold manufacturer specific data | |
// Initialize with easily identifiable data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(void) | |
{ | |
uint32_t err_code; | |
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); | |
ble_stack_init(); | |
advertising_init(); | |
timers_init(); | |
advertising_start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void advertising_init(void) | |
{ | |
uint32_t err_code; | |
ble_gap_conn_sec_mode_t sec_mode; | |
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); | |
err_code = sd_ble_gap_device_name_set(&sec_mode, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
upload.py | |
Uploads DFU OTA bootloader to bluey board. | |
Electronut Labs | |
electronut.in | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
oscillating_circle.py | |
A simple matplotlib animation example that shows an oscillating circle. | |
electronut.in | |
""" | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
ldr.py | |
Display analog data from Arduino using Python (matplotlib) | |
Author: Mahesh Venkitachalam | |
Website: electronut.in | |
""" | |
import sys, serial, argparse |