mirror of
				https://github.com/brmlab/osmo-tetra.git
				synced 2025-10-30 23:14:00 +01:00 
			
		
		
		
	fix some global ugliness
This removes a static global variable which will only work if you only have once instance of the tetra receiver.
This commit is contained in:
		
							parent
							
								
									1594e170bc
								
							
						
					
					
						commit
						6430bdeb5f
					
				
					 2 changed files with 7 additions and 9 deletions
				
			
		|  | @ -2,7 +2,7 @@ | ||||||
| #define TETRA_COMMON_H | #define TETRA_COMMON_H | ||||||
| 
 | 
 | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| 
 | #include "tetra_mac_pdu.h" | ||||||
| #include <osmocom/core/linuxlist.h> | #include <osmocom/core/linuxlist.h> | ||||||
| 
 | 
 | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
|  | @ -47,6 +47,7 @@ struct tetra_mac_state { | ||||||
| 	struct { | 	struct { | ||||||
| 		int is_traffic; | 		int is_traffic; | ||||||
| 	} cur_burst; | 	} cur_burst; | ||||||
|  |     struct tetra_si_decoded last_sid; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| void tetra_mac_state_init(struct tetra_mac_state *tms); | void tetra_mac_state_init(struct tetra_mac_state *tms); | ||||||
|  |  | ||||||
|  | @ -40,9 +40,6 @@ | ||||||
| 
 | 
 | ||||||
| static int rx_tm_sdu(struct tetra_mac_state *tms, struct msgb *msg, unsigned int len); | static int rx_tm_sdu(struct tetra_mac_state *tms, struct msgb *msg, unsigned int len); | ||||||
| 
 | 
 | ||||||
| /* FIXME: this is ugly */ |  | ||||||
| static struct tetra_si_decoded g_last_sid; |  | ||||||
| 
 |  | ||||||
| static void rx_bcast(struct tetra_tmvsap_prim *tmvp, struct tetra_mac_state *tms) | static void rx_bcast(struct tetra_tmvsap_prim *tmvp, struct tetra_mac_state *tms) | ||||||
| { | { | ||||||
| 	struct msgb *msg = tmvp->oph.msg; | 	struct msgb *msg = tmvp->oph.msg; | ||||||
|  | @ -74,10 +71,10 @@ static void rx_bcast(struct tetra_tmvsap_prim *tmvp, struct tetra_mac_state *tms | ||||||
| 		printf("\t%s: %u\n", tetra_get_bs_serv_det_name(1 << i), | 		printf("\t%s: %u\n", tetra_get_bs_serv_det_name(1 << i), | ||||||
| 			sid.mle_si.bs_service_details & (1 << i) ? 1 : 0); | 			sid.mle_si.bs_service_details & (1 << i) ? 1 : 0); | ||||||
| 
 | 
 | ||||||
| 	memcpy(&g_last_sid, &sid, sizeof(sid)); | 	memcpy(&tms->last_sid, &sid, sizeof(sid)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const char *tetra_alloc_dump(const struct tetra_chan_alloc_decoded *cad) | const char *tetra_alloc_dump(const struct tetra_chan_alloc_decoded *cad, struct tetra_mac_state *tms) | ||||||
| { | { | ||||||
| 	static char buf[64]; | 	static char buf[64]; | ||||||
| 	char *cur = buf; | 	char *cur = buf; | ||||||
|  | @ -87,8 +84,8 @@ const char *tetra_alloc_dump(const struct tetra_chan_alloc_decoded *cad) | ||||||
| 		freq_band = cad->ext_carr.freq_band; | 		freq_band = cad->ext_carr.freq_band; | ||||||
| 		freq_offset = cad->ext_carr.freq_offset; | 		freq_offset = cad->ext_carr.freq_offset; | ||||||
| 	} else { | 	} else { | ||||||
| 		freq_band = g_last_sid.freq_band; | 		freq_band = tms->last_sid.freq_band; | ||||||
| 		freq_offset = g_last_sid.freq_offset; | 		freq_offset = tms->last_sid.freq_offset; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	cur += sprintf(cur, "%s (TN%u/%s/%uHz)", | 	cur += sprintf(cur, "%s (TN%u/%s/%uHz)", | ||||||
|  | @ -170,7 +167,7 @@ static void rx_resrc(struct tetra_tmvsap_prim *tmvp, struct tetra_mac_state *tms | ||||||
| 		goto out; | 		goto out; | ||||||
| 
 | 
 | ||||||
| 	if (rsd.chan_alloc_pres) | 	if (rsd.chan_alloc_pres) | ||||||
| 		printf("ChanAlloc=%s ", tetra_alloc_dump(&rsd.cad)); | 		printf("ChanAlloc=%s ", tetra_alloc_dump(&rsd.cad, tms)); | ||||||
| 
 | 
 | ||||||
| 	if (rsd.slot_granting.pres) | 	if (rsd.slot_granting.pres) | ||||||
| 		printf("SlotGrant=%u/%u ", rsd.slot_granting.nr_slots, | 		printf("SlotGrant=%u/%u ", rsd.slot_granting.nr_slots, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Frank A. Stevenson
						Frank A. Stevenson