mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
broadcast transmission stuff
This commit is contained in:
parent
5c551812e6
commit
35689284d5
|
@ -21,7 +21,7 @@ import chat_navbar from './chat_navbar.vue'
|
|||
import chat_conversations from './chat_conversations.vue'
|
||||
import chat_messages from './chat_messages.vue'
|
||||
|
||||
import {updateAllChat, newMessage} from '../js/chatHandler'
|
||||
import {updateAllChat, newMessage, newBroadcast} from '../js/chatHandler'
|
||||
|
||||
|
||||
|
||||
|
@ -30,8 +30,14 @@ import {updateAllChat, newMessage} from '../js/chatHandler'
|
|||
|
||||
function transmitNewMessage(){
|
||||
|
||||
newMessage(chat.selectedCallsign, chat.inputText, chat.inputFile, chat.inputFileName, chat.inputFileSize, chat.inputFileType)
|
||||
|
||||
if (chat.selectedCallsign.startsWith("BC-")) {
|
||||
|
||||
newBroadcast(chat.selectedCallsign, chat.inputText)
|
||||
|
||||
} else {
|
||||
newMessage(chat.selectedCallsign, chat.inputText, chat.inputFile, chat.inputFileName, chat.inputFileSize, chat.inputFileType)
|
||||
}
|
||||
// finally do a cleanup
|
||||
chat.inputText = ''
|
||||
resetFile()
|
||||
|
|
|
@ -62,6 +62,86 @@ createChatIndex();
|
|||
// create callsign set for storing unique callsigns
|
||||
chat.callsign_list = new Set()
|
||||
|
||||
// function for creating a new broadcast
|
||||
export function newBroadcast(broadcastChannel, chatmessage){
|
||||
|
||||
var mode = ''
|
||||
var frames = ''
|
||||
var data = ''
|
||||
if (typeof chatFile !== "undefined"){
|
||||
var file = chatFile;
|
||||
var filetype = chatFileType
|
||||
var filename = chatFileName
|
||||
} else {
|
||||
var file = '';
|
||||
var filetype = 'text'
|
||||
var filename = ''
|
||||
}
|
||||
var file_checksum = ''//crc32(file).toString(16).toUpperCase();
|
||||
var checksum = ''
|
||||
var message_type = 'broadcast_transmit'
|
||||
var command = ''
|
||||
|
||||
var timestamp = Math.floor(Date.now() / 1000)
|
||||
var uuid = uuidv4();
|
||||
// TODO: Not sure what this uuid part is needed for ...
|
||||
let uuidlast = uuid.lastIndexOf("-");
|
||||
uuidlast += 1;
|
||||
if (uuidlast > 0) {
|
||||
uuid = uuid.substring(uuidlast);
|
||||
}
|
||||
// slice uuid for reducing overhead
|
||||
uuid = uuid.slice(-4);
|
||||
|
||||
var data_with_attachment =
|
||||
timestamp +
|
||||
split_char +
|
||||
chatmessage +
|
||||
split_char +
|
||||
filename +
|
||||
split_char +
|
||||
filetype +
|
||||
split_char +
|
||||
file;
|
||||
|
||||
var tnc_command = "broadcast";
|
||||
|
||||
sendMessage(
|
||||
dxcallsign,
|
||||
data_with_attachment,
|
||||
checksum,
|
||||
uuid,
|
||||
tnc_command
|
||||
)
|
||||
|
||||
let newChatObj = new Object();
|
||||
|
||||
newChatObj.command = "msg"
|
||||
newChatObj.hmac_signed = false
|
||||
newChatObj.percent = 0
|
||||
newChatObj.bytesperminute
|
||||
newChatObj.is_new = false
|
||||
newChatObj._id = uuid
|
||||
newChatObj.timestamp = timestamp
|
||||
newChatObj.dxcallsign = dxcallsign
|
||||
newChatObj.dxgrid = "null"
|
||||
newChatObj.msg = chatmessage
|
||||
newChatObj.checksum = file_checksum
|
||||
newChatObj.type = message_type
|
||||
newChatObj.status = "transmitting"
|
||||
newChatObj.attempt = 1
|
||||
newChatObj.uuid = uuid
|
||||
newChatObj._attachments = {
|
||||
[filename]: {
|
||||
content_type: filetype,
|
||||
data: FD.btoa_FD(file),
|
||||
},
|
||||
}
|
||||
|
||||
addObjToDatabase(newChatObj)
|
||||
|
||||
}
|
||||
|
||||
// function for creating a new message
|
||||
export function newMessage(dxcallsign, chatmessage, chatFile, chatFileName, chatFileSize, chatFileType){
|
||||
var mode = ''
|
||||
|
@ -424,6 +504,12 @@ console.log(protocol)
|
|||
},
|
||||
}
|
||||
|
||||
// some tweaks for broadcasts
|
||||
if (item.fec == "broadcast") {
|
||||
newChatObj.broadcast_sender = protocol["dxcallsign"]
|
||||
newChatObj.type = 'broadcast_received'
|
||||
}
|
||||
|
||||
addObjToDatabase(newChatObj)
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue