DJ2LS / FreeDATA

A free, open-source, multi-platform application for sending files and messages, using the codec2 HF modems
https://wiki.freedata.app/
GNU General Public License v3.0
133 stars 17 forks source link

0.16.0 #733

Open DJ2LS opened 1 month ago

DJ2LS commented 1 month ago

get all messages: GET: http://127.0.0.1:5000/freedata/messages

get specific message by id GET: http://127.0.0.1:5000/freedata/messages?id=AA1AAA-1_DJ2LS-3_2024-05-14T15:31:27.805131

retransmit message PATCH: http://127.0.0.1:5000/freedata/messages content: "action: retransmit" # this triggers a retransmission

update message PATCH: http://127.0.0.1:5000/freedata/messages content: "is_read: True" # "is_read" must be part of the message header.

frspin commented 1 month ago

Review API for messages leaving GET /freedata/messages?[key]=[value] for getting messages (no key == no filter)

removing old GET /freedata/messages/ (actually not returning a JSON)

and collapsing modifications and retransmit in a new API

PATCH /freedata/messages/ -> payload : "action:retransmit" or "is_read: True" or many other updates to message, body included for a modified message.

DELETE /freedata/message/ is unchanged

Franco Spinelli IW2DHW

DJ2LS commented 1 month ago

@frspin I added the api changes - please have a look at them. @LA3QMA FYI

frspin commented 1 month ago

Il 31/05/24 09:44, DJ2LS ha scritto:

@frspin https://github.com/frspin I added the api changes - please have a look at them.

I have seen.

Now retransmit API is:

PATCH /freedata/messages/?action=retransmit

I will modify my Gui and test it

Franco Spinelli IW2DHW

DJ2LS commented 1 month ago

No, you have to push the command as JSON, not as url parameter.Von meinem iPhone gesendetAm 31.05.2024 um 09:48 schrieb frspin @.***>: Il 31/05/24 09:44, DJ2LS ha scritto:

@frspin https://github.com/frspin I added the api changes - please have a look at them.

I have seen.

Now retransmit API is:

PATCH /freedata/messages/?action=retransmit

I will modify my Gui and test it

Franco Spinelli IW2DHW

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

frspin commented 1 month ago

Il 31/05/24 10:21, DJ2LS ha scritto:

No, you have to push the command as JSON, not as url parameter.

In command body?

Can you give an example?

Franco Spinelli IW2DHW

DJ2LS commented 1 month ago

Like with updating a messages content via post. Just PATCH “{action: retransmit}” via the endpoint.Von meinem iPhone gesendetAm 31.05.2024 um 10:47 schrieb frspin @.***>: Il 31/05/24 10:21, DJ2LS ha scritto:

No, you have to push the command as JSON, not as url parameter.

In command body?

Can you give an example?

Franco Spinelli IW2DHW

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

frspin commented 1 month ago

Il 31/05/24 11:05, DJ2LS ha scritto:

Like with updating a messages content via post. Just PATCH “{action: retransmit}” via the endpoint.

Ok

I will test it

Regards

Franco Spinelli IW2DHW

frspin commented 1 month ago

Il 31/05/24 11:05, DJ2LS ha scritto:

Like with updating a messages content via post. Just PATCH “{action: retransmit}” via the endpoint.

Done and it is working

Regards

Franco Spinelli IW2DHW

DJ2LS commented 1 month ago

Happy with the changes? Von meinem iPhone gesendetAm 31.05.2024 um 11:47 schrieb frspin @.***>: Il 31/05/24 11:05, DJ2LS ha scritto:

Like with updating a messages content via post. Just PATCH “{action: retransmit}” via the endpoint.

Done and it is working

Regards

Franco Spinelli IW2DHW

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

frspin commented 1 month ago

Il 31/05/24 12:50, DJ2LS ha scritto:

Happy with the changes?

Yes!

Now I am working on a "correct" mode for modify and resend a message.

The initial idea is:

There is some problems for doing this (ID propagation, attach process, etc.) but I think this is the correct roadmap.

Thanks

Franco Spinelli IW2DHW

DJ2LS commented 1 month ago

Il 31/05/24 12:50, DJ2LS ha scritto: Happy with the changes? Yes! Now I am working on a "correct" mode for modify and resend a message. The initial idea is: - modify "Send" button to "Update" button - fill message area with text and attach of message to modify - when "Update" button is clicked send message with: PATCH /freedata/messages/ as URL and message in body There is some problems for doing this (ID propagation, attach process, etc.) but I think this is the correct roadmap. Thanks Franco Spinelli IW2DHW

Franco, this isnt working yet, as the message id is unique and the actual way is, dropping a message if it is received again. The reason is, that we want to implement this, when we have hmac message signing enabled - same with deleting a wrong message remotely afterwards.

frspin commented 1 month ago

Il 31/05/24 19:59, DJ2LS ha scritto:

