static void handle_cmd(handler_arg_t arg) { switch ((char) (uint32_t) arg) { case 't': temperature_sensor(); break; case 'l': light_sensor(); break; case 'p': pressure_sensor(); break; case 's': send_packet(); break; case 'b': send_big_packet(); break; case 'e': leds_action(); break; case '\n': printf("\ncmd > "); break; case 'h': default: print_usage(); break; } }
void obtain_measurement() { AnalogIn temperature_sensor(p15); uint16_t sensor_value; // value read from the analog in float temperature; // to store the value after the conversion from mV float voltage; // conversion from integer to mV char float_converted[50]; // to store the result of the conversion myled = 1; // turn on, something to transmit sensor_value = temperature_sensor.read_u16(); voltage = (sensor_value / 65536.0 ) * 3.3; temperature = (voltage - .5) * 100; sprintf(float_converted, "%f", temperature); rn42.putc('*'); wait(0.1); rn42.putc(' '); wait(0.1); rn42.putc('2'); wait(0.1); rn42.putc(' '); wait(0.1); rn42.putc(float_converted[0]); wait(0.1); rn42.putc(float_converted[1]); wait(0.1); rn42.putc(float_converted[2]); wait(0.1); rn42.putc(float_converted[3]); wait(0.1); rn42.putc(float_converted[4]); wait(0.1); rn42.putc(' '); wait(0.1); rn42.putc('#'); wait(0.1); rn42.putc('#'); wait(0.1); rn42.putc('#'); wait(0.1); rn42.putc('#'); wait(0.1); rn42.putc('#'); wait(0.1); rn42.putc(' '); wait(0.1); rn42.putc('*'); myled = 0; }
static void handle_cmd(handler_arg_t arg) { switch ((char) (uint32_t) arg) { #ifdef IOTLAB_M3 case 't': temperature_sensor(); break; case 'l': light_sensor(); break; case 'p': pressure_sensor(); break; #endif case 'u': print_node_uid(); break; case 'd': print_cn_time(); break; case 's': send_packet(); break; case 'b': send_big_packet(); break; case 'e': leds_action(); break; case '\n': printf("\ncmd > "); break; case 'h': default: print_usage(); break; } }