Koncentrator
Dependencies: SX127x mbed-rtos mbed
fun.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 #include "sx127x_lora.h" 00004 #include "comm.h" 00005 #include "fun.h" 00006 #include "application.h" 00007 00008 unsigned long readCurrentTimestamp( void ) { 00009 time_t seconds = time(NULL); 00010 return seconds; 00011 } 00012 00013 void setCurrentTimeDate( unsigned long ts ) { 00014 set_time(ts); 00015 } 00016 00017 00018 void printStr(unsigned int destination, unsigned char * str, unsigned int len) { 00019 unsigned int i; 00020 00021 #ifdef LORA_TARGET 00022 if(destination==LORA_TARGET) { 00023 kom.write_reg(0x22,len); 00024 } 00025 #endif 00026 00027 for(i=0;i<len;i++) { 00028 switch(destination) { 00029 #ifdef PC_TARGET 00030 case PC_TARGET: 00031 pc_mutex.lock(); 00032 pc.putc(str[i]); 00033 pc_mutex.unlock(); 00034 break; 00035 #endif 00036 #ifdef FIBER_OPTIC_TARGET 00037 case FIBER_OPTIC_TARGET: 00038 fiberOptic_mutex.lock(); 00039 fiberOptic.putc(str[i]); 00040 fiberOptic_mutex.unlock(); 00041 break; 00042 #endif 00043 #ifdef LORA_TARGET 00044 case LORA_TARGET: 00045 kom.tx_buf[i] = str[i]; 00046 break; 00047 #endif 00048 #ifdef GSM_TARGET 00049 case GSM_TARGET: 00050 //gsm_mutex.lock(); 00051 //gsm_mutex.unlock(); 00052 break; 00053 #endif 00054 default: 00055 break; 00056 } 00057 } 00058 #ifdef LORA_TARGET 00059 if(destination==LORA_TARGET) 00060 Lora.start_tx(len); 00061 while(Lora.service() != SERVICE_TX_DONE); 00062 Lora.start_rx(); 00063 #endif 00064 }
Generated on Tue Jul 12 2022 18:10:08 by 1.7.2