Il 31/05/24 12:50, DJ2LS ha scritto:
Happy with the changes?
Yes! Now I am working on a "correct" mode for modify and resend a
message. The initial idea is: - modify "Send" button to "Update"
button - fill message area with text and attach of message to modify
- when "Update" button is clicked send message with: PATCH
/freedata/messages/ as URL and message in body There is some
problems for doing this (ID propagation, attach process, etc.) but I
think this is the correct roadmap. Thanks Franco Spinelli IW2DHW

Franco, this isnt working yet, as the message id is unique and the actual way is, dropping a message if it is received again. The reason is, that we want to implement this, when we have hmac message signing enabled - same with deleting a wrong message remotely afterwards.

No problem at all. I am very far away to a solution.

For updating a message I need ID of message (and this can be solved) but I have also to get all attached files (and can be in any number). For each file there is a need to remove it and to add a new file as attach.

The update to message body is the easy part......

I am thinking to a pop-up but it is too complex for a pop-up.

More study is needed. in the meantime "no update to message"!

Regards

Franco Spinelli IW2DHW

frspin commented 1 month ago

After updating with git pull to latest version in develop branch the problem is not solved

If I remove --vfo from my rigctld start command

rigctld -m 1043 -r /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A907OEFM-if00-port0 -s 38400

and start modem with

FREEDATA_CONFIG=freedata_server/config.ini python3 freedata_server/server.py

I get this on terminal window:

2024-06-02 10:21.29 [C2 ] Libcodec2 loaded path=/mnt/Prog/ham/FreeDATA/freedata_server/lib/codec2/libcodec2.so Using config from freedata_server/config.ini 2024-06-02 10:21.29 [RIGCTLD] Connected to rigctld at 127.0.0.1:4532 2024-06-02 10:21.29 [DatabaseManager]: Initialized database 2024-06-02 10:21.29 tested audio devices result=[True, True] 2024-06-02 10:21.29 starting freedata_server.... 2024-06-02 10:21.29 [C2 ] Create 48<->8 kHz resampler 2024-06-02 10:21.29 [C2 ] Creating audio buffer size=9600 2024-06-02 10:21.29 [C2 ] Creating audio buffer size=9600 2024-06-02 10:21.29 [C2 ] Creating audio buffer size=9600 2024-06-02 10:21.29 [C2 ] Creating audio buffer size=9600 2024-06-02 10:21.29 [C2 ] Creating audio buffer size=9600 2024-06-02 10:21.29 [C2 ] Creating audio buffer size=9600 2024-06-02 10:21.29 [C2 ] Creating audio buffer size=9600 2024-06-02 10:21.29 [C2 ] Creating audio buffer size=9600 2024-06-02 10:21.29 loading frame dispatcher.....

2024-06-02 10:21.29 Event: ev={'freedata_server': 'started'} 2024-06-02 10:21.29 [MDM] init: get audio devices input_device=5b4d output_device=5b4d 2024-06-02 10:21.29 [MDM] init: receiving audio from 'pulse' 2024-06-02 10:21.29 [MDM] init: transmiting audio on 'pulse' 2024-06-02 10:21.29 [MDM] init: starting pyaudio callback and decoding threads 2024-06-02 10:21.29 [C2 ] Create 48<->8 kHz resampler 2024-06-02 10:21.30 [DatabaseManager]: Database vacuumed successfully 2024-06-02 10:21.30 Error getting ALC: could not convert string to float: 'PKTUSB\n0' 2024-06-02 10:21.30 [DatabaseManager]: Database reindexed successfully 2024-06-02 10:21.30 [DatabaseManager]: Database integrity check passed INFO: Started server process [15103] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://127.0.0.1:5000 (Press CTRL+C to quit) 2024-06-02 10:21.30 [DatabaseManagerBeacon]: Deleted 0 beacons older than 2 days 2024-06-02 10:21.31 Error getting ALC: could not convert string to float: 'PKTUSB\n0' 2024-06-02 10:21.31 [RIGCTLD] Error getting TUNER state: invalid literal for int() with base 10: '0.000000' 2024-06-02 10:21.32 [RIGCTLD] Connected to rigctld at 127.0.0.1:4532 2024-06-02 10:21.32 Error getting ALC: could not convert string to float: 'PKTUSB\n0' 2024-06-02 10:21.33 Error getting ALC: could not convert string to float: 'PKTUSB\n0'

and, after a Ctrl C, modem is not ending and I required to kill it with a kill -9 [pid]

Restoring --vfo solve the problem for RIGCTLD error but problem of not exiting with CtrlC remain

Franco Spinelli IW2DHW

frspin commented 1 month ago

No change after latest commit

2024-06-02 11:12.28 [DatabaseManagerBeacon]: Deleted 0 beacons older than 2 days 2024-06-02 11:12.29 Error getting frequency: invalid literal for int() with base 10: 'VFOB' 2024-06-02 11:12.30 Error getting frequency: invalid literal for int() with base 10: 'VFOB' l ALC PKTUSB 0 False 2024-06-02 11:12.30 Error getting ALC: could not convert string to float: 'PKTUSB\n0'

