void md5i_iterate(int pass, int niter, unsigned char* out) { unsigned char a[4]; int32_to_char(pass,a); md5_iterate(a,4,niter,out); }
// ask power strip how much energy it has used between start_utc and // end_utc, then print it out in kWh, as well as the cost in $. void send_cmd_energy_query(time_t start_utc, time_t end_utc) { // fill send_buf with command and two dates send_buf[0] = MASTER_COMMAND_ENERGY_QUERY; int32_to_char(start_utc, send_buf + 1); int32_to_char(end_utc, send_buf + 5); send_to_client(send_buf, 9); // now the result is in recv_buf uint32_t result[4]; double total_kwh = 0; for(int32_t i = 0; i < 3; i++) { // get the result out of recv_buf and print it out result[i] = char_to_int32(recv_buf + i * 4); double kwh = (double)result[i] / KWH_IN_J; total_kwh += kwh; printf("Socket %d: %.4fkWh, $%.4f\n", i+1, kwh, kwh * CENT_PER_KWH / 100); } printf(" Total: %.4fkWh, $%.4f\n", total_kwh, total_kwh * CENT_PER_KWH / 100); }
// send current time to set the RTC in power strip void send_cmd_set_time() { send_buf[0] = MASTER_COMMAND_SET_TIME; int32_to_char(time(0), send_buf+1); send_to_client(send_buf, 5); }