Skip to content

Instantly share code, notes, and snippets.

static uint32_t measure_value_char_add(ble_mus_t * p_mus, const ble_mus_init_t * p_mus_init)
{
uint32_t err_code;
ble_gatts_char_md_t char_md;
ble_gatts_attr_md_t cccd_md;
ble_gatts_attr_t attr_char_value;
ble_uuid_t ble_uuid;
ble_gatts_attr_md_t attr_md;
// Add Measure Value characteristic
BluetoothLEDevice bluetoothLeDevice = await BluetoothLEDevice.FromIdAsync(id);
GattDeviceServicesResult result = await bluetoothLeDevice.GetGattServicesAsync();
if (result.Status == GattCommunicationStatus.Success) {
LogEvent("DEBUG: Services discovered successfully");
foreach (GattDeviceService service in result.Services) {
// Discover characteristics for each service
GattCharacteristicsResult characteristicsResult = await service.GetCharacteristicsAsync();
BluetoothLEDevice bluetoothLeDevice = await BluetoothLEDevice.FromIdAsync(id);
GattDeviceServicesResult result = await bluetoothLeDevice.GetGattServicesAsync();
if (result.Status == GattCommunicationStatus.Success) {
LogEvent("DEBUG: Services discovered successfully");
foreach (GattDeviceService service in result.Services) {
// Discover characteristics for each service
GattCharacteristicsResult characteristicsResult = await service.GetCharacteristicsAsync();
public class ReportGrievanceRequest {
// Initialize the objects
Context context;
ReportGrievanceCallback reportGrievanceCallback;
// Call Constructor to fetch objects
public ReportGrievanceRequest(Context context, ReportGrievanceCallback reportGrievanceCallback) {
this.context = context;
this.reportGrievanceCallback = reportGrievanceCallback;
@neelratanguria
neelratanguria / flask_concurrency.py
Created September 17, 2022 01:09
Example for achieving concurrency in flask endpoint
@signal_blueprint.route('/all-stats',)
async def signal_stats():
tasks = []
titles = []
tasks.append(asyncio.gather(signal_actions.get_total_count()))
titles.append("signal_count")
tasks.append(asyncio.gather(spir_actions.get_total_signal_count()))
titles.append("spir_signal_count")
tasks.append(asyncio.gather(spir_actions.get_total_unseg_features_count()))
def append_parent_path():
import sys
import os
# getting the name of the directory
# where the this file is present.
current = os.path.dirname(os.path.realpath(__file__))
# Getting the parent directory name
# where the current directory is present.
parent = os.path.dirname(current)
@neelratanguria
neelratanguria / nrf_decrypt.py
Created March 22, 2022 11:10
Code snippet to convert and decrypt hex output from NRF AES CTR project in python.
from Crypto.Cipher import AES
# Hex prints from debug console from segger
nrf_plain_hex = "45 78 61 6D 70 6C 65 20 73 74 72 69 6E 67 20 74 6F 20 64 65 6D 6F 6E 73 74 72 61 74 65 20 62 61 73 69 63 20 75 73 61 67 65 20 6F 66 20 41 45 53 20 43 54 52 20 6D 6F 64 65 2E"
nrf_cipher = "12 DD C3 EE DF 6E 7E 04 C7 3B DD 0D A3 F5 8E 7E CF 6D A0 A6 76 60 8A 63 01 87 A5 F6 F6 26 B6 86 3A 07 B3 C0 FE D3 E5 3E 94 95 D5 05 EA 62 E7 23 4A F8 9A 20 4C 68 B2 2C D6 E5"
# Initiat vector for aes_ctr project
iv = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
# Method for converton of of hex string from NRF to bytes in python
def nrf_hex_str_to_bytes(m_hex_str):
const path = require('path');
const { exec } = require('child_process');
const fs = require('fs');
const rimraf = require('rimraf');
function renameOutputFolder(buildFolderPath, outputFolderPath) {
return new Promise((resolve, reject) => {
fs.rename(buildFolderPath, outputFolderPath, (err) => {
if (err) {
reject(err);
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const renderReactDom = () => {
ReactDOM.render(
<React.StrictMode>
<App />
{
"name": "io.cordova.hellocordova",
"displayName": "HelloCordova",
"version": "1.0.0",
"description": "A sample Apache Cordova application that responds to the deviceready event.",
"main": "index.js",
"keywords": [
"ecosystem:cordova"
],
"author": "Apache Cordova Team",