Breno,
Welcome to the forum
A lot depends on how your PrimaryLine is set up. The default for OBi110 is:
Physical Interfaces -> PHONE Port -> PrimaryLine : PSTN Line
This means that you do not need to dial **8 to use the PSTN line. I will assume that is the case.
I will have a go at the first part you asked for: 1 - Calls to another state: 0xx xxxxxxx (10 digits) - Call through SP2/FreeVoipDeal, also that first 0 would have to act as "0055". If it makes sense to you, then have a go at the others or come back and I'll try some more.
Take your existing Line Port DigitMap:
(1xx|[34]00xxxx|0800xxxxxxx|1xxxx|[2-9]xxxxxxx|90xx.)
Change to:
(<0:**20055>x[1-9]xxxxxxx|1xx|[34]00xxxx|0800xxxxxxx|1xxxx|[2-9]xxxxxxx|90xx.)
I made assumptions following very little research – with calls to another state the third digit cannot be a "0". This means we can avoid conflict with 0800 numbers.
First rule: If a number starts with a 0, the third digit is not a 0 and is ten digits long, then replace the leading 0 with **20055. When this number, **20055xxxxxxxxx, is processed by the Phone Port OutboundCallRoute, the **2 will be removed and 0055xxxxxxxxx will be sent out to Service Provider 2. To make this work a rule 0055xxxxxxxxx will also need to be in the Service Providers -> ITSP Profile B -> General -> DigitMap (which is Msp2).
Simple
To be fair that is unusually difficult. I hope my assumptions were correct. If not, then I would need more info on Brazilian number formats.
There is a conflict in your original DigitMap as it contains these two rules: 1xx and 1xxxx. If you dial 1xxxx fairly slowly the 1xx rule will match it after 1xx has been dialled. The way we normally deal with this is to change the shortest rule by adding a delay – 1xxS4 – this gives more time for users dialling 1xxxx. The problem is that it delays your emergency number calling. Can any other digits be used to avoid conflicts – maybe the second digits can be different?
Anyhow, that's more than enough to think about for one post