Another info.

On my rig there is no ALC info from rigctld If I do with rigctl

l ALC

I get

Rig command: l ALC get_level: error = Invalid parameter rig_ext_lookup called rigctl_get_level: level not found=ALC rigctl_parse.c(3199):rigctl_get_level return(-1)

and

Rig command: l ? RFPOWER RAWSTR SWR STRENGTH

Franco Spinelli IW2DHW

DJ2LS commented 1 month ago

@frspin please do a git pull and give another test run

frspin commented 1 month ago

I think there is a step to do before issue a "l" command. Not all rigs have all info.

So a

l ? command give a list of available info and only for this can be done a query.

In my rig only RFPOWER RAWSTR SWR STRENGTH are available so we can do only a call to: get_rf() get_swr() get_strength()

but not get_alc()

For info response to rigctld.py commands for get_XXX done with rigctl command are:

spin@franco:/mnt/Prog/ham/FreeDATA$ rigctl -m 2

Rig command: v VFO: VFOB

Rig command: u TUNER get_func: error = Invalid parameter rig_parse_func called rig_ext_lookup called rigctl_parse.c(3331):rigctl_get_func return(-1)

Rig command: v VFO: VFOB

Rig command: f Frequency: 14093000

Rig command: m Mode: PKTUSB Passband: 0

Rig command: l ALC get_level: error = Invalid parameter rig_ext_lookup called rigctl_get_level: level not found=ALC rigctl_parse.c(3199):rigctl_get_level return(-1)

Rig command: l STRENGTH Level Value: -12

Rig command: l RFPOWER Level Value: 0.000000

Rig command: l SWR Level Value: 0.000000

Franco Spinelli IW2DHW

DJ2LS commented 1 month ago

@frspin , rigctld should ignore the commands if they are not available, so I think thats working - but I might be wrong.

frspin commented 1 month ago

Il 02/06/24 12:23, DJ2LS ha scritto:

@frspin https://github.com/frspin , rigctld should ignore the commands if they are not available, so I think thats working - but I might be wrong.

What I have seen is in my Ubuntu with hamlib, rigctld and rigctl from Ubuntu repo.

In your rigctld.py you have:

         self.get_vfo()
         self.get_frequency()
         self.get_mode_bandwidth()
         self.get_alc()
         self.get_strength()
         self.get_rf()
         self.get_tuner()
         self.get_swr()

and, using hamlib python binding with this simple program:

import Hamlib model = Hamlib.RIG_MODEL_NETRIGCTL Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE) rig = Hamlib.Rig(model) rig.open () print(rig.get_vfo()) print(rig.get_freq()) print(rig.get_mode()) print(rig.get_level_i('ALC')) print(rig.get_level_i('RFPOWER')) print(rig.get_level_i('SWR')) print(rig.get_level_i('STRENGTH'))

I get:

2 14093000.0 [2048, 0] 0 0 0 -12

So, with hamlib, there is a response to all questions. Your function is directly using a socket and commands (like rigctl is doing). I don't know if this is the problem or not.

Inserting "print" command after self.send_command(command) in any of get_XXXX functions show an "out of sync" response

get_vfo 0.000000 get_tune None get_vfo None get_swr None 2024-06-02 15:02.50 [DatabaseManagerBeacon]: Deleted 0 beacons older than 2 days get_vfo 0.000000 get_vfo VFOB get_frequency VFOB 2024-06-02 15:02.51 Error getting frequency: invalid literal for int() with base 10: 'VFOB' get_vfo 14093000 get_mode_bandwidth None get_vfo None get_alc None get_vfo None get_strebgth None get_vfo -12 get_rf None get_vfo 0.000000 get_tune None get_vfo None get_swr None get_vfo 0.000000 get_vfo VFOB get_frequency VFOB 2024-06-02 15:02.53 Error getting frequency: invalid literal for int() with base 10: 'VFOB' get_vfo 14093000 get_mode_bandwidth None get_vfo None get_alc PKTUSB 0 l ALC PKTUSB 0 False 2024-06-02 15:02.53 Error getting ALC: could not convert string to float: 'PKTUSB\n0' get_vfo None get_strebgth None get_vfo -12 get_rf None get_vfo 0.000000 get_tune None get_vfo None get_swr None get_vfo 0.000000 get_vfo VFOB get_frequency VFOB 2024-06-02 15:02.54 Error getting frequency: invalid literal for int() with base 10: 'VFOB' get_vfo 14093000 get_mode_bandwidth None get_vfo None get_alc PKTUSB 0 l ALC PKTUSB 0 False 2024-06-02 15:02.54 Error getting ALC: could not convert string to float: 'PKTUSB\n0'

Very strange!

Franco Spinelli IW2DHW

frspin commented 1 month ago

Running modem when rigctld is started with --vfo give correct response.

But CtrlC don't kill the server

Franco Spinelli IW2DHW