Beispiel #1
0
static retval_t cmd_rtc_set_time(const subsystem_t *self, frame_t *iframe, frame_t *oframe) {
	uint64_t current_time_ms;
	retval_t rv;

	rv = frame_get_u64(iframe, &current_time_ms);
	SUCCESS_OR_RETURN(rv);

	rtc_set_current_time(current_time_ms);
	return frame_put_u64(oframe, rtc_get_current_time());
}
static void scr_changetime_handle_button_select(void) {
	  if (change_mode == MODE_HOUR) {
			  change_mode = MODE_MINUTES;
			
				mlcd_fb_clear();
			  scr_changetime_draw_all();
	      mlcd_fb_flush();
		} else if (change_mode == MODE_MINUTES) {
				time_t t;
				time(&t);
				struct tm* time_struct = localtime(&t);

				time_struct->tm_hour = hour;
				time_struct->tm_min = minutes;
				time_struct->tm_sec = 0;
			  rtc_set_current_time(mktime(time_struct));
			  scr_mngr_show_screen(SCR_SETTINGS);
		}
}
/**@snippet [Handling the data received over BLE] */
static void ossw_data_handler(ble_ossw_t * p_ossw, uint8_t * p_data, uint16_t length)
{ 
		#ifdef OSSW_DEBUG
				sd_nvic_critical_region_enter(0);
				printf("DAT: 0x%02x 0x%02x 0x%02x\r\n", p_data[0], p_data[1], p_data[2]);
				sd_nvic_critical_region_exit(0);
		#endif
	
	 switch(p_data[0]) {	
		 case 0x01:
					scr_mngr_handle_event(SCR_EVENT_APP_CONNECTION_CONFIRMED, NULL);
					break;
		 case 0x10:
			    // set current time
					rtc_set_current_time(((uint32_t)p_data[1]<<24) | ((uint32_t)p_data[2]<<16)
						| ((uint32_t)p_data[3]<<8) | (uint32_t)p_data[4]);
					break; 
		 case 0x40:
					// command first part
					command_reset_data();
					command_append_data(p_data+1, length-1);
					break;
		 case 0x41:
					// command next part
					command_append_data(p_data+1, length-1);
					break;
		 case 0x42:
					// command last part
					command_append_data(p_data+1, length-1);
					command_data_complete();
					break;
		 case 0x43:
					// command first and last part
					command_reset_data();
					command_append_data(p_data+1, length-1);
					command_data_complete();
					break;
	 }
}
/**@snippet [Handling the data received over BLE] */
static void ossw_data_handler(ble_ossw_t * p_ossw, uint8_t * p_data, uint16_t length)
{ 
	 switch(p_data[0]) {	
		 case 0x10:
			    // set current time
					rtc_set_current_time((p_data[1]<<24) | (p_data[2]<<16) | (p_data[3]<<8) | p_data[4]);
					break; 
	/*	 case 0x20:
			    // init data upload
					init_data_upload(p_data[1], (p_data[2]<<24) | (p_data[3]<<16) | (p_data[4]<<8) | p_data[5]);
					break;
		 case 0x21:
			    // upload data part
		 			handle_data_upload_part(&p_data[1], length - 1);
					break;
		 case 0x22:
			    // upload data finished
					handle_data_upload_done();
			    break;	*/
		 case 0x40:
					// command first part
					command_reset_data();
					command_append_data(p_data+1, length-1);
					break;
		 case 0x41:
					// command next part
					command_append_data(p_data+1, length-1);
					break;
		 case 0x42:
					// command last part
					command_append_data(p_data+1, length-1);
					command_data_complete();
					break;
		 case 0x43:
					// command first and last part
					command_reset_data();
					command_append_data(p_data+1, length-1);
					command_data_complete();
					break;
		 case 0x23:
			    // init notification upload
					init_notification_upload((p_data[1]<<8) | p_data[2]);
					break;
		 case 0x24:
			    // upload notification part
		 			handle_notification_upload_part(&p_data[1], length - 1);
					break;
		 case 0x25:
			    // upload notification finished
					handle_notification_upload_done();
			    break;	
		 case 0x26:
			    // extend alert notification
					handle_notification_alert_extend(p_data[1] << 8 | p_data[2], p_data[3] << 8 | p_data[4]);
			    break;		
		 case 0x27:
			    // stop alert notification
					handle_notification_alert_stop(p_data[1] << 8 | p_data[2]);
			    break;
		 case 0x30:
			    // set ext param
					set_external_property_data(p_data[1], &p_data[2], length-2);
					break;
	 }
}